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