Esempio n. 1
0
 def model_sql_to_model(model_sql: ServiceTypeSQL) -> ServiceType:
     model = ServiceType()
     ''' STRINGS '''
     model.name = model_sql.name
     model.id = model_sql.id_name
     model.short_name = model_sql.short_name
     model.description = model_sql.description
     ''' BOOLEANS '''
     model.bindable = model_sql.bindable
     model.plan_updateable = model_sql.plan_updateable
     ''' LISTS '''
     model.tags = json.loads(model_sql.tags)
     model.requires = json.loads(model_sql.requires)
     ''' OBJECTS '''
     model.metadata = ServiceMetadataAdapter.from_blob(model_sql.metadata)
     model.dashboard_client = DashboardClientAdapter.from_blob(
         model_sql.dashboard_client)
     model.plans = PlanAdapter.plans_from_service_sql(model_sql)
     return model
Esempio n. 2
0
 def sample_model(name='service1') -> ServiceType:
     model = ServiceType()
     ''' STRINGS '''
     model.id = name
     model.name = name
     model.short_name = name
     model.description = 'description' + name
     ''' BOOLEANS '''
     model.bindable = False
     model.plan_updateable = False
     ''' LISTS '''
     model.tags = ['description1']
     model.requires = ['requirement1']
     ''' OBJECTS '''
     model.metadata = ServiceMetadata(display_name='metadata1')
     model.dashboard_client = DashboardClient(id='client1')
     ''' PLANS '''
     model.plans = [
         PlanAdapter.sample_model(name + 'plan1'),
         PlanAdapter.sample_model(name + 'plan2')
     ]
     return model