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