/// <summary> /// Updates the specified GroupPolicyCategory using PATCH. /// </summary> /// <param name="groupPolicyCategoryToUpdate">The GroupPolicyCategory 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 GroupPolicyCategory.</returns> public async System.Threading.Tasks.Task <GroupPolicyCategory> UpdateAsync(GroupPolicyCategory groupPolicyCategoryToUpdate, CancellationToken cancellationToken) { if (groupPolicyCategoryToUpdate.AdditionalData != null) { if (groupPolicyCategoryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || groupPolicyCategoryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, groupPolicyCategoryToUpdate.GetType().Name) }); } } if (groupPolicyCategoryToUpdate.AdditionalData != null) { if (groupPolicyCategoryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || groupPolicyCategoryToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, groupPolicyCategoryToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <GroupPolicyCategory>(groupPolicyCategoryToUpdate, cancellationToken).ConfigureAwait(false); return(updatedEntity); }
/// <summary> /// Creates the specified GroupPolicyCategory using POST. /// </summary> /// <param name="groupPolicyCategoryToCreate">The GroupPolicyCategory to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created GroupPolicyCategory.</returns> public async System.Threading.Tasks.Task <GroupPolicyCategory> CreateAsync(GroupPolicyCategory groupPolicyCategoryToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <GroupPolicyCategory>(groupPolicyCategoryToCreate, cancellationToken).ConfigureAwait(false); return(newEntity); }
/// <summary> /// Adds the specified GroupPolicyCategory to the collection via POST. /// </summary> /// <param name="groupPolicyCategory">The GroupPolicyCategory to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The task to await.</returns> public System.Threading.Tasks.Task AddAsync(GroupPolicyCategory groupPolicyCategory, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; if (string.IsNullOrEmpty(groupPolicyCategory.Id)) { throw new ServiceException(new Error { Code = "invalidRequest", Message = "ID is required to add a reference." }); } var requestBody = new ReferenceRequestBody { ODataId = string.Format("{0}/deviceManagement/children/{1}", this.Client.BaseUrl, groupPolicyCategory.Id) }; return(this.SendAsync(requestBody, cancellationToken)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="groupPolicyCategoryToInitialize">The <see cref="GroupPolicyCategory"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(GroupPolicyCategory groupPolicyCategoryToInitialize) { if (groupPolicyCategoryToInitialize != null && groupPolicyCategoryToInitialize.AdditionalData != null) { if (groupPolicyCategoryToInitialize.Children != null && groupPolicyCategoryToInitialize.Children.CurrentPage != null) { groupPolicyCategoryToInitialize.Children.AdditionalData = groupPolicyCategoryToInitialize.AdditionalData; object nextPageLink; groupPolicyCategoryToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { groupPolicyCategoryToInitialize.Children.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (groupPolicyCategoryToInitialize.Definitions != null && groupPolicyCategoryToInitialize.Definitions.CurrentPage != null) { groupPolicyCategoryToInitialize.Definitions.AdditionalData = groupPolicyCategoryToInitialize.AdditionalData; object nextPageLink; groupPolicyCategoryToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { groupPolicyCategoryToInitialize.Definitions.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Updates the specified GroupPolicyCategory using PATCH. /// </summary> /// <param name="groupPolicyCategoryToUpdate">The GroupPolicyCategory to update.</param> /// <returns>The updated GroupPolicyCategory.</returns> public System.Threading.Tasks.Task <GroupPolicyCategory> UpdateAsync(GroupPolicyCategory groupPolicyCategoryToUpdate) { return(this.UpdateAsync(groupPolicyCategoryToUpdate, CancellationToken.None)); }
/// <summary> /// Adds the specified GroupPolicyCategory to the collection via POST. /// </summary> /// <param name="groupPolicyCategory">The GroupPolicyCategory to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created GroupPolicyCategory.</returns> public System.Threading.Tasks.Task <GroupPolicyCategory> AddAsync(GroupPolicyCategory groupPolicyCategory, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <GroupPolicyCategory>(groupPolicyCategory, cancellationToken)); }
/// <summary> /// Adds the specified GroupPolicyCategory to the collection via POST. /// </summary> /// <param name="groupPolicyCategory">The GroupPolicyCategory to add.</param> /// <returns>The created GroupPolicyCategory.</returns> public System.Threading.Tasks.Task <GroupPolicyCategory> AddAsync(GroupPolicyCategory groupPolicyCategory) { return(this.AddAsync(groupPolicyCategory, CancellationToken.None)); }