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