public void TestRetrieveServiceInstanceResponse() { string json = @"{ ""metadata"": { ""guid"": ""d9b47622-1b8c-43f8-9171-6b1be3bd51c9"", ""url"": ""/v2/service_instances/362d8994-8573-406b-9597-152e497fd531"", ""created_at"": ""2016-09-02T11:52:08Z"", ""updated_at"": null }, ""entity"": { ""name"": ""name-679"", ""credentials"": { ""creds-key-17"": ""creds-val-17"" }, ""service_plan_guid"": ""d9b47622-1b8c-43f8-9171-6b1be3bd51c9"", ""space_guid"": ""d9b47622-1b8c-43f8-9171-6b1be3bd51c9"", ""gateway_data"": null, ""dashboard_url"": null, ""type"": ""managed_service_instance"", ""last_operation"": { ""type"": ""create"", ""state"": ""succeeded"", ""description"": ""service broker-provided description"", ""updated_at"": ""2016-09-02T11:52:08Z"", ""created_at"": ""2016-09-02T11:52:08Z"" }, ""tags"": [ ""accounting"", ""mongodb"" ], ""space_url"": ""/v2/spaces/84d8a4da-1b4d-42c1-a5ff-804791af0a26"", ""service_plan_url"": ""/v2/service_plans/ee9074df-d664-4824-880a-ffbb327dab99"", ""service_bindings_url"": ""/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/service_bindings"", ""service_keys_url"": ""/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/service_keys"", ""routes_url"": ""/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/routes"" } }"; RetrieveServiceInstanceResponse obj = Utilities.DeserializeJson <RetrieveServiceInstanceResponse>(json); Assert.AreEqual("d9b47622-1b8c-43f8-9171-6b1be3bd51c9", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/service_instances/362d8994-8573-406b-9597-152e497fd531", TestUtil.ToTestableString(obj.EntityMetadata.Url), true); Assert.AreEqual("2016-09-02T11:52:08Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true); Assert.AreEqual("name-679", TestUtil.ToTestableString(obj.Name), true); Assert.AreEqual("d9b47622-1b8c-43f8-9171-6b1be3bd51c9", TestUtil.ToTestableString(obj.ServicePlanGuid), true); Assert.AreEqual("d9b47622-1b8c-43f8-9171-6b1be3bd51c9", TestUtil.ToTestableString(obj.SpaceGuid), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.GatewayData), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.DashboardUrl), true); Assert.AreEqual("managed_service_instance", TestUtil.ToTestableString(obj.Type), true); Assert.AreEqual("/v2/spaces/84d8a4da-1b4d-42c1-a5ff-804791af0a26", TestUtil.ToTestableString(obj.SpaceUrl), true); Assert.AreEqual("/v2/service_plans/ee9074df-d664-4824-880a-ffbb327dab99", TestUtil.ToTestableString(obj.ServicePlanUrl), true); Assert.AreEqual("/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/service_bindings", TestUtil.ToTestableString(obj.ServiceBindingsUrl), true); Assert.AreEqual("/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/service_keys", TestUtil.ToTestableString(obj.ServiceKeysUrl), true); Assert.AreEqual("/v2/service_instances/362d8994-8573-406b-9597-152e497fd531/routes", TestUtil.ToTestableString(obj.RoutesUrl), true); }
public void TestRetrieveServiceInstanceResponse() { string json = @"{ ""metadata"": { ""guid"": ""32e29b45-a238-4100-bb8f-5a8c12fec7fc"", ""url"": ""/v2/service_instances/32e29b45-a238-4100-bb8f-5a8c12fec7fc"", ""created_at"": ""2016-02-09T10:21:51Z"", ""updated_at"": null }, ""entity"": { ""name"": ""name-1677"", ""credentials"": { ""creds-key-389"": ""creds-val-389"" }, ""service_plan_guid"": ""1cb93f78-6ada-494a-b494-73ba4ca847b8"", ""space_guid"": ""503a1f4c-d596-4b70-9034-88d37b001687"", ""gateway_data"": null, ""dashboard_url"": null, ""type"": ""managed_service_instance"", ""last_operation"": { ""type"": ""create"", ""state"": ""succeeded"", ""description"": ""service broker-provided description"", ""updated_at"": ""2016-02-09T10:21:51Z"" }, ""space_url"": ""/v2/spaces/503a1f4c-d596-4b70-9034-88d37b001687"", ""service_plan_url"": ""/v2/service_plans/1cb93f78-6ada-494a-b494-73ba4ca847b8"", ""service_bindings_url"": ""/v2/service_instances/32e29b45-a238-4100-bb8f-5a8c12fec7fc/service_bindings"" } }"; RetrieveServiceInstanceResponse obj = Utilities.DeserializeJson <RetrieveServiceInstanceResponse>(json); Assert.AreEqual("32e29b45-a238-4100-bb8f-5a8c12fec7fc", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/service_instances/32e29b45-a238-4100-bb8f-5a8c12fec7fc", TestUtil.ToTestableString(obj.EntityMetadata.Url), true); Assert.AreEqual("2016-02-09T10:21:51Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true); Assert.AreEqual("name-1677", TestUtil.ToTestableString(obj.Name), true); Assert.AreEqual("1cb93f78-6ada-494a-b494-73ba4ca847b8", TestUtil.ToTestableString(obj.ServicePlanGuid), true); Assert.AreEqual("503a1f4c-d596-4b70-9034-88d37b001687", TestUtil.ToTestableString(obj.SpaceGuid), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.GatewayData), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.DashboardUrl), true); Assert.AreEqual("managed_service_instance", TestUtil.ToTestableString(obj.Type), true); Assert.AreEqual("/v2/spaces/503a1f4c-d596-4b70-9034-88d37b001687", TestUtil.ToTestableString(obj.SpaceUrl), true); Assert.AreEqual("/v2/service_plans/1cb93f78-6ada-494a-b494-73ba4ca847b8", TestUtil.ToTestableString(obj.ServicePlanUrl), true); Assert.AreEqual("/v2/service_instances/32e29b45-a238-4100-bb8f-5a8c12fec7fc/service_bindings", TestUtil.ToTestableString(obj.ServiceBindingsUrl), true); }
public void TestRetrieveServiceInstanceResponse() { string json = @"{ ""metadata"": { ""guid"": ""793f6e72-2f3d-45a5-b2c6-c32fc800b4b8"", ""url"": ""/v2/service_instances/793f6e72-2f3d-45a5-b2c6-c32fc800b4b8"", ""created_at"": ""2015-04-16T12:04:31+00:00"", ""updated_at"": null }, ""entity"": { ""name"": ""name-1436"", ""credentials"": { ""creds-key-472"": ""creds-val-472"" }, ""service_plan_guid"": ""10231b18-66aa-4572-8ff7-53e4b9357518"", ""space_guid"": ""546a3a36-2695-41ab-94b3-ff14132e96c3"", ""gateway_data"": null, ""dashboard_url"": null, ""type"": ""managed_service_instance"", ""space_url"": ""/v2/spaces/546a3a36-2695-41ab-94b3-ff14132e96c3"", ""service_plan_url"": ""/v2/service_plans/10231b18-66aa-4572-8ff7-53e4b9357518"", ""service_bindings_url"": ""/v2/service_instances/793f6e72-2f3d-45a5-b2c6-c32fc800b4b8/service_bindings"" } }"; RetrieveServiceInstanceResponse obj = Utilities.DeserializeJson <RetrieveServiceInstanceResponse>(json); Assert.AreEqual("793f6e72-2f3d-45a5-b2c6-c32fc800b4b8", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("/v2/service_instances/793f6e72-2f3d-45a5-b2c6-c32fc800b4b8", TestUtil.ToTestableString(obj.EntityMetadata.Url), true); Assert.AreEqual("2015-04-16T12:04:31+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true); Assert.AreEqual("name-1436", TestUtil.ToTestableString(obj.Name), true); Assert.AreEqual("10231b18-66aa-4572-8ff7-53e4b9357518", TestUtil.ToTestableString(obj.ServicePlanGuid), true); Assert.AreEqual("546a3a36-2695-41ab-94b3-ff14132e96c3", TestUtil.ToTestableString(obj.SpaceGuid), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.GatewayData), true); Assert.AreEqual("", TestUtil.ToTestableString(obj.DashboardUrl), true); Assert.AreEqual("managed_service_instance", TestUtil.ToTestableString(obj.Type), true); Assert.AreEqual("/v2/spaces/546a3a36-2695-41ab-94b3-ff14132e96c3", TestUtil.ToTestableString(obj.SpaceUrl), true); Assert.AreEqual("/v2/service_plans/10231b18-66aa-4572-8ff7-53e4b9357518", TestUtil.ToTestableString(obj.ServicePlanUrl), true); Assert.AreEqual("/v2/service_instances/793f6e72-2f3d-45a5-b2c6-c32fc800b4b8/service_bindings", TestUtil.ToTestableString(obj.ServiceBindingsUrl), true); }
public void ServiceInstance_test() { var services = client.Services.ListAllServices().Result; if (services.FirstOrDefault(s => s.Label == "mysql") == null) { Assert.Inconclusive("Cloud Foundry target does not support mysql services"); } Guid serviceGuid = services.FirstOrDefault(s => s.Label == "mysql").EntityMetadata.Guid; var plans = client.Services.ListAllServicePlansForService(serviceGuid).Result; Guid servicePlanGuid = plans.FirstOrDefault().EntityMetadata.Guid; CreateServiceInstanceResponse newService = null; RetrieveServiceInstanceResponse readService = null; UpdateServiceInstanceResponse updatedService = null; CreateServiceInstanceRequest createService = new CreateServiceInstanceRequest(); createService.SpaceGuid = spaceGuid; createService.Name = "svc" + Guid.NewGuid().ToString().Substring(0, 3); createService.ServicePlanGuid = servicePlanGuid; try { newService = client.ServiceInstances.CreateServiceInstance(createService).Result; } catch (Exception ex) { Assert.Fail("Exception while creating service instance: {0}", ex.ToString()); } Assert.IsNotNull(newService); Assert.AreEqual(createService.Name, newService.Name); try { readService = client.ServiceInstances.RetrieveServiceInstance(newService.EntityMetadata.Guid).Result; } catch (Exception ex) { Assert.Fail("Exception while reading service instance: {0}", ex.ToString()); } UpdateServiceInstanceRequest updateService = new UpdateServiceInstanceRequest(); updateService.Name = "svc" + Guid.NewGuid().ToString().Substring(0, 3); try { updatedService = client.ServiceInstances.UpdateServiceInstance(newService.EntityMetadata.Guid, updateService).Result; } catch (Exception ex) { Assert.Fail("Exception while updating service instance: {0}", ex.ToString()); } Assert.IsNotNull(updatedService); Assert.AreEqual(updateService.Name, updatedService.Name); try { client.ServiceInstances.DeleteServiceInstance(newService.EntityMetadata.Guid).Wait(); } catch (Exception ex) { Assert.Fail("Exception while deleting service instance: {0}", ex.ToString()); } }