public void TestAssociateAuditorWithSpaceByUsernameRequest()
        {
            string json = @"{
  ""username"": ""*****@*****.**""
}";

            AssociateAuditorWithSpaceByUsernameRequest request = new AssociateAuditorWithSpaceByUsernameRequest();

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

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

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

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