API Gateway Stage tags support (#4160)
This commit is contained in:
parent
2f26e870b8
commit
7240e8f965
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from moto.utilities.utils import merge_multiple_dicts
|
||||
from moto.core.responses import BaseResponse
|
||||
from .models import apigateway_backends
|
||||
from .exceptions import (
|
||||
@ -363,6 +364,24 @@ class APIGatewayResponse(BaseResponse):
|
||||
|
||||
return 200, {}, json.dumps(stage_response)
|
||||
|
||||
def restapis_stages_tags(self, request, full_url, headers):
|
||||
self.setup_class(request, full_url, headers)
|
||||
url_path_parts = self.path.split("/")
|
||||
function_id = url_path_parts[4]
|
||||
stage_name = url_path_parts[6]
|
||||
if self.method == "PUT":
|
||||
tags = self._get_param("tags")
|
||||
if tags:
|
||||
stage = self.backend.get_stage(function_id, stage_name)
|
||||
stage["tags"] = merge_multiple_dicts(stage.get("tags"), tags)
|
||||
return 200, {}, json.dumps({"item": tags})
|
||||
if self.method == "DELETE":
|
||||
stage = self.backend.get_stage(function_id, stage_name)
|
||||
for tag in stage.get("tags").copy():
|
||||
if tag in self.querystring.get("tagKeys"):
|
||||
stage["tags"].pop(tag, None)
|
||||
return 200, {}, json.dumps({"item": ""})
|
||||
|
||||
def stages(self, request, full_url, headers):
|
||||
self.setup_class(request, full_url, headers)
|
||||
url_path_parts = self.path.split("/")
|
||||
|
@ -12,6 +12,7 @@ url_paths = {
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/authorizers$": response.restapis_authorizers,
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/authorizers/(?P<authorizer_id>[^/]+)/?$": response.authorizers,
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/stages$": response.restapis_stages,
|
||||
"{0}/tags/arn:aws:apigateway:(?P<region_name>[^/]+)::/restapis/(?P<function_id>[^/]+)/stages/(?P<stage_name>[^/]+)/?$": response.restapis_stages_tags,
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/stages/(?P<stage_name>[^/]+)/?$": response.stages,
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/deployments$": response.deployments,
|
||||
"{0}/restapis/(?P<function_id>[^/]+)/deployments/(?P<deployment_id>[^/]+)/?$": response.individual_deployment,
|
||||
|
@ -78,6 +78,9 @@ TestAccAWSUserPolicyAttachment
|
||||
TestAccAWSUserSSHKey
|
||||
TestAccAWSVpc_
|
||||
TestAccAWSRouteTable_disappears
|
||||
TestAccAWSAPIGatewayStage_basic
|
||||
TestAccAWSAPIGatewayStage_accessLogSettings_kinesis
|
||||
TestAccAWSAPIGatewayStage_accessLogSettings
|
||||
TestAccAWSRouteTable_RequireRouteTarget
|
||||
TestAccAWSRouteTable_Route_ConfigMode
|
||||
TestAccAWSRouteTable_tags
|
||||
|
Loading…
Reference in New Issue
Block a user