/// <summary> /// Scaling a Process /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/238/processes__experimental_/scaling_a_process.html"</para> /// </summary> public async Task <ScalingProcessResponse> ScalingProcess(Guid?guid, ScalingProcessRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v3/processes/{0}/actions/scale", guid); var client = this.GetHttpClient(); client.Uri = uriBuilder.Uri; client.Method = HttpMethod.Put; var authHeader = await BuildAuthenticationHeader(); if (!string.IsNullOrWhiteSpace(authHeader.Key)) { if (client.Headers.ContainsKey(authHeader.Key)) { client.Headers[authHeader.Key] = authHeader.Value; } else { client.Headers.Add(authHeader); } } client.ContentType = "application/x-www-form-urlencoded"; client.Content = ((string)JsonConvert.SerializeObject(value)).ConvertToStream(); var expectedReturnStatus = 200; var response = await this.SendAsync(client, expectedReturnStatus); return(Utilities.DeserializeJson <ScalingProcessResponse>(await response.ReadContentAsStringAsync())); }
public void ScalingProcessTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""guid"": ""3cd15332-7b75-4550-adf9-54a7f26b5ff4"", ""type"": ""web"", ""command"": null, ""instances"": 3, ""memory_in_mb"": 100, ""disk_in_mb"": 100, ""created_at"": ""2016-07-07T09:17:15Z"", ""updated_at"": ""2016-07-07T09:17:15Z"", ""links"": { ""self"": { ""href"": ""/v3/processes/db4a1298-c1f9-421d-8703-039cef4d069a"" }, ""scale"": { ""href"": ""/v3/processes/db4a1298-c1f9-421d-8703-039cef4d069a/scale"", ""method"": ""PUT"" }, ""app"": { ""href"": ""/v3/apps/a56861c2-c2fc-43d1-aead-e496456e121e"" }, ""space"": { ""href"": ""/v2/spaces/5e5296b1-11dd-4ce3-a566-87709cda4d12"" } } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)200; var cfClient = clients.CreateCloudFoundryClient(); Guid?guid = Guid.NewGuid(); ScalingProcessRequest value = new ScalingProcessRequest(); var obj = cfClient.ProcessesExperimental.ScalingProcess(guid, value).Result; Assert.AreEqual("3cd15332-7b75-4550-adf9-54a7f26b5ff4", TestUtil.ToTestableString(obj.Guid), true); Assert.AreEqual("web", TestUtil.ToTestableString(obj.Type), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.Command), true); Assert.AreEqual("3", TestUtil.ToTestableString(obj.Instances), true); Assert.AreEqual("100", TestUtil.ToTestableString(obj.MemoryInMb), true); Assert.AreEqual("100", TestUtil.ToTestableString(obj.DiskInMb), true); Assert.AreEqual("2016-07-07T09:17:15Z", TestUtil.ToTestableString(obj.CreatedAt), true); Assert.AreEqual("2016-07-07T09:17:15Z", TestUtil.ToTestableString(obj.UpdatedAt), true); } }
public void TestScalingProcessRequest() { string json = @"{ ""instances"": 3 }"; ScalingProcessRequest request = new ScalingProcessRequest(); request.Instances = 3; string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
public void ScalingProcessTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""guid"": ""a695bdf5-3d91-40cd-affa-9cd12ec6fe16"", ""type"": ""web"", ""command"": null, ""instances"": 3, ""created_at"": ""2015-06-30T07:10:40Z"", ""updated_at"": ""2015-06-30T07:10:40Z"", ""_links"": { ""self"": { ""href"": ""/v3/processes/a695bdf5-3d91-40cd-affa-9cd12ec6fe16"" }, ""scale"": { ""href"": ""/v3/processes/a695bdf5-3d91-40cd-affa-9cd12ec6fe16/scale"", ""method"": ""PUT"" }, ""app"": { ""href"": ""/v3/apps/guid-cdf7a2a8-b9ab-48ef-b883-16fb951fcb1e"" }, ""space"": { ""href"": ""/v2/spaces/8c9e2409-f75e-45a8-823d-4ee9726b6f21"" } } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)200; var cfClient = clients.CreateCloudFoundryClient(); Guid?guid = Guid.NewGuid(); ScalingProcessRequest value = new ScalingProcessRequest(); var obj = cfClient.Processes.ScalingProcess(guid, value).Result; Assert.AreEqual("a695bdf5-3d91-40cd-affa-9cd12ec6fe16", TestUtil.ToTestableString(obj.Guid), true); Assert.AreEqual("web", TestUtil.ToTestableString(obj.Type), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.Command), true); Assert.AreEqual("3", TestUtil.ToTestableString(obj.Instances), true); Assert.AreEqual("2015-06-30T07:10:40Z", TestUtil.ToTestableString(obj.CreatedAt), true); Assert.AreEqual("2015-06-30T07:10:40Z", TestUtil.ToTestableString(obj.UpdatedAt), true); } }
/// <summary> /// Scaling a Process /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/238/processes__experimental_/scaling_a_process.html"</para> /// </summary> public async Task <ScalingProcessResponse> ScalingProcess(Guid?guid, ScalingProcessRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v3/processes/{0}/scale", guid); var client = this.GetHttpClient(); client.Uri = uriBuilder.Uri; client.Method = HttpMethod.Put; var expectedReturnStatus = 200; var response = await this.SendAsync(client, expectedReturnStatus, new StringContent(JsonConvert.SerializeObject(value), Encoding.UTF8, "application/json")); return(Utilities.DeserializeJson <ScalingProcessResponse>(await response.Content.ReadAsStringAsync())); }
public void TestScalingProcessRequest() { string json = @"{ ""instances"": 3, ""memory_in_mb"": 100, ""disk_in_mb"": 100 }"; ScalingProcessRequest request = new ScalingProcessRequest(); request.Instances = 3; request.MemoryInMb = 100; request.DiskInMb = 100; string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }