public async Task <DeviceTemplate> SetAsync(DeviceTemplate body, string device_template_id, CancellationToken cancellationToken)
        {
            if (device_template_id == null)
            {
                throw new ArgumentNullException("device_template_id");
            }

            var urlBuilder_ = new StringBuilder();

            urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/deviceTemplates/{device_template_id}");
            urlBuilder_.Replace("{device_template_id}", Uri.EscapeDataString(ConvertToString(device_template_id, CultureInfo.InvariantCulture)));

            var client_ = _httpClient;

            using (var request_ = new HttpRequestMessage()) {
                var content_ = new StringContent(JsonSerializer.Serialize(body, new JsonSerializerOptions {
                    IgnoreNullValues = true
                }));
                content_.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
                request_.Content             = content_;
                request_.Method = new HttpMethod("PUT");
                request_.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));

                PrepareRequest(client_, request_, urlBuilder_);
                var url_ = urlBuilder_.ToString();
                request_.RequestUri = new Uri(url_, UriKind.RelativeOrAbsolute);
                PrepareRequest(client_, request_, url_);

                var response_ = await client_.SendAsync(request_, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

                try {
                    var headers_ = Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
                    if (response_.Content != null && response_.Content.Headers != null)
                    {
                        foreach (var item_ in response_.Content.Headers)
                        {
                            headers_[item_.Key] = item_.Value;
                        }
                    }

                    ProcessResponse(client_, response_);

                    var status_ = ((int)response_.StatusCode).ToString();
                    if (status_ == "200")
                    {
                        var objectResponse_ = await ReadObjectResponseAsync <DeviceTemplate>(response_, headers_).ConfigureAwait(false);

                        return(objectResponse_.Object);
                    }
                    else
                    if (status_ != "200" && status_ != "204")
                    {
                        var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                        throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
                    }

                    return(default(DeviceTemplate));
                }
                finally {
                    if (response_ != null)
                    {
                        response_.Dispose();
                    }
                }
            }
        }
 public Task <DeviceTemplate> SetAsync(DeviceTemplate body, string device_template_id)
 {
     return(SetAsync(body, device_template_id, CancellationToken.None));
 }