/// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="cloudPcProvisioningPolicyToInitialize">The <see cref="CloudPcProvisioningPolicy"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(CloudPcProvisioningPolicy cloudPcProvisioningPolicyToInitialize)
        {
            if (cloudPcProvisioningPolicyToInitialize != null && cloudPcProvisioningPolicyToInitialize.AdditionalData != null)
            {
                if (cloudPcProvisioningPolicyToInitialize.Assignments != null && cloudPcProvisioningPolicyToInitialize.Assignments.CurrentPage != null)
                {
                    cloudPcProvisioningPolicyToInitialize.Assignments.AdditionalData = cloudPcProvisioningPolicyToInitialize.AdditionalData;

                    object nextPageLink;
                    cloudPcProvisioningPolicyToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        cloudPcProvisioningPolicyToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Adds the specified CloudPcProvisioningPolicy to the collection via POST.
 /// </summary>
 /// <param name="cloudPcProvisioningPolicy">The CloudPcProvisioningPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created CloudPcProvisioningPolicy.</returns>
 public System.Threading.Tasks.Task <CloudPcProvisioningPolicy> AddAsync(CloudPcProvisioningPolicy cloudPcProvisioningPolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <CloudPcProvisioningPolicy>(cloudPcProvisioningPolicy, cancellationToken));
 }
Esempio n. 3
0
 /// <summary>
 /// Adds the specified CloudPcProvisioningPolicy to the collection via POST.
 /// </summary>
 /// <param name="cloudPcProvisioningPolicy">The CloudPcProvisioningPolicy to add.</param>
 /// <returns>The created CloudPcProvisioningPolicy.</returns>
 public System.Threading.Tasks.Task <CloudPcProvisioningPolicy> AddAsync(CloudPcProvisioningPolicy cloudPcProvisioningPolicy)
 {
     return(this.AddAsync(cloudPcProvisioningPolicy, CancellationToken.None));
 }
        /// <summary>
        /// Creates the specified CloudPcProvisioningPolicy using POST.
        /// </summary>
        /// <param name="cloudPcProvisioningPolicyToCreate">The CloudPcProvisioningPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created CloudPcProvisioningPolicy.</returns>
        public async System.Threading.Tasks.Task <CloudPcProvisioningPolicy> CreateAsync(CloudPcProvisioningPolicy cloudPcProvisioningPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <CloudPcProvisioningPolicy>(cloudPcProvisioningPolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Creates the specified CloudPcProvisioningPolicy using POST.
 /// </summary>
 /// <param name="cloudPcProvisioningPolicyToCreate">The CloudPcProvisioningPolicy to create.</param>
 /// <returns>The created CloudPcProvisioningPolicy.</returns>
 public System.Threading.Tasks.Task <CloudPcProvisioningPolicy> CreateAsync(CloudPcProvisioningPolicy cloudPcProvisioningPolicyToCreate)
 {
     return(this.CreateAsync(cloudPcProvisioningPolicyToCreate, CancellationToken.None));
 }
        /// <summary>
        /// Updates the specified CloudPcProvisioningPolicy using PATCH.
        /// </summary>
        /// <param name="cloudPcProvisioningPolicyToUpdate">The CloudPcProvisioningPolicy 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 CloudPcProvisioningPolicy.</returns>
        public async System.Threading.Tasks.Task <CloudPcProvisioningPolicy> UpdateAsync(CloudPcProvisioningPolicy cloudPcProvisioningPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (cloudPcProvisioningPolicyToUpdate.AdditionalData != null)
            {
                if (cloudPcProvisioningPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    cloudPcProvisioningPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, cloudPcProvisioningPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (cloudPcProvisioningPolicyToUpdate.AdditionalData != null)
            {
                if (cloudPcProvisioningPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    cloudPcProvisioningPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, cloudPcProvisioningPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <CloudPcProvisioningPolicy>(cloudPcProvisioningPolicyToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }