Beispiel #1
0
    def update_engine(self, engine, updated_engine):
        updated_engine = default_and_validate(updated_engine, engine_schema())
        self._validate_ecs_task_definition(updated_engine.data.ecs_task_definition)

        p = jsonpatch.make_patch(engine.data.ecs_task_definition, updated_engine.data.ecs_task_definition)
        prior_arn_missing = not engine.data.ecs_task_definition_arn and updated_engine.data.ecs_task_definition
        if len(p.patch) > 0 or prior_arn_missing:
            self._deregister_task_definition(engine.data.ecs_task_definition_arn)
            updated_engine.data.ecs_task_definition_arn = self._register_ecs_task_definition(updated_engine)

        return self.update_engine_data(engine.id, updated_engine.data)
Beispiel #2
0
    def update_engine(self, engine, updated_engine):
        updated_engine = default_and_validate(updated_engine, engine_schema())
        self._validate_ecs_task_definition(
            updated_engine.data.ecs_task_definition)

        p = jsonpatch.make_patch(engine.data.ecs_task_definition,
                                 updated_engine.data.ecs_task_definition)
        prior_arn_missing = not engine.data.ecs_task_definition_arn and updated_engine.data.ecs_task_definition
        if len(p.patch) > 0 or prior_arn_missing:
            self._deregister_task_definition(
                engine.data.ecs_task_definition_arn)
            updated_engine.data.ecs_task_definition_arn = self._register_ecs_task_definition(
                updated_engine)

        return self.update_engine_data(engine.id, updated_engine.data)
Beispiel #3
0
    def save_engine(self, engine):
        """ :type engine: dart.model.engine.Engine """
        engine = default_and_validate(engine, engine_schema())
        self._validate_ecs_task_definition(engine.data.ecs_task_definition)

        engine_dao = EngineDao()
        engine_dao.id = random_id()
        engine_dao.name = engine.data.name
        engine_dao.data = engine.data.to_dict()
        db.session.add(engine_dao)
        try:
            db.session.commit()
            engine = engine_dao.to_model()
            engine.data.ecs_task_definition_arn = self._register_ecs_task_definition(engine)
            return self.update_engine_data(engine.id, engine.data)

        except SqlAlchemyIntegrityError as e:
            if hasattr(e, 'orig') and isinstance(e.orig, PostgresIntegrityError) and e.orig.pgcode == '23505':
                raise DartValidationException('name already exists: %s' % engine.data.name)
            raise e
def main():
    data = {
        'definitions': {
            'Action': action_schema(None),
            'ActionContext': action_context_schema(),
            'ActionResult': action_result_schema(),
            'Dataset': dataset_schema(),
            'Datastore': datastore_schema(None),
            'Engine': engine_schema(),
            'ErrorResult': error_result_schema(),
            'Event': event_schema(),
            'Filter': filter_schema(),
            'GraphEntityIdentifier': graph_entity_identifier_schema(),
            'GraphEntity': graph_entity_schema(),
            'JSONPatch': json_patch_schema(),
            'JSONSchema': json_schema_schema(),
            'OKResult': ok_result_schema(),
            'OrderBy': order_by_schema(),
            'SubGraph': sub_graph_schema(),
            'SubGraphDefinition': {
                'type': 'object'
            },  #subgraph_definition_schema([{'type': 'object'}], [{'type': 'object'}], {'type': 'object'}),
            'Subscription': subscription_schema(),
            'Trigger': trigger_schema({'type': 'object'}),
            'TriggerType': trigger_type_schema(),
            'Workflow': workflow_schema(),
            'WorkflowInstance': workflow_instance_schema()
        }
    }
    fix_up(data, data, [None])
    print dump(data,
               Dumper=Dumper,
               default_style=None,
               default_flow_style=False,
               explicit_start=False,
               explicit_end=False)
    return 0
Beispiel #5
0
    def save_engine(self, engine):
        """ :type engine: dart.model.engine.Engine """
        engine = default_and_validate(engine, engine_schema())
        self._validate_ecs_task_definition(engine.data.ecs_task_definition)

        engine_dao = EngineDao()
        engine_dao.id = random_id()
        engine_dao.name = engine.data.name
        engine_dao.data = engine.data.to_dict()
        db.session.add(engine_dao)
        try:
            db.session.commit()
            engine = engine_dao.to_model()
            engine.data.ecs_task_definition_arn = self._register_ecs_task_definition(
                engine)
            return self.update_engine_data(engine.id, engine.data)

        except SqlAlchemyIntegrityError as e:
            if hasattr(e, 'orig') and isinstance(
                    e.orig,
                    PostgresIntegrityError) and e.orig.pgcode == '23505':
                raise DartValidationException('name already exists: %s' %
                                              engine.data.name)
            raise e
