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