| | 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.ResourceManager.DigitalTwins.Models; |
| | 17 | |
|
| | 18 | | namespace Azure.ResourceManager.DigitalTwins |
| | 19 | | { |
| | 20 | | internal partial class DigitalTwinsRestOperations |
| | 21 | | { |
| | 22 | | private string subscriptionId; |
| | 23 | | private Uri endpoint; |
| | 24 | | private string apiVersion; |
| | 25 | | private ClientDiagnostics _clientDiagnostics; |
| | 26 | | private HttpPipeline _pipeline; |
| | 27 | |
|
| | 28 | | /// <summary> Initializes a new instance of DigitalTwinsRestOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> The subscription identifier. </param> |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| | 33 | | /// <param name="apiVersion"> Api Version. </param> |
| | 34 | | /// <exception cref="ArgumentNullException"> <paramref name="subscriptionId"/> or <paramref name="apiVersion"/> |
| 20 | 35 | | public DigitalTwinsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 36 | | { |
| 20 | 37 | | if (subscriptionId == null) |
| | 38 | | { |
| 0 | 39 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 40 | | } |
| 20 | 41 | | endpoint ??= new Uri("https://management.azure.com"); |
| 20 | 42 | | if (apiVersion == null) |
| | 43 | | { |
| 0 | 44 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 45 | | } |
| | 46 | |
|
| 20 | 47 | | this.subscriptionId = subscriptionId; |
| 20 | 48 | | this.endpoint = endpoint; |
| 20 | 49 | | this.apiVersion = apiVersion; |
| 20 | 50 | | _clientDiagnostics = clientDiagnostics; |
| 20 | 51 | | _pipeline = pipeline; |
| 20 | 52 | | } |
| | 53 | |
|
| | 54 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string resourceName) |
| | 55 | | { |
| 4 | 56 | | var message = _pipeline.CreateMessage(); |
| 4 | 57 | | var request = message.Request; |
| 4 | 58 | | request.Method = RequestMethod.Get; |
| 4 | 59 | | var uri = new RawRequestUriBuilder(); |
| 4 | 60 | | uri.Reset(endpoint); |
| 4 | 61 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 62 | | uri.AppendPath(subscriptionId, true); |
| 4 | 63 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 64 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 65 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false); |
| 4 | 66 | | uri.AppendPath(resourceName, true); |
| 4 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 68 | | request.Uri = uri; |
| 4 | 69 | | return message; |
| | 70 | | } |
| | 71 | |
|
| | 72 | | /// <summary> Get DigitalTwinsInstances resource. </summary> |
| | 73 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 74 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 77 | | public async Task<Response<DigitalTwinsDescription>> GetAsync(string resourceGroupName, string resourceName, Can |
| | 78 | | { |
| 2 | 79 | | if (resourceGroupName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 82 | | } |
| 2 | 83 | | if (resourceName == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 86 | | } |
| | 87 | |
|
| 2 | 88 | | using var message = CreateGetRequest(resourceGroupName, resourceName); |
| 2 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | { |
| | 94 | | DigitalTwinsDescription value = default; |
| 2 | 95 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 96 | | value = DigitalTwinsDescription.DeserializeDigitalTwinsDescription(document.RootElement); |
| 2 | 97 | | return Response.FromValue(value, message.Response); |
| | 98 | | } |
| | 99 | | default: |
| 0 | 100 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 101 | | } |
| 2 | 102 | | } |
| | 103 | |
|
| | 104 | | /// <summary> Get DigitalTwinsInstances resource. </summary> |
| | 105 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 106 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 107 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 108 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 109 | | public Response<DigitalTwinsDescription> Get(string resourceGroupName, string resourceName, CancellationToken ca |
| | 110 | | { |
| 2 | 111 | | if (resourceGroupName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 114 | | } |
| 2 | 115 | | if (resourceName == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 118 | | } |
| | 119 | |
|
| 2 | 120 | | using var message = CreateGetRequest(resourceGroupName, resourceName); |
| 2 | 121 | | _pipeline.Send(message, cancellationToken); |
| 2 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | { |
| | 126 | | DigitalTwinsDescription value = default; |
| 2 | 127 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 128 | | value = DigitalTwinsDescription.DeserializeDigitalTwinsDescription(document.RootElement); |
| 2 | 129 | | return Response.FromValue(value, message.Response); |
| | 130 | | } |
| | 131 | | default: |
| 0 | 132 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 133 | | } |
| 2 | 134 | | } |
| | 135 | |
|
| | 136 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string resourceName, DigitalTwinsDesc |
| | 137 | | { |
| 8 | 138 | | var message = _pipeline.CreateMessage(); |
| 8 | 139 | | var request = message.Request; |
| 8 | 140 | | request.Method = RequestMethod.Put; |
| 8 | 141 | | var uri = new RawRequestUriBuilder(); |
| 8 | 142 | | uri.Reset(endpoint); |
| 8 | 143 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 144 | | uri.AppendPath(subscriptionId, true); |
| 8 | 145 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 146 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 147 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false); |
| 8 | 148 | | uri.AppendPath(resourceName, true); |
| 8 | 149 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 150 | | request.Uri = uri; |
| 8 | 151 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 152 | | var content = new Utf8JsonRequestContent(); |
| 8 | 153 | | content.JsonWriter.WriteObjectValue(digitalTwinsCreate); |
| 8 | 154 | | request.Content = content; |
| 8 | 155 | | return message; |
| | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is |
| | 159 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 160 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 161 | | /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param> |
| | 162 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 163 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName" |
| | 164 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string resourceName, DigitalTwinsDescr |
| | 165 | | { |
| 2 | 166 | | if (resourceGroupName == null) |
| | 167 | | { |
| 0 | 168 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 169 | | } |
| 2 | 170 | | if (resourceName == null) |
| | 171 | | { |
| 0 | 172 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 173 | | } |
| 2 | 174 | | if (digitalTwinsCreate == null) |
| | 175 | | { |
| 0 | 176 | | throw new ArgumentNullException(nameof(digitalTwinsCreate)); |
| | 177 | | } |
| | 178 | |
|
| 2 | 179 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, digitalTwinsCreate); |
| 2 | 180 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 181 | | switch (message.Response.Status) |
| | 182 | | { |
| | 183 | | case 200: |
| | 184 | | case 201: |
| 2 | 185 | | return message.Response; |
| | 186 | | default: |
| 0 | 187 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 188 | | } |
| 2 | 189 | | } |
| | 190 | |
|
| | 191 | | /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is |
| | 192 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 193 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 194 | | /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param> |
| | 195 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 196 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName" |
| | 197 | | public Response CreateOrUpdate(string resourceGroupName, string resourceName, DigitalTwinsDescription digitalTwi |
| | 198 | | { |
| 2 | 199 | | if (resourceGroupName == null) |
| | 200 | | { |
| 0 | 201 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 202 | | } |
| 2 | 203 | | if (resourceName == null) |
| | 204 | | { |
| 0 | 205 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 206 | | } |
| 2 | 207 | | if (digitalTwinsCreate == null) |
| | 208 | | { |
| 0 | 209 | | throw new ArgumentNullException(nameof(digitalTwinsCreate)); |
| | 210 | | } |
| | 211 | |
|
| 2 | 212 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, digitalTwinsCreate); |
| 2 | 213 | | _pipeline.Send(message, cancellationToken); |
| 2 | 214 | | switch (message.Response.Status) |
| | 215 | | { |
| | 216 | | case 200: |
| | 217 | | case 201: |
| 2 | 218 | | return message.Response; |
| | 219 | | default: |
| 0 | 220 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 221 | | } |
| 2 | 222 | | } |
| | 223 | |
|
| | 224 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string resourceName, IDictionary<string, stri |
| | 225 | | { |
| 0 | 226 | | var message = _pipeline.CreateMessage(); |
| 0 | 227 | | var request = message.Request; |
| 0 | 228 | | request.Method = RequestMethod.Patch; |
| 0 | 229 | | var uri = new RawRequestUriBuilder(); |
| 0 | 230 | | uri.Reset(endpoint); |
| 0 | 231 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 232 | | uri.AppendPath(subscriptionId, true); |
| 0 | 233 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 234 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 235 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false); |
| 0 | 236 | | uri.AppendPath(resourceName, true); |
| 0 | 237 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 238 | | request.Uri = uri; |
| 0 | 239 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 240 | | DigitalTwinsPatchDescription digitalTwinsPatchDescription = new DigitalTwinsPatchDescription(); |
| 0 | 241 | | foreach (var value in tags) |
| | 242 | | { |
| 0 | 243 | | digitalTwinsPatchDescription.Tags.Add(value); |
| | 244 | | } |
| 0 | 245 | | var model = digitalTwinsPatchDescription; |
| 0 | 246 | | var content = new Utf8JsonRequestContent(); |
| 0 | 247 | | content.JsonWriter.WriteObjectValue(model); |
| 0 | 248 | | request.Content = content; |
| 0 | 249 | | return message; |
| | 250 | | } |
| | 251 | |
|
| | 252 | | /// <summary> Update metadata of DigitalTwinsInstance. </summary> |
| | 253 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 254 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 255 | | /// <param name="tags"> Instance tags. </param> |
| | 256 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 257 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 258 | | public async Task<Response> UpdateAsync(string resourceGroupName, string resourceName, IDictionary<string, strin |
| | 259 | | { |
| 0 | 260 | | if (resourceGroupName == null) |
| | 261 | | { |
| 0 | 262 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 263 | | } |
| 0 | 264 | | if (resourceName == null) |
| | 265 | | { |
| 0 | 266 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 267 | | } |
| | 268 | |
|
| 0 | 269 | | using var message = CreateUpdateRequest(resourceGroupName, resourceName, tags); |
| 0 | 270 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 271 | | switch (message.Response.Status) |
| | 272 | | { |
| | 273 | | case 200: |
| | 274 | | case 201: |
| 0 | 275 | | return message.Response; |
| | 276 | | default: |
| 0 | 277 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 278 | | } |
| 0 | 279 | | } |
| | 280 | |
|
| | 281 | | /// <summary> Update metadata of DigitalTwinsInstance. </summary> |
| | 282 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 283 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 284 | | /// <param name="tags"> Instance tags. </param> |
| | 285 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 286 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 287 | | public Response Update(string resourceGroupName, string resourceName, IDictionary<string, string> tags = null, C |
| | 288 | | { |
| 0 | 289 | | if (resourceGroupName == null) |
| | 290 | | { |
| 0 | 291 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 292 | | } |
| 0 | 293 | | if (resourceName == null) |
| | 294 | | { |
| 0 | 295 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 296 | | } |
| | 297 | |
|
| 0 | 298 | | using var message = CreateUpdateRequest(resourceGroupName, resourceName, tags); |
| 0 | 299 | | _pipeline.Send(message, cancellationToken); |
| 0 | 300 | | switch (message.Response.Status) |
| | 301 | | { |
| | 302 | | case 200: |
| | 303 | | case 201: |
| 0 | 304 | | return message.Response; |
| | 305 | | default: |
| 0 | 306 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 307 | | } |
| 0 | 308 | | } |
| | 309 | |
|
| | 310 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string resourceName) |
| | 311 | | { |
| 8 | 312 | | var message = _pipeline.CreateMessage(); |
| 8 | 313 | | var request = message.Request; |
| 8 | 314 | | request.Method = RequestMethod.Delete; |
| 8 | 315 | | var uri = new RawRequestUriBuilder(); |
| 8 | 316 | | uri.Reset(endpoint); |
| 8 | 317 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 318 | | uri.AppendPath(subscriptionId, true); |
| 8 | 319 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 320 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 321 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false); |
| 8 | 322 | | uri.AppendPath(resourceName, true); |
| 8 | 323 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 324 | | request.Uri = uri; |
| 8 | 325 | | return message; |
| | 326 | | } |
| | 327 | |
|
| | 328 | | /// <summary> Delete a DigitalTwinsInstance. </summary> |
| | 329 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 330 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 331 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 332 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 333 | | public async Task<Response> DeleteAsync(string resourceGroupName, string resourceName, CancellationToken cancell |
| | 334 | | { |
| 2 | 335 | | if (resourceGroupName == null) |
| | 336 | | { |
| 0 | 337 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 338 | | } |
| 2 | 339 | | if (resourceName == null) |
| | 340 | | { |
| 0 | 341 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 342 | | } |
| | 343 | |
|
| 2 | 344 | | using var message = CreateDeleteRequest(resourceGroupName, resourceName); |
| 2 | 345 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 346 | | switch (message.Response.Status) |
| | 347 | | { |
| | 348 | | case 200: |
| | 349 | | case 202: |
| | 350 | | case 204: |
| 2 | 351 | | return message.Response; |
| | 352 | | default: |
| 0 | 353 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 354 | | } |
| 2 | 355 | | } |
| | 356 | |
|
| | 357 | | /// <summary> Delete a DigitalTwinsInstance. </summary> |
| | 358 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 359 | | /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param> |
| | 360 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 361 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam |
| | 362 | | public Response Delete(string resourceGroupName, string resourceName, CancellationToken cancellationToken = defa |
| | 363 | | { |
| 2 | 364 | | if (resourceGroupName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 367 | | } |
| 2 | 368 | | if (resourceName == null) |
| | 369 | | { |
| 0 | 370 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 371 | | } |
| | 372 | |
|
| 2 | 373 | | using var message = CreateDeleteRequest(resourceGroupName, resourceName); |
| 2 | 374 | | _pipeline.Send(message, cancellationToken); |
| 2 | 375 | | switch (message.Response.Status) |
| | 376 | | { |
| | 377 | | case 200: |
| | 378 | | case 202: |
| | 379 | | case 204: |
| 2 | 380 | | return message.Response; |
| | 381 | | default: |
| 0 | 382 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 383 | | } |
| 2 | 384 | | } |
| | 385 | |
|
| | 386 | | internal HttpMessage CreateListRequest() |
| | 387 | | { |
| 4 | 388 | | var message = _pipeline.CreateMessage(); |
| 4 | 389 | | var request = message.Request; |
| 4 | 390 | | request.Method = RequestMethod.Get; |
| 4 | 391 | | var uri = new RawRequestUriBuilder(); |
| 4 | 392 | | uri.Reset(endpoint); |
| 4 | 393 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 394 | | uri.AppendPath(subscriptionId, true); |
| 4 | 395 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances", false); |
| 4 | 396 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 397 | | request.Uri = uri; |
| 4 | 398 | | return message; |
| | 399 | | } |
| | 400 | |
|
| | 401 | | /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary> |
| | 402 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 403 | | public async Task<Response<DigitalTwinsDescriptionListResult>> ListAsync(CancellationToken cancellationToken = d |
| | 404 | | { |
| 2 | 405 | | using var message = CreateListRequest(); |
| 2 | 406 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 407 | | switch (message.Response.Status) |
| | 408 | | { |
| | 409 | | case 200: |
| | 410 | | { |
| | 411 | | DigitalTwinsDescriptionListResult value = default; |
| 2 | 412 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 413 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 2 | 414 | | return Response.FromValue(value, message.Response); |
| | 415 | | } |
| | 416 | | default: |
| 0 | 417 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 418 | | } |
| 2 | 419 | | } |
| | 420 | |
|
| | 421 | | /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary> |
| | 422 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 423 | | public Response<DigitalTwinsDescriptionListResult> List(CancellationToken cancellationToken = default) |
| | 424 | | { |
| 2 | 425 | | using var message = CreateListRequest(); |
| 2 | 426 | | _pipeline.Send(message, cancellationToken); |
| 2 | 427 | | switch (message.Response.Status) |
| | 428 | | { |
| | 429 | | case 200: |
| | 430 | | { |
| | 431 | | DigitalTwinsDescriptionListResult value = default; |
| 2 | 432 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 433 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 2 | 434 | | return Response.FromValue(value, message.Response); |
| | 435 | | } |
| | 436 | | default: |
| 0 | 437 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 438 | | } |
| 2 | 439 | | } |
| | 440 | |
|
| | 441 | | internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) |
| | 442 | | { |
| 0 | 443 | | var message = _pipeline.CreateMessage(); |
| 0 | 444 | | var request = message.Request; |
| 0 | 445 | | request.Method = RequestMethod.Get; |
| 0 | 446 | | var uri = new RawRequestUriBuilder(); |
| 0 | 447 | | uri.Reset(endpoint); |
| 0 | 448 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 449 | | uri.AppendPath(subscriptionId, true); |
| 0 | 450 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 451 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 452 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances", false); |
| 0 | 453 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 454 | | request.Uri = uri; |
| 0 | 455 | | return message; |
| | 456 | | } |
| | 457 | |
|
| | 458 | | /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary> |
| | 459 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 460 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 461 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception> |
| | 462 | | public async Task<Response<DigitalTwinsDescriptionListResult>> ListByResourceGroupAsync(string resourceGroupName |
| | 463 | | { |
| 0 | 464 | | if (resourceGroupName == null) |
| | 465 | | { |
| 0 | 466 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 467 | | } |
| | 468 | |
|
| 0 | 469 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 0 | 470 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 471 | | switch (message.Response.Status) |
| | 472 | | { |
| | 473 | | case 200: |
| | 474 | | { |
| | 475 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 476 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 477 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 478 | | return Response.FromValue(value, message.Response); |
| | 479 | | } |
| | 480 | | default: |
| 0 | 481 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 482 | | } |
| 0 | 483 | | } |
| | 484 | |
|
| | 485 | | /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary> |
| | 486 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 487 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 488 | | /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception> |
| | 489 | | public Response<DigitalTwinsDescriptionListResult> ListByResourceGroup(string resourceGroupName, CancellationTok |
| | 490 | | { |
| 0 | 491 | | if (resourceGroupName == null) |
| | 492 | | { |
| 0 | 493 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 494 | | } |
| | 495 | |
|
| 0 | 496 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 0 | 497 | | _pipeline.Send(message, cancellationToken); |
| 0 | 498 | | switch (message.Response.Status) |
| | 499 | | { |
| | 500 | | case 200: |
| | 501 | | { |
| | 502 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 503 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 504 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 505 | | return Response.FromValue(value, message.Response); |
| | 506 | | } |
| | 507 | | default: |
| 0 | 508 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 509 | | } |
| 0 | 510 | | } |
| | 511 | |
|
| | 512 | | internal HttpMessage CreateCheckNameAvailabilityRequest(string location, string name) |
| | 513 | | { |
| 4 | 514 | | var message = _pipeline.CreateMessage(); |
| 4 | 515 | | var request = message.Request; |
| 4 | 516 | | request.Method = RequestMethod.Post; |
| 4 | 517 | | var uri = new RawRequestUriBuilder(); |
| 4 | 518 | | uri.Reset(endpoint); |
| 4 | 519 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 520 | | uri.AppendPath(subscriptionId, true); |
| 4 | 521 | | uri.AppendPath("/providers/Microsoft.DigitalTwins/locations/", false); |
| 4 | 522 | | uri.AppendPath(location, true); |
| 4 | 523 | | uri.AppendPath("/checkNameAvailability", false); |
| 4 | 524 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 525 | | request.Uri = uri; |
| 4 | 526 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 527 | | var model = new CheckNameRequest(name); |
| 4 | 528 | | var content = new Utf8JsonRequestContent(); |
| 4 | 529 | | content.JsonWriter.WriteObjectValue(model); |
| 4 | 530 | | request.Content = content; |
| 4 | 531 | | return message; |
| | 532 | | } |
| | 533 | |
|
| | 534 | | /// <summary> Check if a DigitalTwinsInstance name is available. </summary> |
| | 535 | | /// <param name="location"> Location of DigitalTwinsInstance. </param> |
| | 536 | | /// <param name="name"> Resource name. </param> |
| | 537 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 538 | | /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="name"/> is null. </e |
| | 539 | | public async Task<Response<CheckNameResult>> CheckNameAvailabilityAsync(string location, string name, Cancellati |
| | 540 | | { |
| 2 | 541 | | if (location == null) |
| | 542 | | { |
| 0 | 543 | | throw new ArgumentNullException(nameof(location)); |
| | 544 | | } |
| 2 | 545 | | if (name == null) |
| | 546 | | { |
| 0 | 547 | | throw new ArgumentNullException(nameof(name)); |
| | 548 | | } |
| | 549 | |
|
| 2 | 550 | | using var message = CreateCheckNameAvailabilityRequest(location, name); |
| 2 | 551 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 552 | | switch (message.Response.Status) |
| | 553 | | { |
| | 554 | | case 200: |
| | 555 | | { |
| | 556 | | CheckNameResult value = default; |
| 2 | 557 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 558 | | value = CheckNameResult.DeserializeCheckNameResult(document.RootElement); |
| 2 | 559 | | return Response.FromValue(value, message.Response); |
| | 560 | | } |
| | 561 | | default: |
| 0 | 562 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 563 | | } |
| 2 | 564 | | } |
| | 565 | |
|
| | 566 | | /// <summary> Check if a DigitalTwinsInstance name is available. </summary> |
| | 567 | | /// <param name="location"> Location of DigitalTwinsInstance. </param> |
| | 568 | | /// <param name="name"> Resource name. </param> |
| | 569 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 570 | | /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="name"/> is null. </e |
| | 571 | | public Response<CheckNameResult> CheckNameAvailability(string location, string name, CancellationToken cancellat |
| | 572 | | { |
| 2 | 573 | | if (location == null) |
| | 574 | | { |
| 0 | 575 | | throw new ArgumentNullException(nameof(location)); |
| | 576 | | } |
| 2 | 577 | | if (name == null) |
| | 578 | | { |
| 0 | 579 | | throw new ArgumentNullException(nameof(name)); |
| | 580 | | } |
| | 581 | |
|
| 2 | 582 | | using var message = CreateCheckNameAvailabilityRequest(location, name); |
| 2 | 583 | | _pipeline.Send(message, cancellationToken); |
| 2 | 584 | | switch (message.Response.Status) |
| | 585 | | { |
| | 586 | | case 200: |
| | 587 | | { |
| | 588 | | CheckNameResult value = default; |
| 2 | 589 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 590 | | value = CheckNameResult.DeserializeCheckNameResult(document.RootElement); |
| 2 | 591 | | return Response.FromValue(value, message.Response); |
| | 592 | | } |
| | 593 | | default: |
| 0 | 594 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 595 | | } |
| 2 | 596 | | } |
| | 597 | |
|
| | 598 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 599 | | { |
| 0 | 600 | | var message = _pipeline.CreateMessage(); |
| 0 | 601 | | var request = message.Request; |
| 0 | 602 | | request.Method = RequestMethod.Get; |
| 0 | 603 | | var uri = new RawRequestUriBuilder(); |
| 0 | 604 | | uri.Reset(endpoint); |
| 0 | 605 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 606 | | request.Uri = uri; |
| 0 | 607 | | return message; |
| | 608 | | } |
| | 609 | |
|
| | 610 | | /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary> |
| | 611 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 612 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 613 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 614 | | public async Task<Response<DigitalTwinsDescriptionListResult>> ListNextPageAsync(string nextLink, CancellationTo |
| | 615 | | { |
| 0 | 616 | | if (nextLink == null) |
| | 617 | | { |
| 0 | 618 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 619 | | } |
| | 620 | |
|
| 0 | 621 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 622 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 623 | | switch (message.Response.Status) |
| | 624 | | { |
| | 625 | | case 200: |
| | 626 | | { |
| | 627 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 628 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 629 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 630 | | return Response.FromValue(value, message.Response); |
| | 631 | | } |
| | 632 | | default: |
| 0 | 633 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 634 | | } |
| 0 | 635 | | } |
| | 636 | |
|
| | 637 | | /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary> |
| | 638 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 639 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 640 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 641 | | public Response<DigitalTwinsDescriptionListResult> ListNextPage(string nextLink, CancellationToken cancellationT |
| | 642 | | { |
| 0 | 643 | | if (nextLink == null) |
| | 644 | | { |
| 0 | 645 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 646 | | } |
| | 647 | |
|
| 0 | 648 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 649 | | _pipeline.Send(message, cancellationToken); |
| 0 | 650 | | switch (message.Response.Status) |
| | 651 | | { |
| | 652 | | case 200: |
| | 653 | | { |
| | 654 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 655 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 656 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 657 | | return Response.FromValue(value, message.Response); |
| | 658 | | } |
| | 659 | | default: |
| 0 | 660 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 661 | | } |
| 0 | 662 | | } |
| | 663 | |
|
| | 664 | | internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName) |
| | 665 | | { |
| 0 | 666 | | var message = _pipeline.CreateMessage(); |
| 0 | 667 | | var request = message.Request; |
| 0 | 668 | | request.Method = RequestMethod.Get; |
| 0 | 669 | | var uri = new RawRequestUriBuilder(); |
| 0 | 670 | | uri.Reset(endpoint); |
| 0 | 671 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 672 | | request.Uri = uri; |
| 0 | 673 | | return message; |
| | 674 | | } |
| | 675 | |
|
| | 676 | | /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary> |
| | 677 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 678 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 679 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 680 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> or <paramref name="resourceGroupName"/> |
| | 681 | | public async Task<Response<DigitalTwinsDescriptionListResult>> ListByResourceGroupNextPageAsync(string nextLink, |
| | 682 | | { |
| 0 | 683 | | if (nextLink == null) |
| | 684 | | { |
| 0 | 685 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 686 | | } |
| 0 | 687 | | if (resourceGroupName == null) |
| | 688 | | { |
| 0 | 689 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 690 | | } |
| | 691 | |
|
| 0 | 692 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 693 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 694 | | switch (message.Response.Status) |
| | 695 | | { |
| | 696 | | case 200: |
| | 697 | | { |
| | 698 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 699 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 700 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 701 | | return Response.FromValue(value, message.Response); |
| | 702 | | } |
| | 703 | | default: |
| 0 | 704 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 705 | | } |
| 0 | 706 | | } |
| | 707 | |
|
| | 708 | | /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary> |
| | 709 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 710 | | /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa |
| | 711 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 712 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> or <paramref name="resourceGroupName"/> |
| | 713 | | public Response<DigitalTwinsDescriptionListResult> ListByResourceGroupNextPage(string nextLink, string resourceG |
| | 714 | | { |
| 0 | 715 | | if (nextLink == null) |
| | 716 | | { |
| 0 | 717 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 718 | | } |
| 0 | 719 | | if (resourceGroupName == null) |
| | 720 | | { |
| 0 | 721 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 722 | | } |
| | 723 | |
|
| 0 | 724 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 725 | | _pipeline.Send(message, cancellationToken); |
| 0 | 726 | | switch (message.Response.Status) |
| | 727 | | { |
| | 728 | | case 200: |
| | 729 | | { |
| | 730 | | DigitalTwinsDescriptionListResult value = default; |
| 0 | 731 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 732 | | value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document. |
| 0 | 733 | | return Response.FromValue(value, message.Response); |
| | 734 | | } |
| | 735 | | default: |
| 0 | 736 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 737 | | } |
| 0 | 738 | | } |
| | 739 | | } |
| | 740 | | } |