Пример #1
0
        /// <summary>
        /// Modify alias details. Modify alias details.
        /// </summary>
        /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception>
        /// <param name="id">Name of AppBundle (unqualified).</param>/// <param name="aliasId">Name of alias.</param>/// <param name="alias">Alias details to be modified.</param>
        /// <returns>Task of ApiResponse<Alias></returns>

        public async System.Threading.Tasks.Task <ApiResponse <Alias> > ModifyAppBundleAliasAsync(string id, string aliasId, AliasPatch alias, string scopes = null, IDictionary <string, string> headers = null, bool throwOnError = true)
        {
            using (var request = new HttpRequestMessage())
            {
                request.RequestUri =
                    Marshalling.BuildRequestUri("/v3/appbundles/{id}/aliases/{aliasId}",
                                                routeParameters: new Dictionary <string, object> {
                    { "id", id },
                    { "aliasId", aliasId },
                },
                                                queryParameters: new Dictionary <string, object> {
                }
                                                );

                request.Headers.TryAddWithoutValidation("Accept", "application/json");
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        request.Headers.TryAddWithoutValidation(header.Key, header.Value);
                    }
                }

                request.Content = Marshalling.Serialize(alias); // http body (model) parameter

                // tell the underlying pipeline what scope we'd like to use
                if (scopes == null)
                {
                    request.Properties.Add(ForgeConfiguration.ScopeKey, "code:all");
                }
                else
                {
                    request.Properties.Add(ForgeConfiguration.ScopeKey, scopes);
                }

                request.Method = new HttpMethod("PATCH");

                // make the HTTP request
                var response = await this.Service.Client.SendAsync(request);

                if (throwOnError)
                {
                    await response.EnsureSuccessStatusCodeAsync();
                }
                else if (!response.IsSuccessStatusCode)
                {
                    return(new ApiResponse <Alias>(response, default(Alias)));
                }

                return(new ApiResponse <Alias>(response, await Marshalling.DeserializeAsync <Alias>(response.Content)));
            } // using
        }
        /// <summary>
        /// Lists all versions of the specified Activity.
        /// </summary>
        /// <remarks>
        /// Lists all versions of the specified Activity.
        /// </remarks>
        /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception>
        /// <param name="id">Name of Activity (unqualified).</param>/// <param name="page">Access an additional &#39;page&#39; of data when necessary, based on the &#39;paginationToken&#39; returned from a previous invocation. (optional)</param>
        /// <returns>Task of ApiResponse<Page&lt;int&gt;></returns>

        public async System.Threading.Tasks.Task <ApiResponse <Page <int> > > GetActivityVersionsAsync(string id, string page = null, string scopes = null, IDictionary <string, string> headers = null, bool throwOnError = true)
        {
            using (var request = new HttpRequestMessage())
            {
                request.RequestUri =
                    Marshalling.BuildRequestUri("/v3/activities/{id}/versions",
                                                routeParameters: new Dictionary <string, object> {
                    { "id", id },
                },
                                                queryParameters: new Dictionary <string, object> {
                    { "page", page },
                }
                                                );

                request.Headers.TryAddWithoutValidation("Accept", "application/json");
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        request.Headers.TryAddWithoutValidation(header.Key, header.Value);
                    }
                }


                // tell the underlying pipeline what scope we'd like to use
                if (scopes == null)
                {
                    request.Options.Set(ForgeConfiguration.ScopeKey, "code:all");
                }
                else
                {
                    request.Options.Set(ForgeConfiguration.ScopeKey, scopes);
                }

                request.Method = new HttpMethod("GET");

                // make the HTTP request
                var response = await this.Service.Client.SendAsync(request);

                if (throwOnError)
                {
                    await response.EnsureSuccessStatusCodeAsync();
                }
                else if (!response.IsSuccessStatusCode)
                {
                    return(new ApiResponse <Page <int> >(response, default(Page <int>)));
                }

                return(new ApiResponse <Page <int> >(response, await Marshalling.DeserializeAsync <Page <int> >(response.Content)));
            } // using
        }
        /// <summary>
        /// Creates a new service limits configuration or updates an exiting one.
        /// </summary>
        /// <remarks>
        /// User can only update the following 2 properties:                - frontendLimits.limitMonthlyProcessingTimeInHours  - backendLimits[/engine/].limitProcessingTimeSec                LimitProcessingTimeSec cannot be set greater than the maximum processing time limit specified by the engine.
        /// </remarks>
        /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception>
        /// <param name="owner">The user to associate the configuration to.</param>/// <param name="item"></param>
        /// <returns>Task of ApiResponse<ServiceLimit></returns>

        public async System.Threading.Tasks.Task <ApiResponse <ServiceLimit> > ModifyServiceLimitsAsync(string owner, ServiceLimit item, string scopes = null, IDictionary <string, string> headers = null, bool throwOnError = true)
        {
            using (var request = new HttpRequestMessage())
            {
                request.RequestUri =
                    Marshalling.BuildRequestUri("/v3/servicelimits/{owner}",
                                                routeParameters: new Dictionary <string, object> {
                    { "owner", owner },
                },
                                                queryParameters: new Dictionary <string, object> {
                }
                                                );

                request.Headers.TryAddWithoutValidation("Accept", "application/json");
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        request.Headers.TryAddWithoutValidation(header.Key, header.Value);
                    }
                }

                request.Content = Marshalling.Serialize(item); // http body (model) parameter

                // tell the underlying pipeline what scope we'd like to use
                if (scopes == null)
                {
                    request.Options.Set(ForgeConfiguration.ScopeKey, "code:all");
                }
                else
                {
                    request.Options.Set(ForgeConfiguration.ScopeKey, scopes);
                }

                request.Method = new HttpMethod("PUT");

                // make the HTTP request
                var response = await this.Service.Client.SendAsync(request);

                if (throwOnError)
                {
                    await response.EnsureSuccessStatusCodeAsync();
                }
                else if (!response.IsSuccessStatusCode)
                {
                    return(new ApiResponse <ServiceLimit>(response, default(ServiceLimit)));
                }

                return(new ApiResponse <ServiceLimit>(response, await Marshalling.DeserializeAsync <ServiceLimit>(response.Content)));
            } // using
        }
