| | 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.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.Search.Documents.Indexes.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.Search.Documents |
| | 18 | | { |
| | 19 | | internal partial class SkillsetsRestClient |
| | 20 | | { |
| | 21 | | private string endpoint; |
| | 22 | | private Guid? xMsClientRequestId; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of SkillsetsRestClient. </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"> The endpoint URL of the search service. </param> |
| | 31 | | /// <param name="xMsClientRequestId"> The tracking ID sent with the request to help with debugging. </param> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| | 33 | | /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul |
| 5 | 34 | | public SkillsetsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, Guid? xM |
| | 35 | | { |
| 5 | 36 | | if (endpoint == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(endpoint)); |
| | 39 | | } |
| 5 | 40 | | if (apiVersion == null) |
| | 41 | | { |
| 0 | 42 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 43 | | } |
| | 44 | |
|
| 5 | 45 | | this.endpoint = endpoint; |
| 5 | 46 | | this.xMsClientRequestId = xMsClientRequestId; |
| 5 | 47 | | this.apiVersion = apiVersion; |
| 5 | 48 | | _clientDiagnostics = clientDiagnostics; |
| 5 | 49 | | _pipeline = pipeline; |
| 5 | 50 | | } |
| | 51 | |
|
| | 52 | | internal HttpMessage CreateCreateOrUpdateRequest(string skillsetName, SearchIndexerSkillset skillset, string ifM |
| | 53 | | { |
| 2 | 54 | | var message = _pipeline.CreateMessage(); |
| 2 | 55 | | var request = message.Request; |
| 2 | 56 | | request.Method = RequestMethod.Put; |
| 2 | 57 | | var uri = new RawRequestUriBuilder(); |
| 2 | 58 | | uri.AppendRaw(endpoint, false); |
| 2 | 59 | | uri.AppendPath("/skillsets('", false); |
| 2 | 60 | | uri.AppendPath(skillsetName, true); |
| 2 | 61 | | uri.AppendPath("')", false); |
| 2 | 62 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 63 | | request.Uri = uri; |
| 2 | 64 | | if (xMsClientRequestId != null) |
| | 65 | | { |
| 0 | 66 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 67 | | } |
| 2 | 68 | | if (ifMatch != null) |
| | 69 | | { |
| 2 | 70 | | request.Headers.Add("If-Match", ifMatch); |
| | 71 | | } |
| 2 | 72 | | if (ifNoneMatch != null) |
| | 73 | | { |
| 0 | 74 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 75 | | } |
| 2 | 76 | | request.Headers.Add("Prefer", "return=representation"); |
| 2 | 77 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 78 | | request.Headers.Add("Content-Type", "application/json"); |
| 2 | 79 | | var content = new Utf8JsonRequestContent(); |
| 2 | 80 | | content.JsonWriter.WriteObjectValue(skillset); |
| 2 | 81 | | request.Content = content; |
| 2 | 82 | | return message; |
| | 83 | | } |
| | 84 | |
|
| | 85 | | /// <summary> Creates a new skillset in a search service or updates the skillset if it already exists. </summary |
| | 86 | | /// <param name="skillsetName"> The name of the skillset to create or update. </param> |
| | 87 | | /// <param name="skillset"> The skillset containing one or more skills to create or update in a search service. |
| | 88 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 89 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 90 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 91 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> or <paramref name="skillset"/> is n |
| | 92 | | public async Task<Response<SearchIndexerSkillset>> CreateOrUpdateAsync(string skillsetName, SearchIndexerSkillse |
| | 93 | | { |
| 1 | 94 | | if (skillsetName == null) |
| | 95 | | { |
| 0 | 96 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 97 | | } |
| 1 | 98 | | if (skillset == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(skillset)); |
| | 101 | | } |
| | 102 | |
|
| 1 | 103 | | using var message = CreateCreateOrUpdateRequest(skillsetName, skillset, ifMatch, ifNoneMatch); |
| 1 | 104 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 105 | | switch (message.Response.Status) |
| | 106 | | { |
| | 107 | | case 200: |
| | 108 | | case 201: |
| | 109 | | { |
| | 110 | | SearchIndexerSkillset value = default; |
| 1 | 111 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 112 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 1 | 113 | | return Response.FromValue(value, message.Response); |
| | 114 | | } |
| | 115 | | default: |
| 0 | 116 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 117 | | } |
| 1 | 118 | | } |
| | 119 | |
|
| | 120 | | /// <summary> Creates a new skillset in a search service or updates the skillset if it already exists. </summary |
| | 121 | | /// <param name="skillsetName"> The name of the skillset to create or update. </param> |
| | 122 | | /// <param name="skillset"> The skillset containing one or more skills to create or update in a search service. |
| | 123 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 124 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 125 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 126 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> or <paramref name="skillset"/> is n |
| | 127 | | public Response<SearchIndexerSkillset> CreateOrUpdate(string skillsetName, SearchIndexerSkillset skillset, strin |
| | 128 | | { |
| 1 | 129 | | if (skillsetName == null) |
| | 130 | | { |
| 0 | 131 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 132 | | } |
| 1 | 133 | | if (skillset == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(skillset)); |
| | 136 | | } |
| | 137 | |
|
| 1 | 138 | | using var message = CreateCreateOrUpdateRequest(skillsetName, skillset, ifMatch, ifNoneMatch); |
| 1 | 139 | | _pipeline.Send(message, cancellationToken); |
| 1 | 140 | | switch (message.Response.Status) |
| | 141 | | { |
| | 142 | | case 200: |
| | 143 | | case 201: |
| | 144 | | { |
| | 145 | | SearchIndexerSkillset value = default; |
| 1 | 146 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 147 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 1 | 148 | | return Response.FromValue(value, message.Response); |
| | 149 | | } |
| | 150 | | default: |
| 0 | 151 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 152 | | } |
| 1 | 153 | | } |
| | 154 | |
|
| | 155 | | internal HttpMessage CreateDeleteRequest(string skillsetName, string ifMatch, string ifNoneMatch) |
| | 156 | | { |
| 3 | 157 | | var message = _pipeline.CreateMessage(); |
| 3 | 158 | | var request = message.Request; |
| 3 | 159 | | request.Method = RequestMethod.Delete; |
| 3 | 160 | | var uri = new RawRequestUriBuilder(); |
| 3 | 161 | | uri.AppendRaw(endpoint, false); |
| 3 | 162 | | uri.AppendPath("/skillsets('", false); |
| 3 | 163 | | uri.AppendPath(skillsetName, true); |
| 3 | 164 | | uri.AppendPath("')", false); |
| 3 | 165 | | uri.AppendQuery("api-version", apiVersion, true); |
| 3 | 166 | | request.Uri = uri; |
| 3 | 167 | | if (xMsClientRequestId != null) |
| | 168 | | { |
| 0 | 169 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 170 | | } |
| 3 | 171 | | if (ifMatch != null) |
| | 172 | | { |
| 2 | 173 | | request.Headers.Add("If-Match", ifMatch); |
| | 174 | | } |
| 3 | 175 | | if (ifNoneMatch != null) |
| | 176 | | { |
| 0 | 177 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 178 | | } |
| 3 | 179 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 3 | 180 | | return message; |
| | 181 | | } |
| | 182 | |
|
| | 183 | | /// <summary> Deletes a skillset in a search service. </summary> |
| | 184 | | /// <param name="skillsetName"> The name of the skillset to delete. </param> |
| | 185 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 186 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 187 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 188 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> is null. </exception> |
| | 189 | | public async Task<Response> DeleteAsync(string skillsetName, string ifMatch = null, string ifNoneMatch = null, C |
| | 190 | | { |
| 2 | 191 | | if (skillsetName == null) |
| | 192 | | { |
| 0 | 193 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 194 | | } |
| | 195 | |
|
| 2 | 196 | | using var message = CreateDeleteRequest(skillsetName, ifMatch, ifNoneMatch); |
| 2 | 197 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 198 | | switch (message.Response.Status) |
| | 199 | | { |
| | 200 | | case 204: |
| | 201 | | case 404: |
| 2 | 202 | | return message.Response; |
| | 203 | | default: |
| 0 | 204 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 205 | | } |
| 2 | 206 | | } |
| | 207 | |
|
| | 208 | | /// <summary> Deletes a skillset in a search service. </summary> |
| | 209 | | /// <param name="skillsetName"> The name of the skillset to delete. </param> |
| | 210 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 211 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 212 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 213 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> is null. </exception> |
| | 214 | | public Response Delete(string skillsetName, string ifMatch = null, string ifNoneMatch = null, CancellationToken |
| | 215 | | { |
| 1 | 216 | | if (skillsetName == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 219 | | } |
| | 220 | |
|
| 1 | 221 | | using var message = CreateDeleteRequest(skillsetName, ifMatch, ifNoneMatch); |
| 1 | 222 | | _pipeline.Send(message, cancellationToken); |
| 1 | 223 | | switch (message.Response.Status) |
| | 224 | | { |
| | 225 | | case 204: |
| | 226 | | case 404: |
| 1 | 227 | | return message.Response; |
| | 228 | | default: |
| 0 | 229 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 230 | | } |
| 1 | 231 | | } |
| | 232 | |
|
| | 233 | | internal HttpMessage CreateGetRequest(string skillsetName) |
| | 234 | | { |
| 2 | 235 | | var message = _pipeline.CreateMessage(); |
| 2 | 236 | | var request = message.Request; |
| 2 | 237 | | request.Method = RequestMethod.Get; |
| 2 | 238 | | var uri = new RawRequestUriBuilder(); |
| 2 | 239 | | uri.AppendRaw(endpoint, false); |
| 2 | 240 | | uri.AppendPath("/skillsets('", false); |
| 2 | 241 | | uri.AppendPath(skillsetName, true); |
| 2 | 242 | | uri.AppendPath("')", false); |
| 2 | 243 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 244 | | request.Uri = uri; |
| 2 | 245 | | if (xMsClientRequestId != null) |
| | 246 | | { |
| 0 | 247 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 248 | | } |
| 2 | 249 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 250 | | return message; |
| | 251 | | } |
| | 252 | |
|
| | 253 | | /// <summary> Retrieves a skillset in a search service. </summary> |
| | 254 | | /// <param name="skillsetName"> The name of the skillset to retrieve. </param> |
| | 255 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 256 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> is null. </exception> |
| | 257 | | public async Task<Response<SearchIndexerSkillset>> GetAsync(string skillsetName, CancellationToken cancellationT |
| | 258 | | { |
| 2 | 259 | | if (skillsetName == null) |
| | 260 | | { |
| 1 | 261 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 262 | | } |
| | 263 | |
|
| 1 | 264 | | using var message = CreateGetRequest(skillsetName); |
| 1 | 265 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 266 | | switch (message.Response.Status) |
| | 267 | | { |
| | 268 | | case 200: |
| | 269 | | { |
| | 270 | | SearchIndexerSkillset value = default; |
| 1 | 271 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 272 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 1 | 273 | | return Response.FromValue(value, message.Response); |
| | 274 | | } |
| | 275 | | default: |
| 0 | 276 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 277 | | } |
| 1 | 278 | | } |
| | 279 | |
|
| | 280 | | /// <summary> Retrieves a skillset in a search service. </summary> |
| | 281 | | /// <param name="skillsetName"> The name of the skillset to retrieve. </param> |
| | 282 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 283 | | /// <exception cref="ArgumentNullException"> <paramref name="skillsetName"/> is null. </exception> |
| | 284 | | public Response<SearchIndexerSkillset> Get(string skillsetName, CancellationToken cancellationToken = default) |
| | 285 | | { |
| 2 | 286 | | if (skillsetName == null) |
| | 287 | | { |
| 1 | 288 | | throw new ArgumentNullException(nameof(skillsetName)); |
| | 289 | | } |
| | 290 | |
|
| 1 | 291 | | using var message = CreateGetRequest(skillsetName); |
| 1 | 292 | | _pipeline.Send(message, cancellationToken); |
| 1 | 293 | | switch (message.Response.Status) |
| | 294 | | { |
| | 295 | | case 200: |
| | 296 | | { |
| | 297 | | SearchIndexerSkillset value = default; |
| 1 | 298 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 299 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 1 | 300 | | return Response.FromValue(value, message.Response); |
| | 301 | | } |
| | 302 | | default: |
| 0 | 303 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 304 | | } |
| 1 | 305 | | } |
| | 306 | |
|
| | 307 | | internal HttpMessage CreateListRequest(string select) |
| | 308 | | { |
| 2 | 309 | | var message = _pipeline.CreateMessage(); |
| 2 | 310 | | var request = message.Request; |
| 2 | 311 | | request.Method = RequestMethod.Get; |
| 2 | 312 | | var uri = new RawRequestUriBuilder(); |
| 2 | 313 | | uri.AppendRaw(endpoint, false); |
| 2 | 314 | | uri.AppendPath("/skillsets", false); |
| 2 | 315 | | if (select != null) |
| | 316 | | { |
| 2 | 317 | | uri.AppendQuery("$select", select, true); |
| | 318 | | } |
| 2 | 319 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 320 | | request.Uri = uri; |
| 2 | 321 | | if (xMsClientRequestId != null) |
| | 322 | | { |
| 0 | 323 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 324 | | } |
| 2 | 325 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 326 | | return message; |
| | 327 | | } |
| | 328 | |
|
| | 329 | | /// <summary> List all skillsets in a search service. </summary> |
| | 330 | | /// <param name="select"> Selects which top-level properties of the skillsets to retrieve. Specified as a comma- |
| | 331 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 332 | | public async Task<Response<ListSkillsetsResult>> ListAsync(string select = null, CancellationToken cancellationT |
| | 333 | | { |
| 1 | 334 | | using var message = CreateListRequest(select); |
| 1 | 335 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 336 | | switch (message.Response.Status) |
| | 337 | | { |
| | 338 | | case 200: |
| | 339 | | { |
| | 340 | | ListSkillsetsResult value = default; |
| 1 | 341 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 342 | | value = ListSkillsetsResult.DeserializeListSkillsetsResult(document.RootElement); |
| 1 | 343 | | return Response.FromValue(value, message.Response); |
| | 344 | | } |
| | 345 | | default: |
| 0 | 346 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 347 | | } |
| 1 | 348 | | } |
| | 349 | |
|
| | 350 | | /// <summary> List all skillsets in a search service. </summary> |
| | 351 | | /// <param name="select"> Selects which top-level properties of the skillsets to retrieve. Specified as a comma- |
| | 352 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 353 | | public Response<ListSkillsetsResult> List(string select = null, CancellationToken cancellationToken = default) |
| | 354 | | { |
| 1 | 355 | | using var message = CreateListRequest(select); |
| 1 | 356 | | _pipeline.Send(message, cancellationToken); |
| 1 | 357 | | switch (message.Response.Status) |
| | 358 | | { |
| | 359 | | case 200: |
| | 360 | | { |
| | 361 | | ListSkillsetsResult value = default; |
| 1 | 362 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 363 | | value = ListSkillsetsResult.DeserializeListSkillsetsResult(document.RootElement); |
| 1 | 364 | | return Response.FromValue(value, message.Response); |
| | 365 | | } |
| | 366 | | default: |
| 0 | 367 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 368 | | } |
| 1 | 369 | | } |
| | 370 | |
|
| | 371 | | internal HttpMessage CreateCreateRequest(SearchIndexerSkillset skillset) |
| | 372 | | { |
| 3 | 373 | | var message = _pipeline.CreateMessage(); |
| 3 | 374 | | var request = message.Request; |
| 3 | 375 | | request.Method = RequestMethod.Post; |
| 3 | 376 | | var uri = new RawRequestUriBuilder(); |
| 3 | 377 | | uri.AppendRaw(endpoint, false); |
| 3 | 378 | | uri.AppendPath("/skillsets", false); |
| 3 | 379 | | uri.AppendQuery("api-version", apiVersion, true); |
| 3 | 380 | | request.Uri = uri; |
| 3 | 381 | | if (xMsClientRequestId != null) |
| | 382 | | { |
| 0 | 383 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 384 | | } |
| 3 | 385 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 3 | 386 | | request.Headers.Add("Content-Type", "application/json"); |
| 3 | 387 | | var content = new Utf8JsonRequestContent(); |
| 3 | 388 | | content.JsonWriter.WriteObjectValue(skillset); |
| 3 | 389 | | request.Content = content; |
| 3 | 390 | | return message; |
| | 391 | | } |
| | 392 | |
|
| | 393 | | /// <summary> Creates a new skillset in a search service. </summary> |
| | 394 | | /// <param name="skillset"> The skillset containing one or more skills to create in a search service. </param> |
| | 395 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 396 | | /// <exception cref="ArgumentNullException"> <paramref name="skillset"/> is null. </exception> |
| | 397 | | public async Task<Response<SearchIndexerSkillset>> CreateAsync(SearchIndexerSkillset skillset, CancellationToken |
| | 398 | | { |
| 3 | 399 | | if (skillset == null) |
| | 400 | | { |
| 1 | 401 | | throw new ArgumentNullException(nameof(skillset)); |
| | 402 | | } |
| | 403 | |
|
| 2 | 404 | | using var message = CreateCreateRequest(skillset); |
| 2 | 405 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 406 | | switch (message.Response.Status) |
| | 407 | | { |
| | 408 | | case 201: |
| | 409 | | { |
| | 410 | | SearchIndexerSkillset value = default; |
| 2 | 411 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 412 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 2 | 413 | | return Response.FromValue(value, message.Response); |
| | 414 | | } |
| | 415 | | default: |
| 0 | 416 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 417 | | } |
| 2 | 418 | | } |
| | 419 | |
|
| | 420 | | /// <summary> Creates a new skillset in a search service. </summary> |
| | 421 | | /// <param name="skillset"> The skillset containing one or more skills to create in a search service. </param> |
| | 422 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 423 | | /// <exception cref="ArgumentNullException"> <paramref name="skillset"/> is null. </exception> |
| | 424 | | public Response<SearchIndexerSkillset> Create(SearchIndexerSkillset skillset, CancellationToken cancellationToke |
| | 425 | | { |
| 2 | 426 | | if (skillset == null) |
| | 427 | | { |
| 1 | 428 | | throw new ArgumentNullException(nameof(skillset)); |
| | 429 | | } |
| | 430 | |
|
| 1 | 431 | | using var message = CreateCreateRequest(skillset); |
| 1 | 432 | | _pipeline.Send(message, cancellationToken); |
| 1 | 433 | | switch (message.Response.Status) |
| | 434 | | { |
| | 435 | | case 201: |
| | 436 | | { |
| | 437 | | SearchIndexerSkillset value = default; |
| 1 | 438 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 439 | | value = SearchIndexerSkillset.DeserializeSearchIndexerSkillset(document.RootElement); |
| 1 | 440 | | return Response.FromValue(value, message.Response); |
| | 441 | | } |
| | 442 | | default: |
| 0 | 443 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 444 | | } |
| 1 | 445 | | } |
| | 446 | | } |
| | 447 | | } |