Example #1
0
        public void TestAssociateDeveloperWithSpaceByUsernameRequest()
        {
            string json = @"{
  ""username"": ""*****@*****.**""
}";

            AssociateDeveloperWithSpaceByUsernameRequest request = new AssociateDeveloperWithSpaceByUsernameRequest();

            request.Username = "******";
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Example #2
0
        /// <summary>
        /// Associate Developer with the Space by Username
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/241/spaces/associate_developer_with_the_space_by_username.html"</para>
        /// </summary>
        public async Task <AssociateDeveloperWithSpaceByUsernameResponse> AssociateDeveloperWithSpaceByUsername(Guid?guid, AssociateDeveloperWithSpaceByUsernameRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "v2/spaces/{0}/developers", guid);
            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     = ((string)JsonConvert.SerializeObject(value)).ConvertToStream();
            var expectedReturnStatus = 201;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <AssociateDeveloperWithSpaceByUsernameResponse>(await response.ReadContentAsStringAsync()));
        }
        /// <summary>
        /// Associate Developer with the Space by Username
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/spaces/associate_developer_with_the_space_by_username.html"</para>
        /// </summary>
        public async Task <AssociateDeveloperWithSpaceByUsernameResponse> AssociateDeveloperWithSpaceByUsername(Guid?guid, AssociateDeveloperWithSpaceByUsernameRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "v2/spaces/{0}/developers", guid);
            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 <AssociateDeveloperWithSpaceByUsernameResponse>(await response.Content.ReadAsStringAsync()));
        }