Пример #1
0
        /// <summary>
        /// Updates the specified FeatureRolloutPolicy using PATCH.
        /// </summary>
        /// <param name="featureRolloutPolicyToUpdate">The FeatureRolloutPolicy 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 FeatureRolloutPolicy.</returns>
        public async System.Threading.Tasks.Task <FeatureRolloutPolicy> UpdateAsync(FeatureRolloutPolicy featureRolloutPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (featureRolloutPolicyToUpdate.AdditionalData != null)
            {
                if (featureRolloutPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    featureRolloutPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, featureRolloutPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (featureRolloutPolicyToUpdate.AdditionalData != null)
            {
                if (featureRolloutPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    featureRolloutPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, featureRolloutPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <FeatureRolloutPolicy>(featureRolloutPolicyToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Пример #2
0
        /// <summary>
        /// Creates the specified FeatureRolloutPolicy using POST.
        /// </summary>
        /// <param name="featureRolloutPolicyToCreate">The FeatureRolloutPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created FeatureRolloutPolicy.</returns>
        public async System.Threading.Tasks.Task <FeatureRolloutPolicy> CreateAsync(FeatureRolloutPolicy featureRolloutPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <FeatureRolloutPolicy>(featureRolloutPolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Пример #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="featureRolloutPolicyToInitialize">The <see cref="FeatureRolloutPolicy"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(FeatureRolloutPolicy featureRolloutPolicyToInitialize)
        {
            if (featureRolloutPolicyToInitialize != null && featureRolloutPolicyToInitialize.AdditionalData != null)
            {
                if (featureRolloutPolicyToInitialize.AppliesTo != null && featureRolloutPolicyToInitialize.AppliesTo.CurrentPage != null)
                {
                    featureRolloutPolicyToInitialize.AppliesTo.AdditionalData = featureRolloutPolicyToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        featureRolloutPolicyToInitialize.AppliesTo.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified FeatureRolloutPolicy to the collection via POST.
 /// </summary>
 /// <param name="featureRolloutPolicy">The FeatureRolloutPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created FeatureRolloutPolicy.</returns>
 public System.Threading.Tasks.Task <FeatureRolloutPolicy> AddAsync(FeatureRolloutPolicy featureRolloutPolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <FeatureRolloutPolicy>(featureRolloutPolicy, cancellationToken));
 }
 /// <summary>
 /// Adds the specified FeatureRolloutPolicy to the collection via POST.
 /// </summary>
 /// <param name="featureRolloutPolicy">The FeatureRolloutPolicy to add.</param>
 /// <returns>The created FeatureRolloutPolicy.</returns>
 public System.Threading.Tasks.Task <FeatureRolloutPolicy> AddAsync(FeatureRolloutPolicy featureRolloutPolicy)
 {
     return(this.AddAsync(featureRolloutPolicy, CancellationToken.None));
 }
Пример #6
0
 /// <summary>
 /// Creates the specified FeatureRolloutPolicy using POST.
 /// </summary>
 /// <param name="featureRolloutPolicyToCreate">The FeatureRolloutPolicy to create.</param>
 /// <returns>The created FeatureRolloutPolicy.</returns>
 public System.Threading.Tasks.Task <FeatureRolloutPolicy> CreateAsync(FeatureRolloutPolicy featureRolloutPolicyToCreate)
 {
     return(this.CreateAsync(featureRolloutPolicyToCreate, CancellationToken.None));
 }