Python botocore.xform_name() Examples
The following are 30
code examples of botocore.xform_name().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore
, or try the search function
.
Example #1
Source File: client.py From deepWordBug with Apache License 2.0 | 6 votes |
def get_waiter(self, waiter_name): """Returns an object that can wait for some condition. :type waiter_name: str :param waiter_name: The name of the waiter to get. See the waiters section of the service docs for a list of available waiters. :returns: The specified waiter object. :rtype: botocore.waiter.Waiter """ config = self._get_waiter_config() if not config: raise ValueError("Waiter does not exist: %s" % waiter_name) model = waiter.WaiterModel(config) mapping = {} for name in model.waiter_names: mapping[xform_name(name)] = name if waiter_name not in mapping: raise ValueError("Waiter does not exist: %s" % waiter_name) return waiter.create_waiter_with_client( mapping[waiter_name], model, self)
Example #2
Source File: model.py From faces with GNU General Public License v2.0 | 6 votes |
def _get_name(self, category, name, snake_case=True): """ Get a possibly renamed value given a category and name. This uses the rename map set up in ``load_rename_map``, so that method must be called once first. :type category: string :param category: The value type, such as 'identifier' or 'action' :type name: string :param name: The original name of the value :type snake_case: bool :param snake_case: True (default) if the name should be snake cased. :rtype: string :return: Either the renamed value if it is set, otherwise the original name. """ if snake_case: name = xform_name(name) return self._renamed.get((category, name), name)
Example #3
Source File: waiter.py From faces with GNU General Public License v2.0 | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #4
Source File: clidriver.py From bash-lambda-layer with MIT License | 6 votes |
def _create_command_table(self): command_table = OrderedDict() service_model = self._get_service_model() for operation_name in service_model.operation_names: cli_name = xform_name(operation_name, '-') operation_model = service_model.operation_model(operation_name) command_table[cli_name] = ServiceOperation( name=cli_name, parent_name=self._name, session=self.session, operation_model=operation_model, operation_caller=CLIOperationCaller(self.session), ) self.session.emit('building-command-table.%s' % self._name, command_table=command_table, session=self.session, command_object=self) self._add_lineage(command_table) return command_table
Example #5
Source File: action.py From faces with GNU General Public License v2.0 | 6 votes |
def __call__(self, parent, *args, **kwargs): """ Perform the wait operation after building operation parameters. :type parent: :py:class:`~boto3.resources.base.ServiceResource` :param parent: The resource instance to which this action is attached. """ client_waiter_name = xform_name(self._waiter_model.waiter_name) # First, build predefined params and then update with the # user-supplied kwargs, which allows overriding the pre-built # params if needed. params = create_request_parameters(parent, self._waiter_model) params.update(kwargs) logger.info('Calling %s:%s with %r', parent.meta.service_name, self._waiter_resource_name, params) client = parent.meta.client waiter = client.get_waiter(client_waiter_name) response = waiter.wait(**params) logger.debug('Response: %r', response)
Example #6
Source File: waiter.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #7
Source File: client.py From bash-lambda-layer with MIT License | 6 votes |
def get_waiter(self, waiter_name): """Returns an object that can wait for some condition. :type waiter_name: str :param waiter_name: The name of the waiter to get. See the waiters section of the service docs for a list of available waiters. :returns: The specified waiter object. :rtype: botocore.waiter.Waiter """ config = self._get_waiter_config() if not config: raise ValueError("Waiter does not exist: %s" % waiter_name) model = waiter.WaiterModel(config) mapping = {} for name in model.waiter_names: mapping[xform_name(name)] = name if waiter_name not in mapping: raise ValueError("Waiter does not exist: %s" % waiter_name) return waiter.create_waiter_with_client( mapping[waiter_name], model, self)
Example #8
Source File: client.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def get_waiter(self, waiter_name): """Returns an object that can wait for some condition. :type waiter_name: str :param waiter_name: The name of the waiter to get. See the waiters section of the service docs for a list of available waiters. :returns: The specified waiter object. :rtype: botocore.waiter.Waiter """ config = self._get_waiter_config() if not config: raise ValueError("Waiter does not exist: %s" % waiter_name) model = waiter.WaiterModel(config) mapping = {} for name in model.waiter_names: mapping[xform_name(name)] = name if waiter_name not in mapping: raise ValueError("Waiter does not exist: %s" % waiter_name) return waiter.create_waiter_with_client( mapping[waiter_name], model, self)
Example #9
Source File: model.py From faces with GNU General Public License v2.0 | 6 votes |
def _get_name(self, category, name, snake_case=True): """ Get a possibly renamed value given a category and name. This uses the rename map set up in ``load_rename_map``, so that method must be called once first. :type category: string :param category: The value type, such as 'identifier' or 'action' :type name: string :param name: The original name of the value :type snake_case: bool :param snake_case: True (default) if the name should be snake cased. :rtype: string :return: Either the renamed value if it is set, otherwise the original name. """ if snake_case: name = xform_name(name) return self._renamed.get((category, name), name)
Example #10
Source File: action.py From faces with GNU General Public License v2.0 | 6 votes |
def __call__(self, parent, *args, **kwargs): """ Perform the wait operation after building operation parameters. :type parent: :py:class:`~boto3.resources.base.ServiceResource` :param parent: The resource instance to which this action is attached. """ client_waiter_name = xform_name(self._waiter_model.waiter_name) # First, build predefined params and then update with the # user-supplied kwargs, which allows overriding the pre-built # params if needed. params = create_request_parameters(parent, self._waiter_model) params.update(kwargs) logger.info('Calling %s:%s with %r', parent.meta.service_name, self._waiter_resource_name, params) client = parent.meta.client waiter = client.get_waiter(client_waiter_name) response = waiter.wait(**params) logger.debug('Response: %r', response)
Example #11
Source File: model.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def _get_name(self, category, name, snake_case=True): """ Get a possibly renamed value given a category and name. This uses the rename map set up in ``load_rename_map``, so that method must be called once first. :type category: string :param category: The value type, such as 'identifier' or 'action' :type name: string :param name: The original name of the value :type snake_case: bool :param snake_case: True (default) if the name should be snake cased. :rtype: string :return: Either the renamed value if it is set, otherwise the original name. """ if snake_case: name = xform_name(name) return self._renamed.get((category, name), name)
Example #12
Source File: waiter.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #13
Source File: waiter.py From faces with GNU General Public License v2.0 | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #14
Source File: action.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def __call__(self, parent, *args, **kwargs): """ Perform the wait operation after building operation parameters. :type parent: :py:class:`~boto3.resources.base.ServiceResource` :param parent: The resource instance to which this action is attached. """ client_waiter_name = xform_name(self._waiter_model.waiter_name) # First, build predefined params and then update with the # user-supplied kwargs, which allows overriding the pre-built # params if needed. params = create_request_parameters(parent, self._waiter_model) params.update(kwargs) logger.debug('Calling %s:%s with %r', parent.meta.service_name, self._waiter_resource_name, params) client = parent.meta.client waiter = client.get_waiter(client_waiter_name) response = waiter.wait(**params) logger.debug('Response: %r', response)
Example #15
Source File: waiter.py From deepWordBug with Apache License 2.0 | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #16
Source File: waiter.py From bash-lambda-layer with MIT License | 6 votes |
def _add_single_waiter(self, section, waiter_name): section = section.add_new_section(waiter_name) section.style.start_sphinx_py_class( class_name='%s.Waiter.%s' % ( self._client.__class__.__name__, waiter_name)) # Add example on how to instantiate waiter. section.style.start_codeblock() section.style.new_line() section.write( 'waiter = client.get_waiter(\'%s\')' % xform_name(waiter_name) ) section.style.end_codeblock() # Add information on the wait() method section.style.new_line() document_wait_method( section=section, waiter_name=waiter_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, service_waiter_model=self._service_waiter_model )
Example #17
Source File: paginator.py From bash-lambda-layer with MIT License | 5 votes |
def _add_paginator(self, section, paginator_name): section = section.add_new_section(paginator_name) # Docment the paginator class section.style.start_sphinx_py_class( class_name='%s.Paginator.%s' % ( self._client.__class__.__name__, paginator_name)) section.style.start_codeblock() section.style.new_line() # Document how to instantiate the paginator. section.write( 'paginator = client.get_paginator(\'%s\')' % xform_name( paginator_name) ) section.style.end_codeblock() section.style.new_line() # Get the pagination model for the particular paginator. paginator_config = self._service_paginator_model.get_paginator( paginator_name) document_paginate_method( section=section, paginator_name=paginator_name, event_emitter=self._client.meta.events, service_model=self._client.meta.service_model, paginator_config=paginator_config )
Example #18
Source File: discovery.py From bash-lambda-layer with MIT License | 5 votes |
def discovery_operation_name(self): discovery_operation = self._service_model.endpoint_discovery_operation return xform_name(discovery_operation.name)
Example #19
Source File: client.py From bash-lambda-layer with MIT License | 5 votes |
def _create_name_mapping(self, service_model): # py_name -> OperationName, for every operation available # for a service. mapping = {} for operation_name in service_model.operation_names: py_operation_name = xform_name(operation_name) mapping[py_operation_name] = operation_name return mapping
Example #20
Source File: discovery.py From deepWordBug with Apache License 2.0 | 5 votes |
def discovery_operation_name(self): discovery_operation = self._service_model.endpoint_discovery_operation return xform_name(discovery_operation.name)
Example #21
Source File: client.py From bash-lambda-layer with MIT License | 5 votes |
def _create_methods(self, service_model): op_dict = {} for operation_name in service_model.operation_names: py_operation_name = xform_name(operation_name) op_dict[py_operation_name] = self._create_api_method( py_operation_name, operation_name, service_model) return op_dict
Example #22
Source File: clidriver.py From bash-lambda-layer with MIT License | 5 votes |
def _unpack_arg(self, cli_argument, value): # Unpacks a commandline argument into a Python value by firing the # load-cli-arg.service-name.operation-name event. session = self._session service_name = self._operation_model.service_model.endpoint_prefix operation_name = xform_name(self._name, '-') return unpack_argument(session, service_name, operation_name, cli_argument, value)
Example #23
Source File: waiters.py From bash-lambda-layer with MIT License | 5 votes |
def invoke(self, service_name, operation_name, parameters, parsed_globals): client = self._session.create_client( service_name, region_name=parsed_globals.region, endpoint_url=parsed_globals.endpoint_url, verify=parsed_globals.verify_ssl) waiter = client.get_waiter(xform_name(self._waiter_name)) waiter.wait(**parameters) return 0
Example #24
Source File: clidriver.py From bash-lambda-layer with MIT License | 5 votes |
def _create_argument_table(self): argument_table = OrderedDict() input_shape = self._operation_model.input_shape required_arguments = [] arg_dict = {} if input_shape is not None: required_arguments = input_shape.required_members arg_dict = input_shape.members for arg_name, arg_shape in arg_dict.items(): cli_arg_name = xform_name(arg_name, '-') arg_class = self.ARG_TYPES.get(arg_shape.type_name, self.DEFAULT_ARG_CLASS) is_token = arg_shape.metadata.get('idempotencyToken', False) is_required = arg_name in required_arguments and not is_token event_emitter = self._session.get_component('event_emitter') arg_object = arg_class( name=cli_arg_name, argument_model=arg_shape, is_required=is_required, operation_model=self._operation_model, serialized_name=arg_name, event_emitter=event_emitter) arg_object.add_to_arg_table(argument_table) LOG.debug(argument_table) self._emit('building-argument-table.%s.%s' % (self._parent_name, self._name), operation_model=self._operation_model, session=self._session, command=self, argument_table=argument_table) return argument_table
Example #25
Source File: clidriver.py From bash-lambda-layer with MIT License | 5 votes |
def _make_client_call(self, client, operation_name, parameters, parsed_globals): py_operation_name = xform_name(operation_name) if client.can_paginate(py_operation_name) and parsed_globals.paginate: paginator = client.get_paginator(py_operation_name) response = paginator.paginate(**parameters) else: response = getattr(client, xform_name(operation_name))( **parameters) return response
Example #26
Source File: createdefaultroles.py From bash-lambda-layer with MIT License | 5 votes |
def _call_iam_operation(self, operation_name, parameters, parsed_globals): client = self._session.create_client( 'iam', region_name=self.region, endpoint_url=self.iam_endpoint_url, verify=parsed_globals.verify_ssl) return getattr(client, xform_name(operation_name))(**parameters)
Example #27
Source File: action.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def document_load_reload_action(section, action_name, resource_name, event_emitter, load_model, service_model, include_signature=True): """Documents the resource load action :param section: The section to write to :param action_name: The name of the loading action should be load or reload :param resource_name: The name of the resource :param event_emitter: The event emitter to use to emit events :param load_model: The model of the load action :param service_model: The model of the service :param include_signature: Whether or not to include the signature. It is useful for generating docstrings. """ description = ( 'Calls :py:meth:`%s.Client.%s` to update the attributes of the' ' %s resource. Note that the load and reload methods are ' 'the same method and can be used interchangeably.' % ( get_service_module_name(service_model), xform_name(load_model.request.operation), resource_name) ) example_resource_name = xform_name(resource_name) if service_model.service_name == resource_name: example_resource_name = resource_name example_prefix = '%s.%s' % (example_resource_name, action_name) document_model_driven_method( section=section, method_name=action_name, operation_model=OperationModel({}, service_model), event_emitter=event_emitter, method_description=description, example_prefix=example_prefix, include_signature=include_signature )
Example #28
Source File: model.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def get_attributes(self, shape): """ Get a dictionary of attribute names to original name and shape models that represent the attributes of this resource. Looks like the following: { 'some_name': ('SomeName', <Shape...>) } :type shape: botocore.model.Shape :param shape: The underlying shape for this resource. :rtype: dict :return: Mapping of resource attributes. """ attributes = {} identifier_names = [i.name for i in self.identifiers] for name, member in shape.members.items(): snake_cased = xform_name(name) if snake_cased in identifier_names: # Skip identifiers, these are set through other means continue snake_cased = self._get_name('attribute', snake_cased, snake_case=False) attributes[snake_cased] = (name, member) return attributes
Example #29
Source File: collection.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def __init__(self, model, parent, handler, **kwargs): self._model = model self._parent = parent self._py_operation_name = xform_name( model.request.operation) self._handler = handler self._params = copy.deepcopy(kwargs)
Example #30
Source File: action.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def document_action(section, resource_name, event_emitter, action_model, service_model, include_signature=True): """Documents a resource action :param section: The section to write to :param resource_name: The name of the resource :param event_emitter: The event emitter to use to emit events :param action_model: The model of the action :param service_model: The model of the service :param include_signature: Whether or not to include the signature. It is useful for generating docstrings. """ operation_model = service_model.operation_model( action_model.request.operation) ignore_params = get_resource_ignore_params(action_model.request.params) example_return_value = 'response' if action_model.resource: example_return_value = xform_name(action_model.resource.type) example_resource_name = xform_name(resource_name) if service_model.service_name == resource_name: example_resource_name = resource_name example_prefix = '%s = %s.%s' % ( example_return_value, example_resource_name, action_model.name) document_model_driven_resource_method( section=section, method_name=action_model.name, operation_model=operation_model, event_emitter=event_emitter, method_description=operation_model.documentation, example_prefix=example_prefix, exclude_input=ignore_params, resource_action_model=action_model, include_signature=include_signature )