示例#1
0
        public void TestAssociateManagerWithSpaceByUsernameRequest()
        {
            string json = @"{
  ""username"": ""*****@*****.**""
}";

            AssociateManagerWithSpaceByUsernameRequest request = new AssociateManagerWithSpaceByUsernameRequest();

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

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

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "v2/spaces/{0}/managers", 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 <AssociateManagerWithSpaceByUsernameResponse>(await response.ReadContentAsStringAsync()));
        }
        /// <summary>
        /// Associate Manager with the Space by Username
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/spaces/associate_manager_with_the_space_by_username.html"</para>
        /// </summary>
        public async Task <AssociateManagerWithSpaceByUsernameResponse> AssociateManagerWithSpaceByUsername(Guid?guid, AssociateManagerWithSpaceByUsernameRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

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