/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="inferenceClassificationToInitialize">The <see cref="InferenceClassification"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(InferenceClassification inferenceClassificationToInitialize) { if (inferenceClassificationToInitialize != null && inferenceClassificationToInitialize.AdditionalData != null) { if (inferenceClassificationToInitialize.Overrides != null && inferenceClassificationToInitialize.Overrides.CurrentPage != null) { inferenceClassificationToInitialize.Overrides.AdditionalData = inferenceClassificationToInitialize.AdditionalData; object nextPageLink; inferenceClassificationToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { inferenceClassificationToInitialize.Overrides.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified InferenceClassification using POST. /// </summary> /// <param name="inferenceClassificationToCreate">The InferenceClassification to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created InferenceClassification.</returns> public async System.Threading.Tasks.Task <InferenceClassification> CreateAsync(InferenceClassification inferenceClassificationToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <InferenceClassification>(inferenceClassificationToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified InferenceClassification using POST. /// </summary> /// <param name="inferenceClassificationToCreate">The InferenceClassification to create.</param> /// <returns>The created InferenceClassification.</returns> public System.Threading.Tasks.Task <InferenceClassification> CreateAsync(InferenceClassification inferenceClassificationToCreate) { return(this.CreateAsync(inferenceClassificationToCreate, CancellationToken.None)); }
/// <summary> /// Updates the specified InferenceClassification using PATCH. /// </summary> /// <param name="inferenceClassificationToUpdate">The InferenceClassification to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated InferenceClassification.</returns> public async System.Threading.Tasks.Task <InferenceClassification> UpdateAsync(InferenceClassification inferenceClassificationToUpdate, CancellationToken cancellationToken) { if (inferenceClassificationToUpdate.AdditionalData != null) { if (inferenceClassificationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || inferenceClassificationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, inferenceClassificationToUpdate.GetType().Name) }); } } if (inferenceClassificationToUpdate.AdditionalData != null) { if (inferenceClassificationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || inferenceClassificationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, inferenceClassificationToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <InferenceClassification>(inferenceClassificationToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }