/// <summary> /// Adds the specified UnifiedRoleManagementPolicyRule to the collection via POST. /// </summary> /// <param name="unifiedRoleManagementPolicyRule">The UnifiedRoleManagementPolicyRule to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created UnifiedRoleManagementPolicyRule.</returns> public System.Threading.Tasks.Task <UnifiedRoleManagementPolicyRule> AddAsync(UnifiedRoleManagementPolicyRule unifiedRoleManagementPolicyRule, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; unifiedRoleManagementPolicyRule.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(unifiedRoleManagementPolicyRule.GetType().FullName)); return(this.SendAsync <UnifiedRoleManagementPolicyRule>(unifiedRoleManagementPolicyRule, cancellationToken)); }
/// <summary> /// Updates the specified UnifiedRoleManagementPolicyRule using PATCH. /// </summary> /// <param name="unifiedRoleManagementPolicyRuleToUpdate">The UnifiedRoleManagementPolicyRule 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 UnifiedRoleManagementPolicyRule.</returns> public async System.Threading.Tasks.Task <UnifiedRoleManagementPolicyRule> UpdateAsync(UnifiedRoleManagementPolicyRule unifiedRoleManagementPolicyRuleToUpdate, CancellationToken cancellationToken) { if (unifiedRoleManagementPolicyRuleToUpdate.AdditionalData != null) { if (unifiedRoleManagementPolicyRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || unifiedRoleManagementPolicyRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, unifiedRoleManagementPolicyRuleToUpdate.GetType().Name) }); } } if (unifiedRoleManagementPolicyRuleToUpdate.AdditionalData != null) { if (unifiedRoleManagementPolicyRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || unifiedRoleManagementPolicyRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, unifiedRoleManagementPolicyRuleToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <UnifiedRoleManagementPolicyRule>(unifiedRoleManagementPolicyRuleToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }