public void ScalingProcessFromItsAppTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""guid"": ""411e7812-0bb0-4bd5-90da-4d7130600991"",
  ""type"": ""web"",
  ""command"": null,
  ""instances"": 3,
  ""memory_in_mb"": 100,
  ""disk_in_mb"": 100,
  ""created_at"": ""2016-07-07T09:16:54Z"",
  ""updated_at"": ""2016-07-07T09:16:54Z"",
  ""links"": {
    ""self"": {
      ""href"": ""/v3/processes/b351ca84-1200-4e61-b874-e70da56ed290""
    },
    ""scale"": {
      ""href"": ""/v3/processes/b351ca84-1200-4e61-b874-e70da56ed290/scale"",
      ""method"": ""PUT""
    },
    ""app"": {
      ""href"": ""/v3/apps/ceaa2858-3862-47bd-bb87-e7da706e4e41""
    },
    ""space"": {
      ""href"": ""/v2/spaces/885b573a-1ca9-4b30-89d7-c3a5fbff76bc""
    }
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();

                dynamic type = null;

                ScalingProcessFromItsAppRequest value = new ScalingProcessFromItsAppRequest();


                var obj = cfClient.AppsExperimental.ScalingProcessFromItsApp(guid, type, value).Result;


                Assert.AreEqual("411e7812-0bb0-4bd5-90da-4d7130600991", 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:16:54Z", TestUtil.ToTestableString(obj.CreatedAt), true);
                Assert.AreEqual("2016-07-07T09:16:54Z", TestUtil.ToTestableString(obj.UpdatedAt), true);
            }
        }
示例#2
0
        public void ScalingProcessFromItsAppTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""guid"": ""95b39415-3a5b-42c9-85b8-55cd57a411bf"",
  ""type"": ""web"",
  ""command"": null,
  ""instances"": 3,
  ""created_at"": ""2015-06-30T07:10:28Z"",
  ""updated_at"": ""2015-06-30T07:10:28Z"",
  ""_links"": {
    ""self"": {
      ""href"": ""/v3/processes/95b39415-3a5b-42c9-85b8-55cd57a411bf""
    },
    ""scale"": {
      ""href"": ""/v3/processes/95b39415-3a5b-42c9-85b8-55cd57a411bf/scale"",
      ""method"": ""PUT""
    },
    ""app"": {
      ""href"": ""/v3/apps/guid-7d529d90-3be5-4c59-951e-b9316dd6ff52""
    },
    ""space"": {
      ""href"": ""/v2/spaces/5797a986-1ac3-41a0-860d-d35034f47d6e""
    }
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)200;
                var cfClient = clients.CreateCloudFoundryClient();

                Guid?guid = Guid.NewGuid();

                dynamic type = null;

                ScalingProcessFromItsAppRequest value = new ScalingProcessFromItsAppRequest();


                var obj = cfClient.Apps.ScalingProcessFromItsApp(guid, type, value).Result;


                Assert.AreEqual("95b39415-3a5b-42c9-85b8-55cd57a411bf", 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:28Z", TestUtil.ToTestableString(obj.CreatedAt), true);
                Assert.AreEqual("2015-06-30T07:10:28Z", TestUtil.ToTestableString(obj.UpdatedAt), true);
            }
        }
示例#3
0
        public void TestScalingProcessFromItsAppRequest()
        {
            string json = @"{
  ""instances"": 3
}";

            ScalingProcessFromItsAppRequest request = new ScalingProcessFromItsAppRequest();

            request.Instances = 3;
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void TestScalingProcessFromItsAppRequest()
        {
            string json = @"{
  ""instances"": 3,
  ""memory_in_mb"": 100,
  ""disk_in_mb"": 100
}";

            ScalingProcessFromItsAppRequest request = new ScalingProcessFromItsAppRequest();

            request.Instances  = 3;
            request.MemoryInMb = 100;
            request.DiskInMb   = 100;
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
示例#5
0
        /// <summary>
        /// Scaling a Process from its App
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/apps__experimental_/scaling_a_process_from_its_app.html"</para>
        /// </summary>
        public async Task <ScalingProcessFromItsAppResponse> ScalingProcessFromItsApp(Guid?guid, dynamic type, ScalingProcessFromItsAppRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v3/apps/{0}/processes/{1}/scale", guid, type);
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Put;
            var authHeader = await BuildAuthenticationHeader();

            if (!string.IsNullOrWhiteSpace(authHeader.Key))
            {
                client.Headers.Add(authHeader);
            }
            client.ContentType = "application/x-www-form-urlencoded";
            client.Content     = JsonConvert.SerializeObject(value).ConvertToStream();
            var expectedReturnStatus = 200;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <ScalingProcessFromItsAppResponse>(await response.ReadContentAsStringAsync()));
        }
        /// <summary>
        /// Scaling a Process from its App
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/238/apps__experimental_/scaling_a_process_from_its_app.html"</para>
        /// </summary>
        public async Task <ScalingProcessFromItsAppResponse> ScalingProcessFromItsApp(Guid?guid, dynamic type, ScalingProcessFromItsAppRequest value)
        {
            var response = await this.GetNewHttpClient().PutAsync($"/v3/apps/{guid}/processes/{type}/scale");

            return(JsonConvert.DeserializeObject <ScalingProcessFromItsAppResponse>(await response.Content.ReadAsStringAsync()));
        }