def export_swagger_definitions(out):
    data = {
        'definitions': {
            'Action': action_schema({'type': 'object', 'x-nullable': True}),
            'ActionResponse': object_response_schema('Action'),
            'ActionsResponse': array_response_schema('Action'),
            'PagedActionsResponse': paged_response_schema('Action'),

            'ActionContext': action_context_schema(),
            'ActionContextResponse': object_response_schema('ActionContext'),

            'ActionResult': action_result_schema(),

            'Dataset': dataset_schema(),
            'DatasetResponse': object_response_schema('Dataset'),
            'PagedDatasetsResponse': paged_response_schema('Dataset'),

            'Datastore': datastore_schema({'type': 'object', 'x-nullable': True}),
            'DatastoreResponse': object_response_schema('Datastore'),
            'PagedDatastoresResponse': paged_response_schema('Datastore'),

            'Engine': engine_schema(),
            'EngineResponse': object_response_schema('Engine'),
            'PagedEnginesResponse': paged_response_schema('Engine'),

            'ErrorResponse': error_response_schema(),

            'Event': event_schema(),
            'EventResponse': object_response_schema('Event'),
            'PagedEventsResponse': paged_response_schema('Event'),

            'Filter': filter_schema(),

            'GraphEntityIdentifier': graph_entity_identifier_schema(),
            'GraphEntityIdentifierResponse': object_response_schema('GraphEntityIdentifier'),
            'GraphEntityIdentifiersResponse': array_response_schema('GraphEntityIdentifier'),

            'GraphEntity': graph_entity_schema(),
            'GraphEntityResponse': object_response_schema('GraphEntity'),

            'JSONPatch': json_patch_schema(),

            'JSONSchema': json_schema_schema(),
            'JSONSchemaResponse': object_response_schema('JSONSchema'),

            'ObjectResponse': object_response_schema('object'),
            'ObjectsResponse': array_response_schema('object'),
            'PagedObjectsResponse': paged_response_schema('object'),

            'OKResponse': ok_response_schema(),

            'OrderBy': order_by_schema(),

            'Subgraph': sub_graph_schema(),
            'SubgraphResponse': object_response_schema('Subgraph'),

            'SubgraphDefinition': {'type': 'object'}, #subgraph_definition_schema([{'type': 'object'}], [{'type': 'object'}], {'type': 'object'}),
            'SubgraphDefinitionResponse': object_response_schema('SubgraphDefinition'),

            'Subscription': subscription_schema(),
            'SubscriptionResponse': object_response_schema('Subscription'),
            'PagedSubscriptionsResponse': paged_response_schema('Subscription'),

            'SubscriptionElement': subscription_element_schema(),
            'PagedSubscriptionElementsResponse': paged_response_schema('SubscriptionElement'),

            'Trigger': trigger_schema({'type': 'object'}),
            'TriggerResponse': object_response_schema('Trigger'),
            'PagedTriggersResponse': paged_response_schema('Trigger'),

            'TriggerType': trigger_type_schema(),
            'PagedTriggerTypesResponse': paged_response_schema('TriggerType'),

            'Workflow': workflow_schema(),
            'WorkflowResponse': object_response_schema('Workflow'),
            'PagedWorkflowsResponse': paged_response_schema('Workflow'),

            'WorkflowInstance': workflow_instance_schema(),
            'WorkflowInstanceResponse': object_response_schema('WorkflowInstance'),
            'PagedWorkflowInstancesResponse': paged_response_schema('WorkflowInstance')
        }
    }
    fix_up(data, data, [None])
    dump(data, out, Dumper=Dumper, default_style=None, default_flow_style=False, explicit_start=False, explicit_end=False)
Beispiel #7
0
 def _query_engine_query(self, filters):
     query = EngineDao.query.order_by(EngineDao.updated)
     for f in filters:
         query = self._filter_service.apply_filter(f, query, EngineDao,
                                                   [engine_schema()])
     return query
Beispiel #8
0
def get_engine_json_schema():
    return {'results': engine_schema()}
