Skip to content

Commit

Permalink
Add apigateway Resource models
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k committed Dec 15, 2015
1 parent 1c42fde commit 900e66e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions touchdown/aws/apigateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .resource import Resource
from .rest_api import RestApi


__all__ = [
"Resource",
"RestApi",
]
60 changes: 60 additions & 0 deletions touchdown/aws/apigateway/resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2015 Isotoma Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from touchdown.core.plan import Plan
from touchdown.core import resource, argument, serializers
from ..common import SimpleDescribe, SimpleApply, SimpleDestroy

from .rest_api import RestApi


class Resource(resource.Resource):

resource_name = "resource"

name = argument.String(field="pathPart")
parent = argument.Resource(
"touchdown.aws.apigateway.rsource.Resource",
field="parentId",
)
api = argument.Resource(
RestApi,
field="restApiId"
)


class Describe(SimpleDescribe, Plan):

resource = Resource
service_name = 'apigateway'
describe_action = "get_resources"
describe_envelope = "items"
key = 'id'


class Apply(SimpleApply, Describe):

create_action = "create_resource"
create_envelope = "@"


class Destroy(SimpleDestroy, Describe):

destroy_action = "delete_resource"

def get_destroy_serializer(self):
return serializers.Dict(
restApiId=self.resource.rest_api.identifier(),
resourceId=self.resource.identifier(),
)

0 comments on commit 900e66e

Please sign in to comment.