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