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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        onPremisesAgentToInitialize.AgentGroups.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Adds the specified OnPremisesAgent to the collection via POST.
 /// </summary>
 /// <param name="onPremisesAgent">The OnPremisesAgent to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created OnPremisesAgent.</returns>
 public System.Threading.Tasks.Task <OnPremisesAgent> AddAsync(OnPremisesAgent onPremisesAgent, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <OnPremisesAgent>(onPremisesAgent, cancellationToken));
 }
예제 #5
0
 /// <summary>
 /// Adds the specified OnPremisesAgent to the collection via POST.
 /// </summary>
 /// <param name="onPremisesAgent">The OnPremisesAgent to add.</param>
 /// <returns>The created OnPremisesAgent.</returns>
 public System.Threading.Tasks.Task <OnPremisesAgent> AddAsync(OnPremisesAgent onPremisesAgent)
 {
     return(this.AddAsync(onPremisesAgent, CancellationToken.None));
 }
 /// <summary>
 /// Creates the specified OnPremisesAgent using POST.
 /// </summary>
 /// <param name="onPremisesAgentToCreate">The OnPremisesAgent to create.</param>
 /// <returns>The created OnPremisesAgent.</returns>
 public System.Threading.Tasks.Task <OnPremisesAgent> CreateAsync(OnPremisesAgent onPremisesAgentToCreate)
 {
     return(this.CreateAsync(onPremisesAgentToCreate, CancellationToken.None));
 }