/// <summary> /// Creates the specified DataClassificationService using POST. /// </summary> /// <param name="dataClassificationServiceToCreate">The DataClassificationService to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DataClassificationService.</returns> public async System.Threading.Tasks.Task <DataClassificationService> CreateAsync(DataClassificationService dataClassificationServiceToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <DataClassificationService>(dataClassificationServiceToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="dataClassificationServiceToInitialize">The <see cref="DataClassificationService"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(DataClassificationService dataClassificationServiceToInitialize) { if (dataClassificationServiceToInitialize != null && dataClassificationServiceToInitialize.AdditionalData != null) { if (dataClassificationServiceToInitialize.ExactMatchDataStores != null && dataClassificationServiceToInitialize.ExactMatchDataStores.CurrentPage != null) { dataClassificationServiceToInitialize.ExactMatchDataStores.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ExactMatchDataStores.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.ClassifyFile != null && dataClassificationServiceToInitialize.ClassifyFile.CurrentPage != null) { dataClassificationServiceToInitialize.ClassifyFile.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ClassifyFile.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.ClassifyFileJobs != null && dataClassificationServiceToInitialize.ClassifyFileJobs.CurrentPage != null) { dataClassificationServiceToInitialize.ClassifyFileJobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ClassifyFileJobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.ClassifyText != null && dataClassificationServiceToInitialize.ClassifyText.CurrentPage != null) { dataClassificationServiceToInitialize.ClassifyText.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ClassifyText.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.ClassifyTextJobs != null && dataClassificationServiceToInitialize.ClassifyTextJobs.CurrentPage != null) { dataClassificationServiceToInitialize.ClassifyTextJobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ClassifyTextJobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.EvaluateDlpPoliciesJobs != null && dataClassificationServiceToInitialize.EvaluateDlpPoliciesJobs.CurrentPage != null) { dataClassificationServiceToInitialize.EvaluateDlpPoliciesJobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.EvaluateDlpPoliciesJobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.EvaluateLabelJobs != null && dataClassificationServiceToInitialize.EvaluateLabelJobs.CurrentPage != null) { dataClassificationServiceToInitialize.EvaluateLabelJobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.EvaluateLabelJobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.Jobs != null && dataClassificationServiceToInitialize.Jobs.CurrentPage != null) { dataClassificationServiceToInitialize.Jobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.Jobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.LabelsAndPoliciesEvaluationJobs != null && dataClassificationServiceToInitialize.LabelsAndPoliciesEvaluationJobs.CurrentPage != null) { dataClassificationServiceToInitialize.LabelsAndPoliciesEvaluationJobs.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.LabelsAndPoliciesEvaluationJobs.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.SensitiveTypes != null && dataClassificationServiceToInitialize.SensitiveTypes.CurrentPage != null) { dataClassificationServiceToInitialize.SensitiveTypes.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.SensitiveTypes.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.SensitivityLabels != null && dataClassificationServiceToInitialize.SensitivityLabels.CurrentPage != null) { dataClassificationServiceToInitialize.SensitivityLabels.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.SensitivityLabels.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (dataClassificationServiceToInitialize.ExactMatchUploadAgents != null && dataClassificationServiceToInitialize.ExactMatchUploadAgents.CurrentPage != null) { dataClassificationServiceToInitialize.ExactMatchUploadAgents.AdditionalData = dataClassificationServiceToInitialize.AdditionalData; object nextPageLink; dataClassificationServiceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { dataClassificationServiceToInitialize.ExactMatchUploadAgents.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified DataClassificationService using POST. /// </summary> /// <param name="dataClassificationServiceToCreate">The DataClassificationService to create.</param> /// <returns>The created DataClassificationService.</returns> public System.Threading.Tasks.Task <DataClassificationService> CreateAsync(DataClassificationService dataClassificationServiceToCreate) { return(this.CreateAsync(dataClassificationServiceToCreate, CancellationToken.None)); }
/// <summary> /// Updates the specified DataClassificationService using PATCH. /// </summary> /// <param name="dataClassificationServiceToUpdate">The DataClassificationService 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 DataClassificationService.</returns> public async System.Threading.Tasks.Task <DataClassificationService> UpdateAsync(DataClassificationService dataClassificationServiceToUpdate, CancellationToken cancellationToken) { if (dataClassificationServiceToUpdate.AdditionalData != null) { if (dataClassificationServiceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || dataClassificationServiceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, dataClassificationServiceToUpdate.GetType().Name) }); } } if (dataClassificationServiceToUpdate.AdditionalData != null) { if (dataClassificationServiceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || dataClassificationServiceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, dataClassificationServiceToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <DataClassificationService>(dataClassificationServiceToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }