internal HttpMessage CreateDeleteRequest(string id, DigitalTwinsDeleteOptions digitalTwinsDeleteOptions)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Delete;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/digitaltwins/", false);
            uri.AppendPath(id, true);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            if (digitalTwinsDeleteOptions?.Traceparent != null)
            {
                request.Headers.Add("traceparent", digitalTwinsDeleteOptions.Traceparent);
            }
            if (digitalTwinsDeleteOptions?.Tracestate != null)
            {
                request.Headers.Add("tracestate", digitalTwinsDeleteOptions.Tracestate);
            }
            if (digitalTwinsDeleteOptions?.IfMatch != null)
            {
                request.Headers.Add("If-Match", digitalTwinsDeleteOptions.IfMatch);
            }
            request.Headers.Add("Accept", "application/json");
            return(message);
        }
        public Response Delete(string id, DigitalTwinsDeleteOptions digitalTwinsDeleteOptions = null, CancellationToken cancellationToken = default)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            using var message = CreateDeleteRequest(id, digitalTwinsDeleteOptions);
            _pipeline.Send(message, cancellationToken);
            switch (message.Response.Status)
            {
            case 204:
                return(message.Response);

            default:
                throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
        public async Task <Response> DeleteAsync(string id, DigitalTwinsDeleteOptions digitalTwinsDeleteOptions = null, CancellationToken cancellationToken = default)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            using var message = CreateDeleteRequest(id, digitalTwinsDeleteOptions);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 204:
                return(message.Response);

            default:
                throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }