/// <summary> /// Copy the app bits for an App /// <para>This endpoint will copy the package bits in the blobstore from the source app to the destination app.</para> /// <para>It will always return a job which you can query for success or failure.</para> /// <para>This operation will require the app to restart in order for the changes to take effect.</para> /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/apps/copy_the_app_bits_for_an_app.html"</para> /// </summary> public async Task <CopyAppBitsForAppResponse> CopyAppBitsForApp(Guid?guid, CopyAppBitsForAppRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/apps/{0}/copy_bits", guid); var client = this.GetHttpClient(); client.Uri = uriBuilder.Uri; client.Method = HttpMethod.Post; var authHeader = await BuildAuthenticationHeader(); if (!string.IsNullOrWhiteSpace(authHeader.Key)) { if (client.Headers.ContainsKey(authHeader.Key)) { client.Headers[authHeader.Key] = authHeader.Value; } else { 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 <CopyAppBitsForAppResponse>(await response.ReadContentAsStringAsync())); }
public void TestCopyAppBitsForAppRequest() { string json = @"{""source_app_guid"":""088a81ad-747a-4285-8173-f4de2a1d7058""}"; CopyAppBitsForAppRequest request = new CopyAppBitsForAppRequest(); request.SourceAppGuid = new Guid("088a81ad-747a-4285-8173-f4de2a1d7058"); string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
public void TestCopyAppBitsForAppRequest() { string json = @"{""source_app_guid"":""0ee3eab6-01ed-4253-a017-de087546c197""}"; CopyAppBitsForAppRequest request = new CopyAppBitsForAppRequest(); request.SourceAppGuid = new Guid("0ee3eab6-01ed-4253-a017-de087546c197"); string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
public void TestCopyAppBitsForAppRequest() { string json = @"{""source_app_guid"":""7ddfd9e0-1166-4bfe-9ef1-5c9be6e76cc5""}"; CopyAppBitsForAppRequest request = new CopyAppBitsForAppRequest(); request.SourceAppGuid = new Guid("7ddfd9e0-1166-4bfe-9ef1-5c9be6e76cc5"); string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
public void TestCopyAppBitsForAppRequest() { string json = @"{""source_app_guid"":""84bd6e05-db62-464b-a9f0-5af0074f83db""}"; CopyAppBitsForAppRequest request = new CopyAppBitsForAppRequest(); request.SourceAppGuid = new Guid("84bd6e05-db62-464b-a9f0-5af0074f83db"); string result = JsonConvert.SerializeObject(request, Formatting.None); Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result); }
/// <summary> /// Copy the app bits for an App /// <para>This endpoint will copy the package bits in the blobstore from the source app to the destination app.</para> /// <para>It will always return a job which you can query for success or failure.</para> /// <para>This operation will require the app to restart in order for the changes to take effect.</para> /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/apps/copy_the_app_bits_for_an_app.html"</para> /// </summary> public async Task <CopyAppBitsForAppResponse> CopyAppBitsForApp(Guid?guid, CopyAppBitsForAppRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/apps/{0}/copy_bits", guid); var client = this.GetHttpClient(); client.Uri = uriBuilder.Uri; client.Method = HttpMethod.Post; client.Content = ((string)JsonConvert.SerializeObject(value)).ConvertToStream(); var expectedReturnStatus = 201; var response = await this.SendAsync(client, expectedReturnStatus); return(Utilities.DeserializeJson <CopyAppBitsForAppResponse>(await response.Content.ReadAsStringAsync())); }
/// <summary> /// Copy the app bits for an App /// <para>This endpoint will copy the package bits in the blobstore from the source app to the destination app.</para> /// <para>It will always return a job which you can query for success or failure.</para> /// <para>This operation will require the app to restart in order for the changes to take effect.</para> /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/apps/copy_the_app_bits_for_an_app.html"</para> /// </summary> public async Task<CopyAppBitsForAppResponse> CopyAppBitsForApp(Guid? guid, CopyAppBitsForAppRequest value) { UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget); uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/apps/{0}/copy_bits", guid); 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<CopyAppBitsForAppResponse>(await response.ReadContentAsStringAsync()); }
public void CopyAppBitsForAppTest() { using (ShimsContext.Create()) { MockClients clients = new MockClients(); string json = @"{ ""metadata"": { ""guid"": ""aaa297dc-83cd-4327-ade7-24268ca71c29"", ""created_at"": ""2015-05-19T15:27:02+00:00"", ""url"": ""/v2/jobs/aaa297dc-83cd-4327-ade7-24268ca71c29"" }, ""entity"": { ""guid"": ""aaa297dc-83cd-4327-ade7-24268ca71c29"", ""status"": ""queued"" } }"; clients.JsonResponse = json; clients.ExpectedStatusCode = (HttpStatusCode)201; var cfClient = clients.CreateCloudFoundryClient(); Guid? guid = Guid.NewGuid(); CopyAppBitsForAppRequest value = new CopyAppBitsForAppRequest(); var obj = cfClient.Apps.CopyAppBitsForApp(guid, value).Result; Assert.AreEqual("aaa297dc-83cd-4327-ade7-24268ca71c29", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true); Assert.AreEqual("2015-05-19T15:27:02+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true); Assert.AreEqual("/v2/jobs/aaa297dc-83cd-4327-ade7-24268ca71c29", TestUtil.ToTestableString(obj.EntityMetadata.Url), true); Assert.AreEqual("aaa297dc-83cd-4327-ade7-24268ca71c29", TestUtil.ToTestableString(obj.Guid), true); Assert.AreEqual("queued", TestUtil.ToTestableString(obj.Status), true); } }