Best Python code snippet using localstack_python
routers.py
Source:routers.py
1# Copyright 2013 Metacloud, Inc.2# Copyright 2012 OpenStack Foundation3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15"""WSGI Routers for the Resource service."""16from keystone.common import json_home17from keystone.common import router18from keystone.common import wsgi19from keystone.resource import controllers20class Admin(wsgi.ComposableRouter):21 def add_routes(self, mapper):22 # Tenant Operations23 tenant_controller = controllers.Tenant()24 mapper.connect('/tenants',25 controller=tenant_controller,26 action='get_all_projects',27 conditions=dict(method=['GET']))28 mapper.connect('/tenants/{tenant_id}',29 controller=tenant_controller,30 action='get_project',31 conditions=dict(method=['GET']))32class Routers(wsgi.RoutersBase):33 def append_v3_routers(self, mapper, routers):34 routers.append(35 router.Router(controllers.DomainV3(),36 'domains', 'domain',37 resource_descriptions=self.v3_resources))38 config_controller = controllers.DomainConfigV3()39 self._add_resource(40 mapper, config_controller,41 path='/domains/{domain_id}/config',42 get_head_action='get_domain_config',43 put_action='create_domain_config',44 patch_action='update_domain_config_only',45 delete_action='delete_domain_config',46 rel=json_home.build_v3_resource_relation('domain_config'),47 path_vars={48 'domain_id': json_home.Parameters.DOMAIN_ID49 })50 config_group_param = (51 json_home.build_v3_parameter_relation('config_group'))52 self._add_resource(53 mapper, config_controller,54 path='/domains/{domain_id}/config/{group}',55 get_head_action='get_domain_config',56 patch_action='update_domain_config_group',57 delete_action='delete_domain_config',58 rel=json_home.build_v3_resource_relation('domain_config_group'),59 path_vars={60 'domain_id': json_home.Parameters.DOMAIN_ID,61 'group': config_group_param62 })63 self._add_resource(64 mapper, config_controller,65 path='/domains/{domain_id}/config/{group}/{option}',66 get_head_action='get_domain_config',67 patch_action='update_domain_config',68 delete_action='delete_domain_config',69 rel=json_home.build_v3_resource_relation('domain_config_option'),70 path_vars={71 'domain_id': json_home.Parameters.DOMAIN_ID,72 'group': config_group_param,73 'option': json_home.build_v3_parameter_relation(74 'config_option')75 })76 self._add_resource(77 mapper, config_controller,78 path='/domains/config/default',79 get_action='get_domain_config_default',80 rel=json_home.build_v3_resource_relation('domain_config_default'))81 self._add_resource(82 mapper, config_controller,83 path='/domains/config/{group}/default',84 get_action='get_domain_config_default',85 rel=json_home.build_v3_resource_relation(86 'domain_config_default_group'),87 path_vars={88 'group': config_group_param89 })90 self._add_resource(91 mapper, config_controller,92 path='/domains/config/{group}/{option}/default',93 get_action='get_domain_config_default',94 rel=json_home.build_v3_resource_relation(95 'domain_config_default_option'),96 path_vars={97 'group': config_group_param,98 'option': json_home.build_v3_parameter_relation(99 'config_option')100 })101 routers.append(102 router.Router(controllers.ProjectV3(),103 'projects', 'project',...
app.py
Source:app.py
...9from .settings import manifest, settings10from .webhooks import product_created, product_deleted, product_updated11async def validate_domain(saleor_domain: DomainName) -> bool:12 db = next(get_db())13 db_config = get_domain_config(db, saleor_domain)14 if db_config:15 return True16 return False17async def store_app_data(18 saleor_domain: DomainName, auth_token: str, webhook_data: WebhookData19):20 print("Called store_app_data")21 db = next(get_db())22 update_domain_config(23 db,24 saleor_domain,25 auth_token,26 webhook_data.webhook_id,27 webhook_data.webhook_secret_key,28 )29async def get_webhook_details(saleor_domain: DomainName) -> WebhookData:30 db = next(get_db())31 db_config = get_domain_config(db, saleor_domain)32 return WebhookData(33 webhook_id=db_config.webhook_id,34 webhook_secret_key=db_config.webhook_secret,35 )36app = SaleorApp(37 manifest=manifest,38 validate_domain=validate_domain,39 save_app_data=store_app_data,40 use_insecure_saleor_http=settings.debug,41)42app.configuration_router.include_router(configuration_router)43app.include_router(extension_router, prefix="/products")44app.include_saleor_app_routes()45app.include_webhook_router(get_webhook_details)...
domain_config_manager.py
Source:domain_config_manager.py
...14 domain_config_vo: DomainConfig = self.domain_config_model.create(params)15 self.transaction.add_rollback(_rollback, domain_config_vo)16 return domain_config_vo17 def update_domain_config(self, params):18 domain_config_vo: DomainConfig = self.get_domain_config(params['name'], params['domain_id'])19 return self.update_domain_config_by_vo(params, domain_config_vo)20 def update_domain_config_by_vo(self, params, domain_config_vo):21 def _rollback(old_data):22 _LOGGER.info(f'[update_domain_config_by_vo._rollback] Revert Data : {old_data["name"]}')23 domain_config_vo.update(old_data)24 self.transaction.add_rollback(_rollback, domain_config_vo.to_dict())25 return domain_config_vo.update(params)26 def delete_domain_config(self, name, domain_id):27 domain_config_vo: DomainConfig = self.get_domain_config(name, domain_id)28 domain_config_vo.delete()29 def get_domain_config(self, name, domain_id, only=None):30 return self.domain_config_model.get(name=name, domain_id=domain_id, only=only)31 def filter_domain_configs(self, **conditions):32 return self.domain_config_model.filter(**conditions)33 def list_domain_configs(self, query={}):34 return self.domain_config_model.query(**query)35 def state_domain_configs(self, query):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!