Пример #4
0
        /// <summary>
        /// Creates new WorkItems and queues them for processing.
        /// </summary>
        /// <remarks>
        /// The new WorkItems are always placed on the queue and later picked up by an engine.                The following limits apply:                Per-engine. These limits are enforced when the engine processes the workitem.                1. Number of downloads (LimitDownloads)  2. Number of uploads (LimitUploads)  3. Total download size (LimitDownloadSize)  4. Total upload size (LimitUploadSize)  5. Processing time (LimitProcessingTime)  6. Total size of uncompressed bits for all referenced appbundles (LimitTotalUncompressedAppsSizePerActivity).                Service wide. These limits are enforced during workitem submission.                7. Total processing time per month (LimitMonthlyProcessingTimeInHours).
        /// </remarks>
        /// <exception cref="HttpRequestException">Thrown when fails to make API call</exception>
        /// <param name="workItems"></param>
        /// <returns>Task of ApiResponse<List&lt;WorkItemStatus&gt;></returns>

        public async System.Threading.Tasks.Task <ApiResponse <List <WorkItemStatus> > > CreateWorkItemsBatchAsync(List <WorkItem> workItems, string scopes = null, IDictionary <string, string> headers = null, bool throwOnError = true)
        {
            using (var request = new HttpRequestMessage())
            {
                request.RequestUri =
                    Marshalling.BuildRequestUri("/v3/workitems/batch",
                                                routeParameters: new Dictionary <string, object> {
                },
                                                queryParameters: new Dictionary <string, object> {
                }
                                                );

                request.Headers.TryAddWithoutValidation("Accept", "application/json");
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        request.Headers.TryAddWithoutValidation(header.Key, header.Value);
                    }
                }

                request.Content = Marshalling.Serialize(workItems); // http body (model) parameter

                // tell the underlying pipeline what scope we'd like to use
                if (scopes == null)
                {
                    request.Properties.Add(ForgeConfiguration.ScopeKey, "code:all");
                }
                else
                {
                    request.Properties.Add(ForgeConfiguration.ScopeKey, scopes);
                }

                request.Method = new HttpMethod("POST");

                // make the HTTP request
                var response = await this.Service.Client.SendAsync(request);

                if (throwOnError)
                {
                    await response.EnsureSuccessStatusCodeAsync();
                }
                else if (!response.IsSuccessStatusCode)
                {
                    return(new ApiResponse <List <WorkItemStatus> >(response, default(List <WorkItemStatus>)));
                }

                return(new ApiResponse <List <WorkItemStatus> >(response, await Marshalling.DeserializeAsync <List <WorkItemStatus> >(response.Content)));
            } // using
        }
Пример #5
0
 public async void TestDeserializeNullInvalid()
 {
     await Assert.ThrowsAsync <Newtonsoft.Json.JsonSerializationException>(() => Marshalling.DeserializeAsync <int>(new StringContent("null", Encoding.UTF8, "application/json")));
 }
Пример #6
0
        public async void TestDeserializeNull()
        {
            var ret = await Marshalling.DeserializeAsync <string>(new StringContent("null", Encoding.UTF8, "application/json"));

            Assert.Null(ret);
        }
Пример #7
0
        public async void TestDeserializeValidString()
        {
            var ret = await Marshalling.DeserializeAsync <string>(new StringContent("\"bla\"", Encoding.UTF8, "application/json"));

            Assert.Equal("bla", ret);
        }
Пример #8
0
 public async void TestDeserializeNonJsonThrows()
 {
     await Assert.ThrowsAsync <ArgumentException>(() => Marshalling.DeserializeAsync <string>(new ByteArrayContent(new byte[] { 0, 2, 3 })));
 }
Пример #9
0
 public async void TestDeserializeThrowsOnNull()
 {
     await Assert.ThrowsAsync <ArgumentNullException>(() => Marshalling.DeserializeAsync <string>(null));
 }