Skip to content

add_tags async

add_tags(
    load_balancer_names: LoadBalancerNames,
    tags: TagList,
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
) -> AddTagsOutput

Adds the specified tags to the specified load balancer. Each load balancer can have a maximum of 10 tags.

Each tag consists of a key and an optional value. If a tag with the same key is already associated with the load balancer, AddTags updates its value.

For more information, see Tag Your Classic Load Balancer in the Classic Load Balancers Guide.

Parameters:

  • load_balancer_names (LoadBalancerNames) –

    The name of the load balancer. You can specify one load balancer only.

  • tags (TagList) –

    The tags.

Raises:

Examples:

To add tags to a load balancer This example adds two tags to the specified load balancer.

>>> await client.add_tags(load_balancer_names=['my-load-balancer'], tags=[{'Key': 'project', 'Value': 'lima'}, {'Key': 'department', 'Value': 'digital-media'}])
Source code in docs_src/capo_elastic_load_balancing/_services/async_elastic_load_balancing.py
async def add_tags(
    self,
    load_balancer_names: "capo_elastic_load_balancing.types.load_balancer_names.LoadBalancerNames",
    tags: "capo_elastic_load_balancing.types.tag_list.TagList",
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.add_tags_output.AddTagsOutput":
    """<p>Adds the specified tags to the specified load balancer. Each load balancer can have a maximum of 10 tags.</p> <p>Each tag consists of a key and an optional value. If a tag with the same key is already associated with the load balancer, <code>AddTags</code> updates its value.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html">Tag Your Classic Load Balancer</a> in the <i>Classic Load Balancers Guide</i>.</p>

    Args:
        load_balancer_names: <p>The name of the load balancer. You can specify one load balancer only.</p>
        tags: <p>The tags.</p>

    Raises:
        capo_elastic_load_balancing.errors.access_point_not_found_exception.AccessPointNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing.errors.duplicate_tag_keys_exception.DuplicateTagKeysException: <p>A tag key was specified more than once.</p>
        capo_elastic_load_balancing.errors.too_many_tags_exception.TooManyTagsException: <p>The quota for the number of tags that can be assigned to a load balancer has been reached.</p>
        capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To add tags to a load balancer
        This example adds two tags to the specified load balancer.

        >>> await client.add_tags(load_balancer_names=['my-load-balancer'], tags=[{'Key': 'project', 'Value': 'lima'}, {'Key': 'department', 'Value': 'digital-media'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elastic_load_balancing.types.add_tags_input.AddTagsInput]",
    ) -> AsyncOperationResponse[
        "capo_elastic_load_balancing.types.add_tags_output.AddTagsOutput"
    ]:
        import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.add_tags

        (
            output,
            http_response,
        ) = await capo_elastic_load_balancing._operations.elastic_load_balancing_v7.add_tags.async_add_tags(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AddTags")
    )
    input_: capo_elastic_load_balancing.types.add_tags_input.AddTagsInput = {
        "load_balancer_names": load_balancer_names,
        "tags": tags,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output