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