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