How to use find_api_subentity_by_id method in localstack

Best Python code snippet using localstack_python

provider.py

Source:provider.py Github

copy

Full Screen

...143 return Authorizers(items=result)144 def get_authorizer(145 self, context: RequestContext, rest_api_id: String, authorizer_id: String146 ) -> Authorizer:147 authorizer = find_api_subentity_by_id(rest_api_id, authorizer_id, "authorizers")148 if authorizer is None:149 raise NotFoundException(f"Authorizer not found: {authorizer_id}")150 return to_authorizer_response_json(rest_api_id, authorizer)151 def delete_authorizer(152 self, context: RequestContext, rest_api_id: String, authorizer_id: String153 ) -> None:154 region_details = APIGatewayRegion.get()155 auth_list = region_details.authorizers.get(rest_api_id, [])156 for i in range(len(auth_list)):157 if auth_list[i]["id"] == authorizer_id:158 del auth_list[i]159 break160 def update_authorizer(161 self,162 context: RequestContext,163 rest_api_id: String,164 authorizer_id: String,165 patch_operations: ListOfPatchOperation = None,166 ) -> Authorizer:167 region_details = APIGatewayRegion.get()168 authorizer = find_api_subentity_by_id(rest_api_id, authorizer_id, "authorizers")169 if authorizer is None:170 raise NotFoundException(f"Authorizer not found: {authorizer_id}")171 result = apply_json_patch_safe(authorizer, patch_operations)172 result = normalize_authorizer(result)173 auth_list = region_details.authorizers[rest_api_id]174 for i in range(len(auth_list)):175 if auth_list[i]["id"] == authorizer_id:176 auth_list[i] = result177 result = to_authorizer_response_json(rest_api_id, result)178 return Authorizer(**result)179 # accounts180 def get_account(181 self,182 context: RequestContext,183 ) -> Account:184 region_details = APIGatewayRegion.get()185 result = to_account_response_json(region_details.account)186 return Account(**result)187 def update_account(188 self, context: RequestContext, patch_operations: ListOfPatchOperation = None189 ) -> Account:190 region_details = APIGatewayRegion.get()191 apply_json_patch_safe(region_details.account, patch_operations, in_place=True)192 result = to_account_response_json(region_details.account)193 return Account(**result)194 # documentation parts195 def get_documentation_parts(196 self, context: RequestContext, request: GetDocumentationPartsRequest197 ) -> DocumentationParts:198 region_details = APIGatewayRegion.get()199 # This function returns either a list or a single entity (depending on the path)200 api_id = request["restApiId"]201 auth_list = region_details.documentation_parts.get(api_id) or []202 result = [to_documentation_part_response_json(api_id, a) for a in auth_list]203 result = {"item": result}204 return result205 def get_documentation_part(206 self, context: RequestContext, rest_api_id: String, documentation_part_id: String207 ) -> DocumentationPart:208 entity = find_api_subentity_by_id(rest_api_id, documentation_part_id, "documentation_parts")209 if entity is None:210 raise NotFoundException(f"Documentation part not found: {documentation_part_id}")211 return to_documentation_part_response_json(rest_api_id, entity)212 def create_documentation_part(213 self,214 context: RequestContext,215 rest_api_id: String,216 location: DocumentationPartLocation,217 properties: String,218 ) -> DocumentationPart:219 region_details = APIGatewayRegion.get()220 entity_id = short_uid()[:6] # length 6 for AWS parity / Terraform compatibility221 entry = {222 "id": entity_id,223 "restApiId": rest_api_id,224 "location": location,225 "properties": properties,226 }227 region_details.documentation_parts.setdefault(rest_api_id, []).append(entry)228 result = to_documentation_part_response_json(rest_api_id, entry)229 return DocumentationPart(**result)230 def update_documentation_part(231 self,232 context: RequestContext,233 rest_api_id: String,234 documentation_part_id: String,235 patch_operations: ListOfPatchOperation = None,236 ) -> DocumentationPart:237 region_details = APIGatewayRegion.get()238 entity = find_api_subentity_by_id(rest_api_id, documentation_part_id, "documentation_parts")239 if entity is None:240 raise NotFoundException(f"Documentation part not found: {documentation_part_id}")241 result = apply_json_patch_safe(entity, patch_operations)242 auth_list = region_details.documentation_parts[rest_api_id]243 for i in range(len(auth_list)):244 if auth_list[i]["id"] == documentation_part_id:245 auth_list[i] = result246 result = to_documentation_part_response_json(rest_api_id, result)247 return DocumentationPart(**result)248 def delete_documentation_part(249 self, context: RequestContext, rest_api_id: String, documentation_part_id: String250 ) -> None:251 region_details = APIGatewayRegion.get()252 auth_list = region_details.documentation_parts[rest_api_id]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful