Exemplo n.º 1
0
class S3URI(SAMSchema):
    Bucket = CharForeignProperty(Ref, required=True)
    Key = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        return obj
Exemplo n.º 2
0
class Parameter(SAMSchema):
    name = CharForeignProperty(Ref, required=True)
    Type = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        name = obj.pop('name')
        return {'name': name, 'r': obj}
Exemplo n.º 3
0
class API(Resource):
    _resource_type = "AWS::Serverless::Api"

    StageName = CharForeignProperty(Ref, required=True)
    DefinitionUri = CharForeignProperty(Ref)
    DefinitionBody = DictProperty()
    CacheClusterEnabled = BooleanProperty()
    CacheClusterSize = CharForeignProperty(Ref)
    Variables = DictProperty()
Exemplo n.º 4
0
class LambdaCode(SAMSchema):
    S3Bucket = CharForeignProperty(Ref, required=True)
    S3Key = CharForeignProperty(Ref, required=True)
    S3ObjectVersion = CharForeignProperty(Ref, required=True)
    ZipFile = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        return obj
Exemplo n.º 5
0
class Function(AbstractFunction):
    _resource_type = 'AWS::Serverless::Function'
    _serverless_type = True

    CodeUri = ForeignProperty(S3URI)
    Policies = CharForeignProperty(Ref)
    Events = ForeignInstanceListProperty(EventSchema)
    Tracing = CharForeignProperty(Ref)
    DeadLetterQueue = ForeignInstanceListProperty(DeadLetterQueueSchema)
    ReservedConcurrentExecutions = IntegerProperty()
Exemplo n.º 6
0
class Output(SAMSchema):
    name = CharForeignProperty(Ref, required=True)
    Description = CharForeignProperty(Ref)
    Value = CharForeignProperty(Ref)
    Export = DictProperty()

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        name = obj.pop('name')
        return {'name': name, 'r': obj}
Exemplo n.º 7
0
class SQS(Resource):
    _resource_type = 'AWS::SQS::Queue'
    _serverless_type = False

    ContentBasedDeduplication = BooleanProperty()
    DelaySeconds = IntForeignProperty(SAMSchema)
    FifoQueue = BooleanProperty()
    KmsMasterKeyId = CharForeignProperty(SAMSchema)
    KmsDataKeyReusePeriodSeconds = IntForeignProperty(SAMSchema)
    MaximumMessageSize = IntForeignProperty(SAMSchema)
    MessageRetentionPeriod = IntForeignProperty(SAMSchema)
    ReceiveMessageWaitTimeSeconds = IntForeignProperty(SAMSchema)
    VisibilityTimeout = IntForeignProperty(SAMSchema)
    QueueName = CharForeignProperty(Ref)
Exemplo n.º 8
0
class DynamoDBTable(Resource):
    _resource_type = "AWS::DynamoDB::Table"
    _serverless_type = False

    AttributeDefinitions = ListProperty(required=True)
    TableName = CharForeignProperty(SAMSchema, required=True)
    GlobalSecondaryIndexes = ListProperty()
    KeySchema = ListProperty(required=True)
    BillingMode = CharForeignProperty(Ref)
    LocalSecondaryIndexes = ListProperty()
    PointInTimeRecoverySpecification = DictProperty()
    ProvisionedThroughput = DictProperty()
    SSESpecification = DictProperty()
    StreamSpecification = DictProperty()
    Tags = DictProperty()
    TimeToLiveSpecification = DictProperty()
Exemplo n.º 9
0
class DeadLetterQueueSchema(SAMSchema):
    _dlq_type = None

    name = CharForeignProperty(Ref, required=True)
    TargetArn = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        event = {
            'name': obj.pop('name'),
            'r': {
                'Type': self._dlq_type,
                'Properties': obj
            }
        }

        return event
Exemplo n.º 10
0
class EventSchema(SAMSchema):
    _event_type = None

    name = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        event = {'name': obj.pop('name'), 'r': {'Type': self._event_type}}

        if len(obj.keys()) > 0:
            event['r']['Properties'] = obj
        return event
Exemplo n.º 11
0
class Sub(SAMSchema):
    Sub = CharForeignProperty(Ref, required=True)
    Map = DictProperty()

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        Map = obj.get('Map', None)
        if not Map:
            return {
                "Fn::Sub": obj.get('Sub'),
            }
        else:
            return {"Fn::Sub": [obj.get('Sub'), obj.get('Map')]}
