Пример #1
0
        /// <summary>
        /// Creating a Service (deprecated)
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/services/creating_a_service_(deprecated).html"</para>
        /// </summary>
        public async Task <CreateServiceDeprecatedResponse> CreateServiceDeprecated(CreateServiceDeprecatedRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = "/v2/services";
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Post;
            client.Headers.Add(await BuildAuthenticationHeader());
            client.ContentType = "application/x-www-form-urlencoded";
            client.Content     = JsonConvert.SerializeObject(value).ConvertToStream();
            var expectedReturnStatus = 201;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <CreateServiceDeprecatedResponse>(await response.ReadContentAsStringAsync()));
        }
Пример #2
0
        public void TestCreateServiceDeprecatedRequest()
        {
            string json = @"{
  ""label"": ""SomeMysqlService"",
  ""description"": ""Mysql stores things for you"",
  ""provider"": ""MySql Provider"",
  ""version"": ""2.0"",
  ""url"": ""http://myql.provider.com""
}";

            CreateServiceDeprecatedRequest request = new CreateServiceDeprecatedRequest();

            request.Label = "SomeMysqlService";
            request.Description = "Mysql stores things for you";
            request.Provider = "MySql Provider";
            request.Version = "2.0";
            request.Url = "http://myql.provider.com";
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Пример #3
0
        public void TestCreateServiceDeprecatedRequest()
        {
            string json = @"{
  ""label"": ""SomeMysqlService"",
  ""description"": ""Mysql stores things for you"",
  ""provider"": ""MySql Provider"",
  ""version"": ""2.0"",
  ""url"": ""http://myql.provider.com""
}";

            CreateServiceDeprecatedRequest request = new CreateServiceDeprecatedRequest();

            request.Label       = "SomeMysqlService";
            request.Description = "Mysql stores things for you";
            request.Provider    = "MySql Provider";
            request.Version     = "2.0";
            request.Url         = "http://myql.provider.com";
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Пример #4
0
        public void CreateServiceDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""b876f258-f75d-4e6e-b0bc-5554e233b669"",
    ""url"": ""/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669"",
    ""created_at"": ""2016-02-09T10:21:55Z"",
    ""updated_at"": null
  },
  ""entity"": {
    ""label"": ""SomeMysqlService"",
    ""provider"": ""MySql Provider"",
    ""url"": ""http://myql.provider.com"",
    ""description"": ""Mysql stores things for you"",
    ""long_description"": null,
    ""version"": ""2.0"",
    ""info_url"": null,
    ""active"": false,
    ""bindable"": true,
    ""unique_id"": null,
    ""extra"": null,
    ""tags"": [

    ],
    ""requires"": [

    ],
    ""documentation_url"": null,
    ""service_broker_guid"": null,
    ""plan_updateable"": false,
    ""service_plans_url"": ""/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669/service_plans""
  }
}";
                clients.JsonResponse = json;

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

                CreateServiceDeprecatedRequest value = new CreateServiceDeprecatedRequest();


                var obj = cfClient.Services.CreateServiceDeprecated(value).Result;


                Assert.AreEqual("b876f258-f75d-4e6e-b0bc-5554e233b669", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:55Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("SomeMysqlService", TestUtil.ToTestableString(obj.Label), true);
                Assert.AreEqual("MySql Provider", TestUtil.ToTestableString(obj.Provider), true);
                Assert.AreEqual("http://myql.provider.com", TestUtil.ToTestableString(obj.Url), true);
                Assert.AreEqual("Mysql stores things for you", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.LongDescription), true);
                Assert.AreEqual("2.0", TestUtil.ToTestableString(obj.Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.InfoUrl), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Bindable), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.DocumentationUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.PlanUpdateable), true);
                Assert.AreEqual("/v2/services/b876f258-f75d-4e6e-b0bc-5554e233b669/service_plans", TestUtil.ToTestableString(obj.ServicePlansUrl), true);
            }
        }
Пример #5
0
 /// <summary>
 /// Creating a Service (deprecated)
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/services/creating_a_service_(deprecated).html"</para>
 /// </summary>
 public async Task<CreateServiceDeprecatedResponse> CreateServiceDeprecated(CreateServiceDeprecatedRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = "/v2/services";
     var client = this.GetHttpClient();
     client.Uri = uriBuilder.Uri;
     client.Method = HttpMethod.Post;
     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 = 201;
     var response = await this.SendAsync(client, expectedReturnStatus);
     return Utilities.DeserializeJson<CreateServiceDeprecatedResponse>(await response.ReadContentAsStringAsync());
 }
Пример #6
0
        public void CreateServiceDeprecatedTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""7d280557-ae2d-45cc-bc50-54b681b56ea4"",
    ""url"": ""/v2/services/7d280557-ae2d-45cc-bc50-54b681b56ea4"",
    ""created_at"": ""2015-05-19T15:27:18+00:00"",
    ""updated_at"": null
  },
  ""entity"": {
    ""label"": ""SomeMysqlService"",
    ""provider"": ""MySql Provider"",
    ""url"": ""http://myql.provider.com"",
    ""description"": ""Mysql stores things for you"",
    ""long_description"": null,
    ""version"": ""2.0"",
    ""info_url"": null,
    ""active"": false,
    ""bindable"": true,
    ""unique_id"": null,
    ""extra"": null,
    ""tags"": [

    ],
    ""requires"": [

    ],
    ""documentation_url"": null,
    ""service_broker_guid"": null,
    ""plan_updateable"": false,
    ""service_plans_url"": ""/v2/services/7d280557-ae2d-45cc-bc50-54b681b56ea4/service_plans""
  }
}";
                clients.JsonResponse = json;

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

                CreateServiceDeprecatedRequest value = new CreateServiceDeprecatedRequest();


                var obj = cfClient.Services.CreateServiceDeprecated(value).Result;


                Assert.AreEqual("7d280557-ae2d-45cc-bc50-54b681b56ea4", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/services/7d280557-ae2d-45cc-bc50-54b681b56ea4", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-05-19T15:27:18+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("SomeMysqlService", TestUtil.ToTestableString(obj.Label), true);
                Assert.AreEqual("MySql Provider", TestUtil.ToTestableString(obj.Provider), true);
                Assert.AreEqual("http://myql.provider.com", TestUtil.ToTestableString(obj.Url), true);
                Assert.AreEqual("Mysql stores things for you", TestUtil.ToTestableString(obj.Description), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.LongDescription), true);
                Assert.AreEqual("2.0", TestUtil.ToTestableString(obj.Version), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.InfoUrl), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.Active), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Bindable), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.UniqueId), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Extra), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.DocumentationUrl), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.ServiceBrokerGuid), true);
                Assert.AreEqual("false", TestUtil.ToTestableString(obj.PlanUpdateable), true);
                Assert.AreEqual("/v2/services/7d280557-ae2d-45cc-bc50-54b681b56ea4/service_plans", TestUtil.ToTestableString(obj.ServicePlansUrl), true);

            }
        }