Beispiel #9
0
def get_engine_json_schema():
    return {'results': engine_schema()}
def export_swagger_definitions(out):
    data = {
        'definitions': {
            'Action':
            action_schema({
                'type': 'object',
                'x-nullable': True
            }),
            'ActionResponse':
            object_response_schema('Action'),
            'ActionsResponse':
            array_response_schema('Action'),
            'PagedActionsResponse':
            paged_response_schema('Action'),
            'ActionContext':
            action_context_schema(),
            'ActionContextResponse':
            object_response_schema('ActionContext'),
            'ActionResult':
            action_result_schema(),
            'Dataset':
            dataset_schema(),
            'DatasetResponse':
            object_response_schema('Dataset'),
            'PagedDatasetsResponse':
            paged_response_schema('Dataset'),
            'Datastore':
            datastore_schema({
                'type': 'object',
                'x-nullable': True
            }),
            'DatastoreResponse':
            object_response_schema('Datastore'),
            'PagedDatastoresResponse':
            paged_response_schema('Datastore'),
            'Engine':
            engine_schema(),
            'EngineResponse':
            object_response_schema('Engine'),
            'PagedEnginesResponse':
            paged_response_schema('Engine'),
            'ErrorResponse':
            error_response_schema(),
            'Event':
            event_schema(),
            'EventResponse':
            object_response_schema('Event'),
            'PagedEventsResponse':
            paged_response_schema('Event'),
            'Filter':
            filter_schema(),
            'GraphEntityIdentifier':
            graph_entity_identifier_schema(),
            'GraphEntityIdentifierResponse':
            object_response_schema('GraphEntityIdentifier'),
            'GraphEntityIdentifiersResponse':
            array_response_schema('GraphEntityIdentifier'),
            'GraphEntity':
            graph_entity_schema(),
            'GraphEntityResponse':
            object_response_schema('GraphEntity'),
            'JSONPatch':
            json_patch_schema(),
            'JSONSchema':
            json_schema_schema(),
            'JSONSchemaResponse':
            object_response_schema('JSONSchema'),
            'ObjectResponse':
            object_response_schema('object'),
            'ObjectsResponse':
            array_response_schema('object'),
            'PagedObjectsResponse':
            paged_response_schema('object'),
            'OKResponse':
            ok_response_schema(),
            'OrderBy':
            order_by_schema(),
            'Subgraph':
            sub_graph_schema(),
            'SubgraphResponse':
            object_response_schema('Subgraph'),
            'SubgraphDefinition': {
                'type': 'object'
            },  #subgraph_definition_schema([{'type': 'object'}], [{'type': 'object'}], {'type': 'object'}),
            'SubgraphDefinitionResponse':
            object_response_schema('SubgraphDefinition'),
            'Subscription':
            subscription_schema(),
            'SubscriptionResponse':
            object_response_schema('Subscription'),
            'PagedSubscriptionsResponse':
            paged_response_schema('Subscription'),
            'SubscriptionElement':
            subscription_element_schema(),
            'PagedSubscriptionElementsResponse':
            paged_response_schema('SubscriptionElement'),
            'Trigger':
            trigger_schema({'type': 'object'}),
            'TriggerResponse':
            object_response_schema('Trigger'),
            'PagedTriggersResponse':
            paged_response_schema('Trigger'),
            'TriggerType':
            trigger_type_schema(),
            'PagedTriggerTypesResponse':
            paged_response_schema('TriggerType'),
            'Workflow':
            workflow_schema(),
            'WorkflowResponse':
            object_response_schema('Workflow'),
            'PagedWorkflowsResponse':
            paged_response_schema('Workflow'),
            'WorkflowInstance':
            workflow_instance_schema(),
            'WorkflowInstanceResponse':
            object_response_schema('WorkflowInstance'),
            'PagedWorkflowInstancesResponse':
            paged_response_schema('WorkflowInstance')
        }
    }
    fix_up(data, data, [None])
    dump(data,
         out,
         Dumper=Dumper,
         default_style=None,
         default_flow_style=False,
         explicit_start=False,
         explicit_end=False)
Beispiel #11
0
 def _query_engine_query(self, filters):
     query = EngineDao.query.order_by(EngineDao.updated)
     for f in filters:
         query = self._filter_service.apply_filter(f, query, EngineDao, [engine_schema()])
     return query