/// <summary>
        /// Updating a Process
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/238/processes__experimental_/updating_a_process.html"</para>
        /// </summary>
        public async Task <UpdateProcessResponse> UpdateProcess(Guid?guid, UpdateProcessRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

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

            client.Uri    = uriBuilder.Uri;
            client.Method = new HttpMethod("PATCH");
            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 <UpdateProcessResponse>(await response.ReadContentAsStringAsync()));
        }
Beispiel #2
0
        public void UpdateProcessTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""guid"": ""25e2f097-bf52-4718-83ca-5cbfec2bed17"",
  ""type"": ""web"",
  ""command"": ""X"",
  ""instances"": 1,
  ""memory_in_mb"": 1024,
  ""disk_in_mb"": 1024,
  ""created_at"": ""2016-07-07T09:17:15Z"",
  ""updated_at"": ""2016-07-07T09:17:15Z"",
  ""links"": {
    ""self"": {
      ""href"": ""/v3/processes/5ee885ae-b24d-4b57-a90b-827000fd34e1""
    },
    ""scale"": {
      ""href"": ""/v3/processes/5ee885ae-b24d-4b57-a90b-827000fd34e1/scale"",
      ""method"": ""PUT""
    },
    ""app"": {
      ""href"": ""/v3/apps/""
    },
    ""space"": {
      ""href"": ""/v2/spaces/d6c4f9a8-af31-4960-8ba8-53a059e0fca8""
    }
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                UpdateProcessRequest value = new UpdateProcessRequest();


                var obj = cfClient.ProcessesExperimental.UpdateProcess(guid, value).Result;


                Assert.AreEqual("25e2f097-bf52-4718-83ca-5cbfec2bed17", TestUtil.ToTestableString(obj.Guid), true);
                Assert.AreEqual("web", TestUtil.ToTestableString(obj.Type), true);
                Assert.AreEqual("X", TestUtil.ToTestableString(obj.Command), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Instances), true);
                Assert.AreEqual("1024", TestUtil.ToTestableString(obj.MemoryInMb), true);
                Assert.AreEqual("1024", 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 TestUpdateProcessRequest()
        {
            string json = @"{
  ""command"": ""X""
}";

            UpdateProcessRequest request = new UpdateProcessRequest();

            request.Command = "X";
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Beispiel #4
0
        public void UpdateProcessTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""guid"": ""451b9bf2-2826-4fc1-a2e3-938688a8e438"",
  ""type"": ""web"",
  ""command"": ""X"",
  ""instances"": 1,
  ""created_at"": ""2015-06-30T07:10:40Z"",
  ""updated_at"": ""2015-06-30T07:10:40Z"",
  ""_links"": {
    ""self"": {
      ""href"": ""/v3/processes/451b9bf2-2826-4fc1-a2e3-938688a8e438""
    },
    ""scale"": {
      ""href"": ""/v3/processes/451b9bf2-2826-4fc1-a2e3-938688a8e438/scale"",
      ""method"": ""PUT""
    },
    ""app"": {
      ""href"": ""/v3/apps/""
    },
    ""space"": {
      ""href"": ""/v2/spaces/bc6e3da0-2866-42a5-9edc-540a5a529f8f""
    }
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                UpdateProcessRequest value = new UpdateProcessRequest();


                var obj = cfClient.Processes.UpdateProcess(guid, value).Result;


                Assert.AreEqual("451b9bf2-2826-4fc1-a2e3-938688a8e438", TestUtil.ToTestableString(obj.Guid), true);
                Assert.AreEqual("web", TestUtil.ToTestableString(obj.Type), true);
                Assert.AreEqual("X", TestUtil.ToTestableString(obj.Command), true);
                Assert.AreEqual("1", 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);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Updating a Process
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/238/processes__experimental_/updating_a_process.html"</para>
        /// </summary>
        public async Task <UpdateProcessResponse> UpdateProcess(Guid?guid, UpdateProcessRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

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

            client.Uri    = uriBuilder.Uri;
            client.Method = new HttpMethod("PATCH");


            client.Content = ((string)JsonConvert.SerializeObject(value)).ConvertToStream();
            var expectedReturnStatus = 200;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <UpdateProcessResponse>(await response.Content.ReadAsStringAsync()));
        }