Skip to content

update_service_attributes

update_service_attributes(
    service_id: Arn,
    attributes: ServiceAttributesMap,
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
) -> UpdateServiceAttributesResponse

Submits a request to update a specified service to add service-level attributes.

Parameters:

  • service_id (Arn) –

    The ID or Amazon Resource Name (ARN) of the service that you want to update. For services created in a namespace shared with your Amazon Web Services account, specify the service ARN.

  • attributes (ServiceAttributesMap) –

    A string map that contains attribute key-value pairs.

Raises:

  • InvalidInput –

    One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.

  • ServiceAttributesLimitExceededException –

    The attribute can't be added to the service because you've exceeded the quota for the number of attributes you can add to a service.

  • ServiceNotFound –

    No service exists with the specified ID.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Update service attributes using service ARN Updates service attributes using a service ARN instead of service ID, useful when working with shared namespaces.

>>> client.update_service_attributes(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678', attributes={'Port': '8080', 'Protocol': 'HTTP'})
UpdateServiceAttributes Example
This example submits a request to update the specified service to add a port attribute with the value 80.
>>> client.update_service_attributes(service_id='srv-e4anhexample0004', attributes={'port': '80'})
Source code in docs_src/capo_servicediscovery/_services/service_discovery.py
def update_service_attributes(
    self,
    service_id: "capo_servicediscovery.types.arn.Arn",
    attributes: "capo_servicediscovery.types.service_attributes_map.ServiceAttributesMap",
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
) -> "capo_servicediscovery.types.update_service_attributes_response.UpdateServiceAttributesResponse":
    """<p>Submits a request to update a specified service to add service-level attributes.</p>

    Args:
        service_id: <p>The ID or Amazon Resource Name (ARN) of the service that you want to update. For services created in a namespace shared with your Amazon Web Services account, specify the service ARN.</p>
        attributes: <p>A string map that contains attribute key-value pairs.</p>

    Raises:
        capo_servicediscovery.errors.invalid_input.InvalidInput: <p>One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.</p>
        capo_servicediscovery.errors.service_attributes_limit_exceeded_exception.ServiceAttributesLimitExceededException: <p>The attribute can't be added to the service because you've exceeded the quota for the number of attributes you can add to a service.</p>
        capo_servicediscovery.errors.service_not_found.ServiceNotFound: <p>No service exists with the specified ID.</p>
        capo_servicediscovery.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Update service attributes using service ARN
        Updates service attributes using a service ARN instead of service ID, useful when working with shared namespaces.

        >>> client.update_service_attributes(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678', attributes={'Port': '8080', 'Protocol': 'HTTP'})
        UpdateServiceAttributes Example
        This example submits a request to update the specified service to add a port attribute with the value 80.

        >>> client.update_service_attributes(service_id='srv-e4anhexample0004', attributes={'port': '80'})
    """

    def _handler(
        req: "OperationRequest[capo_servicediscovery.types.update_service_attributes_request.UpdateServiceAttributesRequest]",
    ) -> OperationResponse[
        "capo_servicediscovery.types.update_service_attributes_response.UpdateServiceAttributesResponse"
    ]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.update_service_attributes

        output, http_response = (
            capo_servicediscovery._operations.route53_auto_naming_v20170314.update_service_attributes.update_service_attributes(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateServiceAttributes")
    )
    input_: capo_servicediscovery.types.update_service_attributes_request.UpdateServiceAttributesRequest = {
        "service_id": service_id,
        "attributes": attributes,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output