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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
예제 #2
0
        /// <summary>
        /// Creates the specified ExternalConnection using POST.
        /// </summary>
        /// <param name="externalConnectionToCreate">The ExternalConnection to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created ExternalConnection.</returns>
        public async System.Threading.Tasks.Task <ExternalConnection> CreateAsync(ExternalConnection externalConnectionToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <ExternalConnection>(externalConnectionToCreate, 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="externalConnectionToInitialize">The <see cref="ExternalConnection"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ExternalConnection externalConnectionToInitialize)
        {
            if (externalConnectionToInitialize != null && externalConnectionToInitialize.AdditionalData != null)
            {
                if (externalConnectionToInitialize.Groups != null && externalConnectionToInitialize.Groups.CurrentPage != null)
                {
                    externalConnectionToInitialize.Groups.AdditionalData = externalConnectionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        externalConnectionToInitialize.Groups.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (externalConnectionToInitialize.Items != null && externalConnectionToInitialize.Items.CurrentPage != null)
                {
                    externalConnectionToInitialize.Items.AdditionalData = externalConnectionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        externalConnectionToInitialize.Items.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (externalConnectionToInitialize.Operations != null && externalConnectionToInitialize.Operations.CurrentPage != null)
                {
                    externalConnectionToInitialize.Operations.AdditionalData = externalConnectionToInitialize.AdditionalData;

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

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