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