| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | | using Azure; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | | using Azure.Iot.Hub.Service.Models; |
| | 17 | |
|
| | 18 | | namespace Azure.Iot.Hub.Service |
| | 19 | | { |
| | 20 | | internal partial class ConfigurationRestClient |
| | 21 | | { |
| | 22 | | private Uri endpoint; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of ConfigurationRestClient. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <param name="apiVersion"> Api Version. </param> |
| | 32 | | /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception> |
| 0 | 33 | | public ConfigurationRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null, |
| | 34 | | { |
| 0 | 35 | | endpoint ??= new Uri("https://fully-qualified-iothubname.azure-devices.net"); |
| 0 | 36 | | if (apiVersion == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 39 | | } |
| | 40 | |
|
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | this.apiVersion = apiVersion; |
| 0 | 43 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 44 | | _pipeline = pipeline; |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | internal HttpMessage CreateGetRequest(string id) |
| | 48 | | { |
| 0 | 49 | | var message = _pipeline.CreateMessage(); |
| 0 | 50 | | var request = message.Request; |
| 0 | 51 | | request.Method = RequestMethod.Get; |
| 0 | 52 | | var uri = new RawRequestUriBuilder(); |
| 0 | 53 | | uri.Reset(endpoint); |
| 0 | 54 | | uri.AppendPath("/configurations/", false); |
| 0 | 55 | | uri.AppendPath(id, true); |
| 0 | 56 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 57 | | request.Uri = uri; |
| 0 | 58 | | return message; |
| | 59 | | } |
| | 60 | |
|
| | 61 | | /// <summary> Gets a configuration on the IoT Hub for automatic device/module management. </summary> |
| | 62 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 63 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 64 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception> |
| | 65 | | public async Task<Response<TwinConfiguration>> GetAsync(string id, CancellationToken cancellationToken = default |
| | 66 | | { |
| 0 | 67 | | if (id == null) |
| | 68 | | { |
| 0 | 69 | | throw new ArgumentNullException(nameof(id)); |
| | 70 | | } |
| | 71 | |
|
| 0 | 72 | | using var message = CreateGetRequest(id); |
| 0 | 73 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 74 | | switch (message.Response.Status) |
| | 75 | | { |
| | 76 | | case 200: |
| | 77 | | { |
| | 78 | | TwinConfiguration value = default; |
| 0 | 79 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 80 | | value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); |
| 0 | 81 | | return Response.FromValue(value, message.Response); |
| | 82 | | } |
| | 83 | | default: |
| 0 | 84 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 85 | | } |
| 0 | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> Gets a configuration on the IoT Hub for automatic device/module management. </summary> |
| | 89 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 90 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 91 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception> |
| | 92 | | public Response<TwinConfiguration> Get(string id, CancellationToken cancellationToken = default) |
| | 93 | | { |
| 0 | 94 | | if (id == null) |
| | 95 | | { |
| 0 | 96 | | throw new ArgumentNullException(nameof(id)); |
| | 97 | | } |
| | 98 | |
|
| 0 | 99 | | using var message = CreateGetRequest(id); |
| 0 | 100 | | _pipeline.Send(message, cancellationToken); |
| 0 | 101 | | switch (message.Response.Status) |
| | 102 | | { |
| | 103 | | case 200: |
| | 104 | | { |
| | 105 | | TwinConfiguration value = default; |
| 0 | 106 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 107 | | value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); |
| 0 | 108 | | return Response.FromValue(value, message.Response); |
| | 109 | | } |
| | 110 | | default: |
| 0 | 111 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 112 | | } |
| 0 | 113 | | } |
| | 114 | |
|
| | 115 | | internal HttpMessage CreateCreateOrUpdateRequest(string id, TwinConfiguration configuration, string ifMatch) |
| | 116 | | { |
| 0 | 117 | | var message = _pipeline.CreateMessage(); |
| 0 | 118 | | var request = message.Request; |
| 0 | 119 | | request.Method = RequestMethod.Put; |
| 0 | 120 | | var uri = new RawRequestUriBuilder(); |
| 0 | 121 | | uri.Reset(endpoint); |
| 0 | 122 | | uri.AppendPath("/configurations/", false); |
| 0 | 123 | | uri.AppendPath(id, true); |
| 0 | 124 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 125 | | request.Uri = uri; |
| 0 | 126 | | if (ifMatch != null) |
| | 127 | | { |
| 0 | 128 | | request.Headers.Add("If-Match", ifMatch); |
| | 129 | | } |
| 0 | 130 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 131 | | var content = new Utf8JsonRequestContent(); |
| 0 | 132 | | content.JsonWriter.WriteObjectValue(configuration); |
| 0 | 133 | | request.Content = content; |
| 0 | 134 | | return message; |
| | 135 | | } |
| | 136 | |
|
| | 137 | | /// <summary> Creates or updates a configuration on the IoT Hub for automatic device/module management. Configur |
| | 138 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 139 | | /// <param name="configuration"> The configuration to be created or updated. </param> |
| | 140 | | /// <param name="ifMatch"> The string representing a weak ETag for configuration, as per RFC7232. This should no |
| | 141 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 142 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="configuration"/> is null. |
| | 143 | | public async Task<Response<TwinConfiguration>> CreateOrUpdateAsync(string id, TwinConfiguration configuration, s |
| | 144 | | { |
| 0 | 145 | | if (id == null) |
| | 146 | | { |
| 0 | 147 | | throw new ArgumentNullException(nameof(id)); |
| | 148 | | } |
| 0 | 149 | | if (configuration == null) |
| | 150 | | { |
| 0 | 151 | | throw new ArgumentNullException(nameof(configuration)); |
| | 152 | | } |
| | 153 | |
|
| 0 | 154 | | using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); |
| 0 | 155 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 156 | | switch (message.Response.Status) |
| | 157 | | { |
| | 158 | | case 200: |
| | 159 | | case 201: |
| | 160 | | { |
| | 161 | | TwinConfiguration value = default; |
| 0 | 162 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 163 | | value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); |
| 0 | 164 | | return Response.FromValue(value, message.Response); |
| | 165 | | } |
| | 166 | | default: |
| 0 | 167 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 168 | | } |
| 0 | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> Creates or updates a configuration on the IoT Hub for automatic device/module management. Configur |
| | 172 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 173 | | /// <param name="configuration"> The configuration to be created or updated. </param> |
| | 174 | | /// <param name="ifMatch"> The string representing a weak ETag for configuration, as per RFC7232. This should no |
| | 175 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 176 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="configuration"/> is null. |
| | 177 | | public Response<TwinConfiguration> CreateOrUpdate(string id, TwinConfiguration configuration, string ifMatch = n |
| | 178 | | { |
| 0 | 179 | | if (id == null) |
| | 180 | | { |
| 0 | 181 | | throw new ArgumentNullException(nameof(id)); |
| | 182 | | } |
| 0 | 183 | | if (configuration == null) |
| | 184 | | { |
| 0 | 185 | | throw new ArgumentNullException(nameof(configuration)); |
| | 186 | | } |
| | 187 | |
|
| 0 | 188 | | using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); |
| 0 | 189 | | _pipeline.Send(message, cancellationToken); |
| 0 | 190 | | switch (message.Response.Status) |
| | 191 | | { |
| | 192 | | case 200: |
| | 193 | | case 201: |
| | 194 | | { |
| | 195 | | TwinConfiguration value = default; |
| 0 | 196 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 197 | | value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); |
| 0 | 198 | | return Response.FromValue(value, message.Response); |
| | 199 | | } |
| | 200 | | default: |
| 0 | 201 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 202 | | } |
| 0 | 203 | | } |
| | 204 | |
|
| | 205 | | internal HttpMessage CreateDeleteRequest(string id, string ifMatch) |
| | 206 | | { |
| 0 | 207 | | var message = _pipeline.CreateMessage(); |
| 0 | 208 | | var request = message.Request; |
| 0 | 209 | | request.Method = RequestMethod.Delete; |
| 0 | 210 | | var uri = new RawRequestUriBuilder(); |
| 0 | 211 | | uri.Reset(endpoint); |
| 0 | 212 | | uri.AppendPath("/configurations/", false); |
| 0 | 213 | | uri.AppendPath(id, true); |
| 0 | 214 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 215 | | request.Uri = uri; |
| 0 | 216 | | if (ifMatch != null) |
| | 217 | | { |
| 0 | 218 | | request.Headers.Add("If-Match", ifMatch); |
| | 219 | | } |
| 0 | 220 | | return message; |
| | 221 | | } |
| | 222 | |
|
| | 223 | | /// <summary> Deletes a configuration on the IoT Hub for automatic device/module management. </summary> |
| | 224 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 225 | | /// <param name="ifMatch"> The string representing a weak ETag for configuration, as per RFC7232. The delete ope |
| | 226 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 227 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception> |
| | 228 | | public async Task<Response> DeleteAsync(string id, string ifMatch = null, CancellationToken cancellationToken = |
| | 229 | | { |
| 0 | 230 | | if (id == null) |
| | 231 | | { |
| 0 | 232 | | throw new ArgumentNullException(nameof(id)); |
| | 233 | | } |
| | 234 | |
|
| 0 | 235 | | using var message = CreateDeleteRequest(id, ifMatch); |
| 0 | 236 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 237 | | switch (message.Response.Status) |
| | 238 | | { |
| | 239 | | case 204: |
| 0 | 240 | | return message.Response; |
| | 241 | | default: |
| 0 | 242 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 243 | | } |
| 0 | 244 | | } |
| | 245 | |
|
| | 246 | | /// <summary> Deletes a configuration on the IoT Hub for automatic device/module management. </summary> |
| | 247 | | /// <param name="id"> The unique identifier of the configuration. </param> |
| | 248 | | /// <param name="ifMatch"> The string representing a weak ETag for configuration, as per RFC7232. The delete ope |
| | 249 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 250 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception> |
| | 251 | | public Response Delete(string id, string ifMatch = null, CancellationToken cancellationToken = default) |
| | 252 | | { |
| 0 | 253 | | if (id == null) |
| | 254 | | { |
| 0 | 255 | | throw new ArgumentNullException(nameof(id)); |
| | 256 | | } |
| | 257 | |
|
| 0 | 258 | | using var message = CreateDeleteRequest(id, ifMatch); |
| 0 | 259 | | _pipeline.Send(message, cancellationToken); |
| 0 | 260 | | switch (message.Response.Status) |
| | 261 | | { |
| | 262 | | case 204: |
| 0 | 263 | | return message.Response; |
| | 264 | | default: |
| 0 | 265 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 266 | | } |
| 0 | 267 | | } |
| | 268 | |
|
| | 269 | | internal HttpMessage CreateGetConfigurationsRequest(int? top) |
| | 270 | | { |
| 0 | 271 | | var message = _pipeline.CreateMessage(); |
| 0 | 272 | | var request = message.Request; |
| 0 | 273 | | request.Method = RequestMethod.Get; |
| 0 | 274 | | var uri = new RawRequestUriBuilder(); |
| 0 | 275 | | uri.Reset(endpoint); |
| 0 | 276 | | uri.AppendPath("/configurations", false); |
| 0 | 277 | | if (top != null) |
| | 278 | | { |
| 0 | 279 | | uri.AppendQuery("top", top.Value, true); |
| | 280 | | } |
| 0 | 281 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 282 | | request.Uri = uri; |
| 0 | 283 | | return message; |
| | 284 | | } |
| | 285 | |
|
| | 286 | | /// <summary> Gets configurations on the IoT Hub for automatic device/module management. Pagination is not suppo |
| | 287 | | /// <param name="top"> The number of configurations to retrieve. Value will be overridden if greater than the ma |
| | 288 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 289 | | public async Task<Response<IReadOnlyList<TwinConfiguration>>> GetConfigurationsAsync(int? top = null, Cancellati |
| | 290 | | { |
| 0 | 291 | | using var message = CreateGetConfigurationsRequest(top); |
| 0 | 292 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 293 | | switch (message.Response.Status) |
| | 294 | | { |
| | 295 | | case 200: |
| | 296 | | { |
| | 297 | | IReadOnlyList<TwinConfiguration> value = default; |
| 0 | 298 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 299 | | List<TwinConfiguration> array = new List<TwinConfiguration>(); |
| 0 | 300 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 301 | | { |
| 0 | 302 | | array.Add(TwinConfiguration.DeserializeTwinConfiguration(item)); |
| | 303 | | } |
| 0 | 304 | | value = array; |
| 0 | 305 | | return Response.FromValue(value, message.Response); |
| | 306 | | } |
| | 307 | | default: |
| 0 | 308 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 309 | | } |
| 0 | 310 | | } |
| | 311 | |
|
| | 312 | | /// <summary> Gets configurations on the IoT Hub for automatic device/module management. Pagination is not suppo |
| | 313 | | /// <param name="top"> The number of configurations to retrieve. Value will be overridden if greater than the ma |
| | 314 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 315 | | public Response<IReadOnlyList<TwinConfiguration>> GetConfigurations(int? top = null, CancellationToken cancellat |
| | 316 | | { |
| 0 | 317 | | using var message = CreateGetConfigurationsRequest(top); |
| 0 | 318 | | _pipeline.Send(message, cancellationToken); |
| 0 | 319 | | switch (message.Response.Status) |
| | 320 | | { |
| | 321 | | case 200: |
| | 322 | | { |
| | 323 | | IReadOnlyList<TwinConfiguration> value = default; |
| 0 | 324 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 325 | | List<TwinConfiguration> array = new List<TwinConfiguration>(); |
| 0 | 326 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 327 | | { |
| 0 | 328 | | array.Add(TwinConfiguration.DeserializeTwinConfiguration(item)); |
| | 329 | | } |
| 0 | 330 | | value = array; |
| 0 | 331 | | return Response.FromValue(value, message.Response); |
| | 332 | | } |
| | 333 | | default: |
| 0 | 334 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 335 | | } |
| 0 | 336 | | } |
| | 337 | |
|
| | 338 | | internal HttpMessage CreateTestQueriesRequest(ConfigurationQueriesTestInput input) |
| | 339 | | { |
| 0 | 340 | | var message = _pipeline.CreateMessage(); |
| 0 | 341 | | var request = message.Request; |
| 0 | 342 | | request.Method = RequestMethod.Post; |
| 0 | 343 | | var uri = new RawRequestUriBuilder(); |
| 0 | 344 | | uri.Reset(endpoint); |
| 0 | 345 | | uri.AppendPath("/configurations/testQueries", false); |
| 0 | 346 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 347 | | request.Uri = uri; |
| 0 | 348 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 349 | | var content = new Utf8JsonRequestContent(); |
| 0 | 350 | | content.JsonWriter.WriteObjectValue(input); |
| 0 | 351 | | request.Content = content; |
| 0 | 352 | | return message; |
| | 353 | | } |
| | 354 | |
|
| | 355 | | /// <summary> Validates target condition and custom metric queries for a configuration on the IoT Hub. </summary |
| | 356 | | /// <param name="input"> The configuration for target condition and custom metric queries. </param> |
| | 357 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 358 | | /// <exception cref="ArgumentNullException"> <paramref name="input"/> is null. </exception> |
| | 359 | | public async Task<Response<ConfigurationQueriesTestResponse>> TestQueriesAsync(ConfigurationQueriesTestInput inp |
| | 360 | | { |
| 0 | 361 | | if (input == null) |
| | 362 | | { |
| 0 | 363 | | throw new ArgumentNullException(nameof(input)); |
| | 364 | | } |
| | 365 | |
|
| 0 | 366 | | using var message = CreateTestQueriesRequest(input); |
| 0 | 367 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 368 | | switch (message.Response.Status) |
| | 369 | | { |
| | 370 | | case 200: |
| | 371 | | { |
| | 372 | | ConfigurationQueriesTestResponse value = default; |
| 0 | 373 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 374 | | value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.Ro |
| 0 | 375 | | return Response.FromValue(value, message.Response); |
| | 376 | | } |
| | 377 | | default: |
| 0 | 378 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 379 | | } |
| 0 | 380 | | } |
| | 381 | |
|
| | 382 | | /// <summary> Validates target condition and custom metric queries for a configuration on the IoT Hub. </summary |
| | 383 | | /// <param name="input"> The configuration for target condition and custom metric queries. </param> |
| | 384 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 385 | | /// <exception cref="ArgumentNullException"> <paramref name="input"/> is null. </exception> |
| | 386 | | public Response<ConfigurationQueriesTestResponse> TestQueries(ConfigurationQueriesTestInput input, CancellationT |
| | 387 | | { |
| 0 | 388 | | if (input == null) |
| | 389 | | { |
| 0 | 390 | | throw new ArgumentNullException(nameof(input)); |
| | 391 | | } |
| | 392 | |
|
| 0 | 393 | | using var message = CreateTestQueriesRequest(input); |
| 0 | 394 | | _pipeline.Send(message, cancellationToken); |
| 0 | 395 | | switch (message.Response.Status) |
| | 396 | | { |
| | 397 | | case 200: |
| | 398 | | { |
| | 399 | | ConfigurationQueriesTestResponse value = default; |
| 0 | 400 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 401 | | value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.Ro |
| 0 | 402 | | return Response.FromValue(value, message.Response); |
| | 403 | | } |
| | 404 | | default: |
| 0 | 405 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 406 | | } |
| 0 | 407 | | } |
| | 408 | |
|
| | 409 | | internal HttpMessage CreateApplyOnEdgeDeviceRequest(string id, ConfigurationContent content) |
| | 410 | | { |
| 0 | 411 | | var message = _pipeline.CreateMessage(); |
| 0 | 412 | | var request = message.Request; |
| 0 | 413 | | request.Method = RequestMethod.Post; |
| 0 | 414 | | var uri = new RawRequestUriBuilder(); |
| 0 | 415 | | uri.Reset(endpoint); |
| 0 | 416 | | uri.AppendPath("/devices/", false); |
| 0 | 417 | | uri.AppendPath(id, true); |
| 0 | 418 | | uri.AppendPath("/applyConfigurationContent", false); |
| 0 | 419 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 420 | | request.Uri = uri; |
| 0 | 421 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 422 | | var content0 = new Utf8JsonRequestContent(); |
| 0 | 423 | | content0.JsonWriter.WriteObjectValue(content); |
| 0 | 424 | | request.Content = content0; |
| 0 | 425 | | return message; |
| | 426 | | } |
| | 427 | |
|
| | 428 | | /// <summary> Applies the configuration content to an edge device. </summary> |
| | 429 | | /// <param name="id"> The unique identifier of the edge device. </param> |
| | 430 | | /// <param name="content"> The configuration content. </param> |
| | 431 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 432 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="content"/> is null. </exce |
| | 433 | | public async Task<Response> ApplyOnEdgeDeviceAsync(string id, ConfigurationContent content, CancellationToken ca |
| | 434 | | { |
| 0 | 435 | | if (id == null) |
| | 436 | | { |
| 0 | 437 | | throw new ArgumentNullException(nameof(id)); |
| | 438 | | } |
| 0 | 439 | | if (content == null) |
| | 440 | | { |
| 0 | 441 | | throw new ArgumentNullException(nameof(content)); |
| | 442 | | } |
| | 443 | |
|
| 0 | 444 | | using var message = CreateApplyOnEdgeDeviceRequest(id, content); |
| 0 | 445 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 446 | | switch (message.Response.Status) |
| | 447 | | { |
| | 448 | | case 204: |
| 0 | 449 | | return message.Response; |
| | 450 | | default: |
| 0 | 451 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 452 | | } |
| 0 | 453 | | } |
| | 454 | |
|
| | 455 | | /// <summary> Applies the configuration content to an edge device. </summary> |
| | 456 | | /// <param name="id"> The unique identifier of the edge device. </param> |
| | 457 | | /// <param name="content"> The configuration content. </param> |
| | 458 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 459 | | /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="content"/> is null. </exce |
| | 460 | | public Response ApplyOnEdgeDevice(string id, ConfigurationContent content, CancellationToken cancellationToken = |
| | 461 | | { |
| 0 | 462 | | if (id == null) |
| | 463 | | { |
| 0 | 464 | | throw new ArgumentNullException(nameof(id)); |
| | 465 | | } |
| 0 | 466 | | if (content == null) |
| | 467 | | { |
| 0 | 468 | | throw new ArgumentNullException(nameof(content)); |
| | 469 | | } |
| | 470 | |
|
| 0 | 471 | | using var message = CreateApplyOnEdgeDeviceRequest(id, content); |
| 0 | 472 | | _pipeline.Send(message, cancellationToken); |
| 0 | 473 | | switch (message.Response.Status) |
| | 474 | | { |
| | 475 | | case 204: |
| 0 | 476 | | return message.Response; |
| | 477 | | default: |
| 0 | 478 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 479 | | } |
| 0 | 480 | | } |
| | 481 | | } |
| | 482 | | } |