/// <summary> /// Updating a Service Plan /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/service_plans/updating_a_service_plan.html"</para> /// </summary> public async Task <UpdateServicePlanResponse> UpdateServicePlan(UpdateServicePlanRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = "/v2/service_plans"; 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 = 201; var response = await this.SendAsync(client, expectedReturnStatus); return(Utilities.DeserializeJson <UpdateServicePlanResponse>(await response.ReadContentAsStringAsync())); }
public void UpdateServicePlanTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""078b2ddc-6834-4282-bbef-172a9fef10d8"", ""url"": ""/v2/service_plans/b493aa60-723e-4bed-813e-4b86fc9ae1ca"", ""created_at"": ""2016-09-02T11:52:11Z"", ""updated_at"": ""2016-09-02T11:52:11Z"" }, ""entity"": { ""name"": ""name-837"", ""free"": false, ""description"": ""desc-125"", ""service_guid"": ""078b2ddc-6834-4282-bbef-172a9fef10d8"", ""extra"": null, ""unique_id"": ""2df607f1-6fbd-4e0f-b2c8-1a443317c270"", ""public"": false, ""active"": true, ""service_url"": ""/v2/services/5678b4eb-ce85-4082-852c-922fdb81066e"", ""service_instances_url"": ""/v2/service_plans/b493aa60-723e-4bed-813e-4b86fc9ae1ca/service_instances"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); UpdateServicePlanRequest value = new UpdateServicePlanRequest(); var obj = cfClient.ServicePlans.UpdateServicePlan(value).Result; Assert.AreEqual("078b2ddc-6834-4282-bbef-172a9fef10d8", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/service_plans/b493aa60-723e-4bed-813e-4b86fc9ae1ca", TestUtil.ToTestableString(obj.EntityMetadata.Url), true); Assert.AreEqual("2016-09-02T11:52:11Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true); Assert.AreEqual("2016-09-02T11:52:11Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true); Assert.AreEqual("name-837", TestUtil.ToTestableString(obj.Name), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Free), true); Assert.AreEqual("desc-125", TestUtil.ToTestableString(obj.Description), true); Assert.AreEqual("078b2ddc-6834-4282-bbef-172a9fef10d8", TestUtil.ToTestableString(obj.ServiceGuid), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true); Assert.AreEqual("2df607f1-6fbd-4e0f-b2c8-1a443317c270", TestUtil.ToTestableString(obj.UniqueId), true); Assert.AreEqual("false", TestUtil.ToTestableString(obj.Public), true); Assert.AreEqual("true", TestUtil.ToTestableString(obj.Active), true); Assert.AreEqual("/v2/services/5678b4eb-ce85-4082-852c-922fdb81066e", TestUtil.ToTestableString(obj.ServiceUrl), true); Assert.AreEqual("/v2/service_plans/b493aa60-723e-4bed-813e-4b86fc9ae1ca/service_instances", TestUtil.ToTestableString(obj.ServiceInstancesUrl), true); } }
public void TestUpdateServicePlanRequest() { string json = @"{ ""public"": false }"; UpdateServicePlanRequest request = new UpdateServicePlanRequest(); request.Public = false; string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
/// <summary> /// Updating a Service Plan /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/service_plans/updating_a_service_plan.html"</para> /// </summary> public async Task <UpdateServicePlanResponse> UpdateServicePlan(UpdateServicePlanRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = "/v2/service_plans"; var client = this.GetHttpClient(); client.Uri = uriBuilder.Uri; client.Method = HttpMethod.Put; client.Content = ((string)JsonConvert.SerializeObject(value)).ConvertToStream(); var expectedReturnStatus = 201; var response = await this.SendAsync(client, expectedReturnStatus); return(Utilities.DeserializeJson <UpdateServicePlanResponse>(await response.Content.ReadAsStringAsync())); }