Example #1
0
def translate_definition(operation, http_response, parsed, **kwargs):
    api_objects = parsed.pop('pipelineObjects', None)
    if api_objects is None:
        return
    else:
        definition = translator.api_to_definition(api_objects)
        parsed['objects'] = definition['objects']
Example #2
0
 def test_api_to_df_with_dupe_keys(self):
     # Duplicate keys should be aggregated into a list.
     api = [{
         "name":
         "S3ToS3Copy",
         "id":
         "S3ToS3Copy",
         "fields": [{
             "key": "type",
             "stringValue": "CopyActivity"
         }, {
             "key": "schedule",
             "refValue": "CopyPeriod"
         }, {
             "key": "script",
             "stringValue": "value1"
         }, {
             "key": "script",
             "stringValue": "value2"
         }]
     }]
     definition = translator.api_to_definition(api)
     self.assertEqual(
         definition, {
             'objects': [{
                 'id': 'S3ToS3Copy',
                 'name': 'S3ToS3Copy',
                 'type': 'CopyActivity',
                 'schedule': {
                     'ref': 'CopyPeriod'
                 },
                 'script': ['value1', 'value2'],
             }]
         })
Example #3
0
 def test_api_to_df(self):
     api = [{"name": "S3ToS3Copy", "id": "S3ToS3Copy",
             "fields": [{"key": "type", "stringValue": "CopyActivity" },
                        {"key": "schedule", "refValue": "CopyPeriod" },
                        {"key": "input", "refValue": "InputData"},
                        {"key": "output", "refValue": "OutputData"}]}]
     definition = translator.api_to_definition(api)
     self.assertEqual(definition, {
         'objects': [{
             'id': 'S3ToS3Copy',
             'name': 'S3ToS3Copy',
             'type': 'CopyActivity',
             'schedule': {'ref': 'CopyPeriod'},
             'input': {'ref': 'InputData'},
             'output': {'ref': 'OutputData'}
         }]
     })
Example #4
0
 def test_api_to_df_with_dupe_keys(self):
     # Duplicate keys should be aggregated into a list.
     api = [{"name": "S3ToS3Copy", "id": "S3ToS3Copy",
             "fields": [{"key": "type", "stringValue": "CopyActivity" },
                        {"key": "schedule", "refValue": "CopyPeriod" },
                        {"key": "script", "stringValue": "value1"},
                        {"key": "script", "stringValue": "value2"}]}]
     definition = translator.api_to_definition(api)
     self.assertEqual(definition, {
         'objects': [{
             'id': 'S3ToS3Copy',
             'name': 'S3ToS3Copy',
             'type': 'CopyActivity',
             'schedule': {'ref': 'CopyPeriod'},
             'script': ['value1', 'value2'],
         }]
     })
Example #5
0
 def test_api_to_df(self):
     api = {
         "pipelineObjects": [{
             "name":
             "S3ToS3Copy",
             "id":
             "S3ToS3Copy",
             "fields": [{
                 "key": "type",
                 "stringValue": "CopyActivity"
             }, {
                 "key": "schedule",
                 "refValue": "CopyPeriod"
             }, {
                 "key": "input",
                 "refValue": "InputData"
             }, {
                 "key": "output",
                 "refValue": "OutputData"
             }]
         }]
     }
     definition = translator.api_to_definition(api)
     self.assertEqual(
         definition, {
             'objects': [{
                 'id': 'S3ToS3Copy',
                 'name': 'S3ToS3Copy',
                 'type': 'CopyActivity',
                 'schedule': {
                     'ref': 'CopyPeriod'
                 },
                 'input': {
                     'ref': 'InputData'
                 },
                 'output': {
                     'ref': 'OutputData'
                 }
             }]
         })
Example #6
0
def translate_definition(parsed, **kwargs):
    translator.api_to_definition(parsed)
