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