Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ImplementationCoverage for APIGateway #3733

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions IMPLEMENTATION_COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@

## apigateway
<details>
<summary>34% implemented</summary>
<summary>38% implemented</summary>

- [ ] create_api_key
- [X] create_api_key
- [X] create_authorizer
- [ ] create_base_path_mapping
- [X] create_deployment
Expand All @@ -274,7 +274,7 @@
- [X] create_usage_plan
- [X] create_usage_plan_key
- [ ] create_vpc_link
- [ ] delete_api_key
- [X] delete_api_key
- [X] delete_authorizer
- [ ] delete_base_path_mapping
- [ ] delete_client_certificate
Expand All @@ -299,8 +299,8 @@
- [ ] flush_stage_cache
- [ ] generate_client_certificate
- [ ] get_account
- [ ] get_api_key
- [ ] get_api_keys
- [X] get_api_key
- [X] get_api_keys
- [X] get_authorizer
- [X] get_authorizers
- [ ] get_base_path_mapping
Expand Down
12 changes: 6 additions & 6 deletions moto/apigateway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,18 +1155,18 @@ def delete_deployment(self, function_id, deployment_id):
api = self.get_rest_api(function_id)
return api.delete_deployment(deployment_id)

def create_apikey(self, payload):
def create_api_key(self, payload):
if payload.get("value") is not None:
if len(payload.get("value", [])) < 20:
raise ApiKeyValueMinLength()
for api_key in self.get_apikeys(include_values=True):
for api_key in self.get_api_keys(include_values=True):
if api_key.get("value") == payload["value"]:
raise ApiKeyAlreadyExists()
key = ApiKey(**payload)
self.keys[key["id"]] = key
return key

def get_apikeys(self, include_values=False):
def get_api_keys(self, include_values=False):
api_keys = list(self.keys.values())

if not include_values:
Expand All @@ -1179,7 +1179,7 @@ def get_apikeys(self, include_values=False):

return api_keys

def get_apikey(self, api_key_id, include_value=False):
def get_api_key(self, api_key_id, include_value=False):
api_key = self.keys[api_key_id]

if not include_value:
Expand All @@ -1189,11 +1189,11 @@ def get_apikey(self, api_key_id, include_value=False):

return api_key

def update_apikey(self, api_key_id, patch_operations):
def update_api_key(self, api_key_id, patch_operations):
key = self.keys[api_key_id]
return key.update_operations(patch_operations)

def delete_apikey(self, api_key_id):
def delete_api_key(self, api_key_id):
self.keys.pop(api_key_id)
return {}

Expand Down
10 changes: 5 additions & 5 deletions moto/apigateway/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def apikeys(self, request, full_url, headers):

if self.method == "POST":
try:
apikey_response = self.backend.create_apikey(json.loads(self.body))
apikey_response = self.backend.create_api_key(json.loads(self.body))
except ApiKeyAlreadyExists as error:
return (
error.code,
Expand All @@ -451,7 +451,7 @@ def apikeys(self, request, full_url, headers):

elif self.method == "GET":
include_values = self._get_bool_param("includeValues")
apikeys_response = self.backend.get_apikeys(include_values=include_values)
apikeys_response = self.backend.get_api_keys(include_values=include_values)
return 200, {}, json.dumps({"item": apikeys_response})

def apikey_individual(self, request, full_url, headers):
Expand All @@ -463,14 +463,14 @@ def apikey_individual(self, request, full_url, headers):
status_code = 200
if self.method == "GET":
include_value = self._get_bool_param("includeValue")
apikey_response = self.backend.get_apikey(
apikey_response = self.backend.get_api_key(
apikey, include_value=include_value
)
elif self.method == "PATCH":
patch_operations = self._get_param("patchOperations")
apikey_response = self.backend.update_apikey(apikey, patch_operations)
apikey_response = self.backend.update_api_key(apikey, patch_operations)
elif self.method == "DELETE":
apikey_response = self.backend.delete_apikey(apikey)
apikey_response = self.backend.delete_api_key(apikey)
status_code = 202

return status_code, {}, json.dumps(apikey_response)
Expand Down