/// <summary>
        /// Adds the specified HomeRealmDiscoveryPolicy to the collection via POST.
        /// </summary>
        /// <param name="homeRealmDiscoveryPolicy">The HomeRealmDiscoveryPolicy to add.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await.</returns>
        public System.Threading.Tasks.Task AddAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicy, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(homeRealmDiscoveryPolicy.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/policies/homeRealmDiscoveryPolicies/{1}", this.Client.BaseUrl, homeRealmDiscoveryPolicy.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
예제 #2
0
 /// <summary>
 /// Adds the specified HomeRealmDiscoveryPolicy to the collection via POST.
 /// </summary>
 /// <param name="homeRealmDiscoveryPolicy">The HomeRealmDiscoveryPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created HomeRealmDiscoveryPolicy.</returns>
 public System.Threading.Tasks.Task <HomeRealmDiscoveryPolicy> AddAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <HomeRealmDiscoveryPolicy>(homeRealmDiscoveryPolicy, cancellationToken));
 }
예제 #3
0
 /// <summary>
 /// Adds the specified HomeRealmDiscoveryPolicy to the collection via POST.
 /// </summary>
 /// <param name="homeRealmDiscoveryPolicy">The HomeRealmDiscoveryPolicy to add.</param>
 /// <returns>The created HomeRealmDiscoveryPolicy.</returns>
 public System.Threading.Tasks.Task <HomeRealmDiscoveryPolicy> AddAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicy)
 {
     return(this.AddAsync(homeRealmDiscoveryPolicy, CancellationToken.None));
 }
예제 #4
0
        /// <summary>
        /// Creates the specified HomeRealmDiscoveryPolicy using POST.
        /// </summary>
        /// <param name="homeRealmDiscoveryPolicyToCreate">The HomeRealmDiscoveryPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created HomeRealmDiscoveryPolicy.</returns>
        public async System.Threading.Tasks.Task <HomeRealmDiscoveryPolicy> CreateAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <HomeRealmDiscoveryPolicy>(homeRealmDiscoveryPolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
예제 #5
0
 /// <summary>
 /// Creates the specified HomeRealmDiscoveryPolicy using POST.
 /// </summary>
 /// <param name="homeRealmDiscoveryPolicyToCreate">The HomeRealmDiscoveryPolicy to create.</param>
 /// <returns>The created HomeRealmDiscoveryPolicy.</returns>
 public System.Threading.Tasks.Task <HomeRealmDiscoveryPolicy> CreateAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicyToCreate)
 {
     return(this.CreateAsync(homeRealmDiscoveryPolicyToCreate, CancellationToken.None));
 }
예제 #6
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="homeRealmDiscoveryPolicyToInitialize">The <see cref="HomeRealmDiscoveryPolicy"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicyToInitialize)
 {
 }
예제 #7
0
        /// <summary>
        /// Updates the specified HomeRealmDiscoveryPolicy using PATCH.
        /// </summary>
        /// <param name="homeRealmDiscoveryPolicyToUpdate">The HomeRealmDiscoveryPolicy 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 HomeRealmDiscoveryPolicy.</returns>
        public async System.Threading.Tasks.Task <HomeRealmDiscoveryPolicy> UpdateAsync(HomeRealmDiscoveryPolicy homeRealmDiscoveryPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (homeRealmDiscoveryPolicyToUpdate.AdditionalData != null)
            {
                if (homeRealmDiscoveryPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    homeRealmDiscoveryPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, homeRealmDiscoveryPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (homeRealmDiscoveryPolicyToUpdate.AdditionalData != null)
            {
                if (homeRealmDiscoveryPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    homeRealmDiscoveryPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, homeRealmDiscoveryPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <HomeRealmDiscoveryPolicy>(homeRealmDiscoveryPolicyToUpdate, cancellationToken).ConfigureAwait(false);

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