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