How to use the botocore.xform_name function in botocore

To help you get started, we’ve selected a few botocore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github boto / botocore / tests / unit / test_utils.py View on Github external
def test_consecutive_upper_case_middle_string(self):
        self.assertEqual(xform_name('MainHTTPHeaders'), 'main_http_headers')
        self.assertEqual(xform_name('MainHTTPHeaders', '-'),
                         'main-http-headers')
github boto / boto3 / boto3 / docs / waiter.py View on Github external
waiter_model = service_waiter_model.get_waiter(
        resource_waiter_model.waiter_name)
    operation_model = service_model.operation_model(
        waiter_model.operation)

    ignore_params = get_resource_ignore_params(resource_waiter_model.params)
    service_module_name = get_service_module_name(service_model)
    description = (
        'Waits until this %s is %s. This method calls '
        ':py:meth:`%s.Waiter.%s.wait` which polls. '
        ':py:meth:`%s.Client.%s` every %s seconds until '
        'a successful state is reached. An error is returned '
        'after %s failed checks.' % (
            resource_name, ' '.join(resource_waiter_model.name.split('_')[2:]),
            service_module_name,
            xform_name(resource_waiter_model.waiter_name),
            service_module_name,
            xform_name(waiter_model.operation),
            waiter_model.delay, waiter_model.max_attempts))
    example_prefix = '%s.%s' % (
        xform_name(resource_name), resource_waiter_model.name)
    document_model_driven_method(
        section=section, method_name=resource_waiter_model.name,
        operation_model=operation_model,
        event_emitter=event_emitter,
        example_prefix=example_prefix,
        method_description=description,
        exclude_input=ignore_params,
        include_signature=include_signature
    )
    if 'return' in section.available_sections:
        # Waiters do not return anything so we should remove
github rpcme / aws-cloud-and-xilinx-workshop / cloud / xilinx-bitstream-deploy-handler / botocore / client.py View on Github external
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
github theriley106 / EchoLinguistics / sampleSkill / lambda / boto3 / resources / model.py View on Github external
Load a name with a given category, possibly renaming it
        if that name is already in use. The name will be stored
        in ``names`` and possibly be set up in ``self._renamed``.

        :type names: set
        :param names: Existing names (Python attributes, properties, or
                      methods) on the resource.
        :type name: string
        :param name: The original name of the value.
        :type category: string
        :param category: The value type, such as 'identifier' or 'action'
        :type snake_case: bool
        :param snake_case: True (default) if the name should be snake cased.
        """
        if snake_case:
            name = xform_name(name)

        if name in names:
            logger.debug('Renaming %s %s %s' % (self.name, category, name))
            self._renamed[(category, name)] = name + '_' + category
            name += '_' + category

            if name in names:
                # This isn't good, let's raise instead of trying to keep
                # renaming this value.
                raise ValueError('Problem renaming {0} {1} to {2}!'.format(
                    self.name, category, name))

        names.add(name)
github MStarmans91 / WORC / .eggs / boto3-1.8.8-py2.7.egg / boto3 / docs / action.py View on Github external
: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
    )
github MStarmans91 / WORC / .eggs / boto3-1.8.8-py2.7.egg / boto3 / resources / model.py View on Github external
like the following:

            {
                'some_name': ('SomeName', )
            }

        :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
github theriley106 / EchoLinguistics / sampleSkill / lambda / boto3 / resources / collection.py View on Github external
def _load_batch_actions(self, attrs, resource_name, collection_model,
                            service_model, event_emitter):
        """
        Batch actions on the collection become methods on both
        the collection manager and iterators.
        """
        for action_model in collection_model.batch_actions:
            snake_cased = xform_name(action_model.name)
            attrs[snake_cased] = self._create_batch_action(
                resource_name, snake_cased, action_model, collection_model,
                service_model, event_emitter)
github boto / boto3 / boto3 / docs.py View on Github external
if resource_model.collections:
        docs += ('   .. rst-class:: admonition-title\n\n   Collections\n\n'
                 '   Collections provide an interface to iterate and'
                 ' manipulate groups of resources.\n\n')
        for collection in sorted(resource_model.collections,
                                 key=lambda i: i.name):
            docs += ('   .. py:attribute:: {0}\n\n      '
                     '(:py:class:`{1}.{2}CollectionManager`)'
                     ' A collection of :py:class:`{3}.{4}` instances. This'
                     ' collection uses the :py:meth:`{5}.Client.{6}` operation'
                     ' to get items.\n\n').format(
                        xform_name(collection.name), service_name,
                        collection.name, service_name,
                        collection.resource.type, service_name,
                        xform_name(collection.request.operation))

    if resource_model.waiters:
        docs += ('   .. rst-class:: admonition-title\n\n   Waiters\n\n'
                 '   Waiters provide an interface to wait for a resource'
                 ' to reach a specific state.\n\n')
        service_waiter_model = session.get_waiter_model(service_name)
        for waiter in sorted(resource_model.waiters,
                             key=lambda i: i.name):
            docs += document_waiter(waiter, service_name, resource_model,
                                    service_model, service_waiter_model)

    return docs
github theriley106 / EchoLinguistics / sampleSkill / lambda / boto3 / resources / response.py View on Github external
:param raw_response: Low-level operation response.
    :rtype: list
    :return: An ordered list of ``(name, value)`` identifier tuples.
    """
    results = []

    for identifier in identifiers:
        source = identifier.source
        target = identifier.target

        if source == 'response':
            value = jmespath.search(identifier.path, raw_response)
        elif source == 'requestParameter':
            value = jmespath.search(identifier.path, params)
        elif source == 'identifier':
            value = getattr(parent, xform_name(identifier.name))
        elif source == 'data':
            # If this is a data member then it may incur a load
            # action before returning the value.
            value = get_data_member(parent, identifier.path)
        elif source == 'input':
            # This value is set by the user, so ignore it here
            continue
        else:
            raise NotImplementedError(
                'Unsupported source type: {0}'.format(source))

        results.append((xform_name(target), value))

    return results
github spulec / moto / scripts / implementation_coverage.py View on Github external
def calculate_implementation_coverage():
    service_names = Session().get_available_services()
    coverage = {}
    for service_name in service_names:
        moto_client = get_moto_implementation(service_name)
        real_client = boto3.client(service_name, region_name='us-east-1')
        implemented = []
        not_implemented = []

        operation_names = [xform_name(op) for op in real_client.meta.service_model.operation_names]
        for op in operation_names:
            if moto_client and op in dir(moto_client):
                implemented.append(op)
            else:
                not_implemented.append(op)

        coverage[service_name] = {
            'implemented': implemented,
            'not_implemented': not_implemented,
        }
    return coverage