Exemplo n.º 12
0
class Function(Resource):
    _resource_type = 'AWS::Serverless::Function'

    Handler = CharForeignProperty(Ref, required=True)
    Runtime = CharForeignProperty(Ref, required=True, max_length=15)
    CodeUri = ForeignProperty(S3URI)
    FunctionName = CharForeignProperty(Ref)
    Description = CharForeignProperty(Ref)
    MemorySize = IntegerProperty()
    Timeout = IntegerProperty()
    Role = CharForeignProperty(SAMSchema)
    Policies = CharForeignProperty(Ref)
    Environment = ForeignProperty(Environment)
    VpcConfig = DictProperty()
    Events = ForeignInstanceListProperty(EventSchema)
    Tags = DictProperty()
    Tracing = CharForeignProperty(Ref)
    KmsKeyArn = CharForeignProperty(Ref)
    DeadLetterQueue = ForeignInstanceListProperty(DeadLetterQueueSchema)

    def to_dict(self):

        obj = super(Function, self).to_dict()
        try:
            events = [
                i.to_dict() for i in obj['r']['Properties'].pop('Events')
            ]

            obj['r']['Properties']['Events'] = {
                i.get('name'): i.get('r')
                for i in events
            }
        except KeyError:
            pass

        try:
            dlq = [
                i.to_dict()
                for i in obj['r']['Properties'].pop('DeadLetterQueue')
            ]
            obj['r']['Properties']['DeadLetterQueue'] = {
                i.get('name'): i.get('r')
                for i in dlq
            }
        except KeyError:
            pass

        return obj
Exemplo n.º 13
0
class Resource(SAMSchema):
    _resource_type = None

    name = CharForeignProperty(Ref, required=True)

    def to_dict(self):
        obj = remove_nulls(self._data.copy())
        name = obj.pop('name')

        r_attrs = {'Type': self._resource_type}
        if len(obj.keys()) > 0:
            r_attrs['Properties'] = {k: v for k, v in obj.items() if v}
        return {'name': name, 'r': r_attrs}

    def add_attr(self, k, v):
        self.r_attrs['Properties'][k] = v
Exemplo n.º 14
0
class AbstractFunction(Resource):
    Handler = CharForeignProperty(Ref, required=True)
    Runtime = CharForeignProperty(Ref, required=True, max_length=15)
    FunctionName = CharForeignProperty(Ref)
    Description = CharForeignProperty(Ref)
    MemorySize = IntegerProperty()
    Timeout = IntegerProperty()
    Role = CharForeignProperty(SAMSchema)
    Environment = ForeignProperty(Environment)
    VpcConfig = DictProperty()
    KmsKeyArn = CharForeignProperty(Ref)
    Tags = DictProperty()

    def to_dict(self):

        obj = super(AbstractFunction, self).to_dict()
        try:
            events = [
                i.to_dict() for i in obj['r']['Properties'].pop('Events')
            ]

            obj['r']['Properties']['Events'] = {
                i.get('name'): i.get('r')
                for i in events
            }
        except KeyError:
            pass

        try:
            dlq = [
                i.to_dict()
                for i in obj['r']['Properties'].pop('DeadLetterQueue')
            ]
            obj['r']['Properties']['DeadLetterQueue'] = {
                i.get('name'): i.get('r')
                for i in dlq
            }
        except KeyError:
            pass

        return obj
Exemplo n.º 15
0
class ScheduleEvent(EventSchema):
    Schedule = CharForeignProperty(Ref, required=True)
    Input = CharForeignProperty(Ref)
Exemplo n.º 16
0
class SQS(Resource):
    _resource_type = 'AWS::SQS::Queue'
    QueueName = CharForeignProperty(Ref)
Exemplo n.º 17
0
class IoTRuleEvent(EventSchema):
    Sql = CharForeignProperty(Ref, required=True)
    AwsIotSqlVersion = CharForeignProperty(Ref)
Exemplo n.º 18
0
class S3KeyFilter(SAMSchema):
    S3Key = CharForeignProperty(Ref)
Exemplo n.º 19
0
class DynamoDBEvent(EventSchema):
    _event_type = 'DynamoDB'

    Stream = CharForeignProperty(Ref, required=True)
    StartingPosition = CharForeignProperty(Ref, required=True)
    BatchSize = IntegerProperty()
Exemplo n.º 20
0
class S3(Resource):
    _resource_type = 'AWS::S3::Bucket'
    _serverless_type = False

    BucketName = CharForeignProperty(Ref)
Exemplo n.º 21
0
class SNSEvent(EventSchema):
    _event_type = 'SNS'

    Topic = CharForeignProperty(Ref, required=True)
Exemplo n.º 22
0
class S3Event(EventSchema):
    _event_type = 'S3'

    Bucket = CharForeignProperty(Ref, required=True)
    Events = ListProperty(required=True)
    Filter = ForeignProperty(S3KeyFilter)
Exemplo n.º 23
0
class APIEvent(EventSchema):
    _event_type = 'Api'

    Path = CharForeignProperty(Ref, required=True)
    Method = CharForeignProperty(Ref, required=True, choices=API_METHODS)
    RestApiId = CharForeignProperty(Ref)
Exemplo n.º 24
0
class SQSEvent(EventSchema):
    _event_type = 'SQS'

    Queue = CharForeignProperty(Ref, required=True)
    BatchSize = IntForeignProperty(Ref)
Exemplo n.º 25
0
class CloudWatchEvent(EventSchema):
    Pattern = DictProperty(required=True)
    Input = CharForeignProperty(Ref)
    InputPath = CharForeignProperty(Ref)