Skip to content

delete_service async

delete_service(
    id: Arn, *, config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None
) -> DeleteServiceResponse

Deletes a specified service and all associated service attributes. If the service still contains one or more registered instances, the request fails.

Parameters:

  • id (Arn) –

    The ID or Amazon Resource Name (ARN) of the service that you want to delete. If the namespace associated with the service is shared with your Amazon Web Services account, specify the service ARN. For more information about shared namespaces, see Cross-account Cloud Map namespace sharing.

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.

  • ResourceInUse –

    The specified resource can't be deleted because it contains other resources. For example, you can't delete a service that contains any instances.

  • ServiceNotFound –

    No service exists with the specified ID.

  • UnknownServiceError –

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

Examples:

Example: Delete service Example: Delete service

>>> await client.delete_service(id='srv-p5zdwlg5uvvzjita')
Delete service using service ARN
Deletes a service using a service ARN instead of service ID, useful when working with shared namespaces.
>>> await client.delete_service(id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678')
Source code in docs_src/capo_servicediscovery/_services/async_service_discovery.py
async def delete_service(
    self,
    id: "capo_servicediscovery.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
) -> "capo_servicediscovery.types.delete_service_response.DeleteServiceResponse":
    """<p>Deletes a specified service and all associated service attributes. If the service still contains one or more registered instances, the request fails.</p>

    Args:
        id: <p>The ID or Amazon Resource Name (ARN) of the service that you want to delete. If the namespace associated with the service is shared with your Amazon Web Services account, specify the service ARN. For more information about shared namespaces, see <a href="https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html">Cross-account Cloud Map namespace sharing</a>.</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.resource_in_use.ResourceInUse: <p>The specified resource can't be deleted because it contains other resources. For example, you can't delete a service that contains any instances.</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:
        Example: Delete service
        Example: Delete service

        >>> await client.delete_service(id='srv-p5zdwlg5uvvzjita')
        Delete service using service ARN
        Deletes a service using a service ARN instead of service ID, useful when working with shared namespaces.

        >>> await client.delete_service(id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_servicediscovery.types.delete_service_request.DeleteServiceRequest]",
    ) -> AsyncOperationResponse[
        "capo_servicediscovery.types.delete_service_response.DeleteServiceResponse"
    ]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.delete_service

        (
            output,
            http_response,
        ) = await capo_servicediscovery._operations.route53_auto_naming_v20170314.delete_service.async_delete_service(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteService")
    )
    input_: capo_servicediscovery.types.delete_service_request.DeleteServiceRequest = {
        "id": id
    }

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