Example #7
0
 def test_api_to_df_with_parameter_objects_and_values(self):
     # Tests for proper handling of parameter value arrays as well
     api = {"parameterObjects": [
         {"attributes": [
             {"key": "max", "stringValue": "24"},
             {"key": "description",
              "stringValue": "Number of pipeline runs"},
             {"key": "type", "stringValue": "Integer"}],
          "id": "myOccurrenceNumber"},
         {"attributes": [
             {"key": "max", "stringValue": "3"},
             {"key": "description", "stringValue": "number of retires"},
             {"key": "type", "stringValue": "Integer"}],
          "id": "myMaximumRetries"}],
         "parameterValues": [
             {"id": "myOccurrenceNumber", "stringValue": "4"},
             {"id": "myMaximumRetries", "stringValue": "2"},
             {"id": "myMaximumRetries", "stringValue": "3"}],
         "pipelineObjects": [
             {"fields": [
                 {"key": "startDateTime",
                     "stringValue": "2011-01-01T00:00:00"},
                 {"key": "occurrences",
                     "stringValue": "#{myOccurrenceNumber}"},
                 {"key": "period",
                     "stringValue": "1 YEAR"},
                 {"key": "type",
                     "stringValue": "Schedule"}],
                 "id": "CopyPeriod",
                 "name": "CopyPeriod"},
             {"fields": [
                 {"key": "schedule", "refValue": "CopyPeriod"},
                 {"key": "retryDelay", "stringValue": "1 MINUTE"},
                 {"key": "command", "stringValue": "false"},
                 {"key": "maximumRetries",
                     "stringValue": "#{myMaximumRetries}"},
                 {"key": "workerGroup", "stringValue": "$PIPELINE_ID"},
                 {"key": "type", "stringValue": "ShellCommandActivity"}],
                 "id": "ShellCommand",
                 "name": "ShellCommand"}]}
     expected = {"parameters": [
         {
             "max": "24",
             "type": "Integer",
             "id": "myOccurrenceNumber",
             "description": "Number of pipeline runs"},
         {
             "max": "3",
             "type": "Integer",
             "id": "myMaximumRetries",
             "description": "number of retires"}
     ], "objects": [
         {
             "name": "CopyPeriod",
             "period": "1 YEAR",
             "occurrences": "#{myOccurrenceNumber}",
             "startDateTime": "2011-01-01T00:00:00",
             "type": "Schedule",
             "id": "CopyPeriod"
         }, {
             "name": "ShellCommand",
             "schedule": {"ref": "CopyPeriod"},
             "retryDelay": "1 MINUTE",
             "workerGroup": "$PIPELINE_ID",
             "command": "false",
             "type": "ShellCommandActivity",
             "id": "ShellCommand",
             "maximumRetries": "#{myMaximumRetries}"
         }
     ], "values":
         {
             "myMaximumRetries": ["2", "3"],
             "myOccurrenceNumber": "4"
         }
     }
     actual = translator.api_to_definition(api)
     self.assertEqual(expected, actual)
Example #8
0
 def test_api_to_df_with_parameter_objects_and_values(self):
     # Tests for proper handling of parameter value arrays as well
     api = {
         "parameterObjects": [{
             "attributes": [{
                 "key": "max",
                 "stringValue": "24"
             }, {
                 "key": "description",
                 "stringValue": "Number of pipeline runs"
             }, {
                 "key": "type",
                 "stringValue": "Integer"
             }],
             "id":
             "myOccurrenceNumber"
         }, {
             "attributes": [{
                 "key": "max",
                 "stringValue": "3"
             }, {
                 "key": "description",
                 "stringValue": "number of retires"
             }, {
                 "key": "type",
                 "stringValue": "Integer"
             }],
             "id":
             "myMaximumRetries"
         }],
         "parameterValues": [{
             "id": "myOccurrenceNumber",
             "stringValue": "4"
         }, {
             "id": "myMaximumRetries",
             "stringValue": "2"
         }, {
             "id": "myMaximumRetries",
             "stringValue": "3"
         }],
         "pipelineObjects": [{
             "fields": [{
                 "key": "startDateTime",
                 "stringValue": "2011-01-01T00:00:00"
             }, {
                 "key": "occurrences",
                 "stringValue": "#{myOccurrenceNumber}"
             }, {
                 "key": "period",
                 "stringValue": "1 YEAR"
             }, {
                 "key": "type",
                 "stringValue": "Schedule"
             }],
             "id":
             "CopyPeriod",
             "name":
             "CopyPeriod"
         }, {
             "fields": [{
                 "key": "schedule",
                 "refValue": "CopyPeriod"
             }, {
                 "key": "retryDelay",
                 "stringValue": "1 MINUTE"
             }, {
                 "key": "command",
                 "stringValue": "false"
             }, {
                 "key": "maximumRetries",
                 "stringValue": "#{myMaximumRetries}"
             }, {
                 "key": "workerGroup",
                 "stringValue": "$PIPELINE_ID"
             }, {
                 "key": "type",
                 "stringValue": "ShellCommandActivity"
             }],
             "id":
             "ShellCommand",
             "name":
             "ShellCommand"
         }]
     }
     expected = {
         "parameters": [{
             "max": "24",
             "type": "Integer",
             "id": "myOccurrenceNumber",
             "description": "Number of pipeline runs"
         }, {
             "max": "3",
             "type": "Integer",
             "id": "myMaximumRetries",
             "description": "number of retires"
         }],
         "objects": [{
             "name": "CopyPeriod",
             "period": "1 YEAR",
             "occurrences": "#{myOccurrenceNumber}",
             "startDateTime": "2011-01-01T00:00:00",
             "type": "Schedule",
             "id": "CopyPeriod"
         }, {
             "name": "ShellCommand",
             "schedule": {
                 "ref": "CopyPeriod"
             },
             "retryDelay": "1 MINUTE",
             "workerGroup": "$PIPELINE_ID",
             "command": "false",
             "type": "ShellCommandActivity",
             "id": "ShellCommand",
             "maximumRetries": "#{myMaximumRetries}"
         }],
         "values": {
             "myMaximumRetries": ["2", "3"],
             "myOccurrenceNumber": "4"
         }
     }
     actual = translator.api_to_definition(api)
     self.assertEqual(expected, actual)
Example #9
0
def translate_definition(parsed, **kwargs):
    translator.api_to_definition(parsed)