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