Example #1
0
        /// <summary>
        /// Update a Route
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/routes/update_a_route.html"</para>
        /// </summary>
        public async Task <UpdateRouteResponse> UpdateRoute(Guid?guid, UpdateRouteRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/routes/{0}", guid);
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Put;
            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 <UpdateRouteResponse>(await response.ReadContentAsStringAsync()));
        }
Example #2
0
        internal virtual UpdateRouteResponse UpdateRoute(UpdateRouteRequest request)
        {
            var marshaller   = UpdateRouteRequestMarshaller.Instance;
            var unmarshaller = UpdateRouteResponseUnmarshaller.Instance;

            return(Invoke <UpdateRouteRequest, UpdateRouteResponse>(request, marshaller, unmarshaller));
        }
Example #3
0
        public void UpdateRouteCommand_Ok()
        {
            //Arrenge
            UpdateRouteRequest request = new UpdateRouteRequest
            {
                PointFromCode = "from",
                PointToCode   = "to",
                Cost          = 12,
                Time          = 20
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsIn(request.PointFromCode), It.IsIn(request.PointToCode)))
            .Returns(new Route()
            {
                PointFromCode = request.PointFromCode,
                PointToCode   = request.PointToCode,
                Cost          = 10,
                Time          = 10
            });

            //Act
            new UpdateRouteCommand(_routedataMock.Object).Execute(request);

            //Assert
            _routedataMock.Verify(p => p.Update(It.Is((Route c) =>
                                                      c.PointToCode == request.PointToCode &&
                                                      c.PointFromCode == request.PointFromCode &&
                                                      c.Cost == request.Cost &&
                                                      c.Time == request.Time
                                                      )));
        }
Example #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateRoute operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateRoute operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/appmesh-2018-10-01/UpdateRoute">REST API Reference for UpdateRoute Operation</seealso>
        public virtual Task <UpdateRouteResponse> UpdateRouteAsync(UpdateRouteRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = UpdateRouteRequestMarshaller.Instance;
            var unmarshaller = UpdateRouteResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateRouteRequest, UpdateRouteResponse>(request, marshaller,
                                                                         unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateRoute operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateRoute operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/appmesh-2018-10-01/UpdateRoute">REST API Reference for UpdateRoute Operation</seealso>
        public virtual Task <UpdateRouteResponse> UpdateRouteAsync(UpdateRouteRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateRouteRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateRouteResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateRouteResponse>(request, options, cancellationToken));
        }
        internal virtual UpdateRouteResponse UpdateRoute(UpdateRouteRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateRouteRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateRouteResponseUnmarshaller.Instance;

            return(Invoke <UpdateRouteResponse>(request, options));
        }
Example #7
0
        public void Route_test()
        {
            CreateRouteResponse   newRoute      = null;
            UpdateRouteResponse   updatedRoute  = null;
            RetrieveRouteResponse retrieveRoute = null;

            CreateRouteRequest request = new CreateRouteRequest();

            request.DomainGuid = domainGuid;
            request.SpaceGuid  = spaceGuid;

            try
            {
                newRoute = client.Routes.CreateRoute(request).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while creating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(newRoute);

            try
            {
                retrieveRoute = client.Routes.RetrieveRoute(newRoute.EntityMetadata.Guid).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while reading route: {0}", ex.ToString());
            }
            Assert.IsNotNull(retrieveRoute);

            UpdateRouteRequest updateR = new UpdateRouteRequest();

            updateR.Host = "newtestdomain";

            try
            {
                updatedRoute = client.Routes.UpdateRoute(newRoute.EntityMetadata.Guid, updateR).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while updating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(updatedRoute);
            Assert.AreEqual(updateR.Host, updatedRoute.Host);

            try
            {
                client.Routes.DeleteRoute(newRoute.EntityMetadata.Guid).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while deleting space: {0}", ex.ToString());
            }
        }
Example #8
0
        public void UpdateRouteTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c"",
    ""created_at"": ""2016-09-02T11:52:13Z"",
    ""updated_at"": ""2016-09-02T11:52:14Z""
  },
  ""entity"": {
    ""host"": ""host-21"",
    ""path"": """",
    ""domain_guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""space_guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""service_instance_guid"": null,
    ""port"": 10000,
    ""domain_url"": ""/v2/shared_domains/d3d68f3a-f005-4d5a-802e-801bec893b4a"",
    ""space_url"": ""/v2/spaces/d3c7b2dc-9de0-49c4-aa78-97547c2f0ca6"",
    ""apps_url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/apps"",
    ""route_mappings_url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/route_mappings""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                UpdateRouteRequest value = new UpdateRouteRequest();


                var obj = cfClient.Routes.UpdateRoute(guid, value).Result;


                Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:13Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-09-02T11:52:14Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("host-21", TestUtil.ToTestableString(obj.Host), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.Path), true);
                Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.DomainGuid), true);
                Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.SpaceGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.ServiceInstanceGuid), true);
                Assert.AreEqual("10000", TestUtil.ToTestableString(obj.Port), true);
                Assert.AreEqual("/v2/shared_domains/d3d68f3a-f005-4d5a-802e-801bec893b4a", TestUtil.ToTestableString(obj.DomainUrl), true);
                Assert.AreEqual("/v2/spaces/d3c7b2dc-9de0-49c4-aa78-97547c2f0ca6", TestUtil.ToTestableString(obj.SpaceUrl), true);
                Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
                Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/route_mappings", TestUtil.ToTestableString(obj.RouteMappingsUrl), true);
            }
        }
Example #9
0
        public void UpdateRouteCommand_ThrowRequiredTimeOrCostToBeFill()
        {
            //Arrenge
            UpdateRouteRequest request = new UpdateRouteRequest
            {
                PointFromCode = "",
                PointToCode   = ""
            };

            //Act
            new UpdateRouteCommand(_routedataMock.Object).Execute(request);
        }
Example #10
0
        public void TestUpdateRouteRequest()
        {
            string json = @"{
  ""host"": ""new_host""
}";

            UpdateRouteRequest request = new UpdateRouteRequest();

            request.Host = "new_host";
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void TestUpdateRouteRequest()
        {
            string json = @"{
  ""host"": ""new_host""
}";

            UpdateRouteRequest request = new UpdateRouteRequest();

            request.Host = "new_host";
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Example #12
0
        public void UpdateRouteCommand_ThrowRouteNotExist()
        {
            //Arrenge
            UpdateRouteRequest request = new UpdateRouteRequest
            {
                PointFromCode = "from",
                PointToCode   = "to",
                Cost          = 10,
                Time          = 20
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsIn(request.PointFromCode), It.IsIn(request.PointToCode)));

            //Act
            new UpdateRouteCommand(_routedataMock.Object).Execute(request);
        }
Example #13
0
        public void UpdateRouteTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""3bbcf6f5-6930-4ed9-87f8-e1466ebf388e"",
    ""url"": ""/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e"",
    ""created_at"": ""2016-02-09T10:21:52Z"",
    ""updated_at"": ""2016-02-09T10:21:52Z""
  },
  ""entity"": {
    ""host"": ""new_host"",
    ""domain_guid"": ""67f729d7-4fd2-4d2a-b28c-c5adecd964b5"",
    ""space_guid"": ""8dd45178-5d66-4584-a1da-f7751f12c102"",
    ""domain_url"": ""/v2/domains/67f729d7-4fd2-4d2a-b28c-c5adecd964b5"",
    ""space_url"": ""/v2/spaces/8dd45178-5d66-4584-a1da-f7751f12c102"",
    ""apps_url"": ""/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e/apps""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                UpdateRouteRequest value = new UpdateRouteRequest();


                var obj = cfClient.Routes.UpdateRoute(guid, value).Result;


                Assert.AreEqual("3bbcf6f5-6930-4ed9-87f8-e1466ebf388e", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:52Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-02-09T10:21:52Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("new_host", TestUtil.ToTestableString(obj.Host), true);
                Assert.AreEqual("67f729d7-4fd2-4d2a-b28c-c5adecd964b5", TestUtil.ToTestableString(obj.DomainGuid), true);
                Assert.AreEqual("8dd45178-5d66-4584-a1da-f7751f12c102", TestUtil.ToTestableString(obj.SpaceGuid), true);
                Assert.AreEqual("/v2/domains/67f729d7-4fd2-4d2a-b28c-c5adecd964b5", TestUtil.ToTestableString(obj.DomainUrl), true);
                Assert.AreEqual("/v2/spaces/8dd45178-5d66-4584-a1da-f7751f12c102", TestUtil.ToTestableString(obj.SpaceUrl), true);
                Assert.AreEqual("/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
            }
        }
        public void UpdateRouteTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""bd6618c9-ff42-4559-9042-28df2d136d56"",
    ""url"": ""/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56"",
    ""created_at"": ""2015-04-16T12:04:14+00:00"",
    ""updated_at"": ""2015-04-16T12:04:14+00:00""
  },
  ""entity"": {
    ""host"": ""new_host"",
    ""domain_guid"": ""151dd40c-afa8-4f3c-b39a-cfe915cf3fda"",
    ""space_guid"": ""90477a11-c3e1-4ed7-bf44-86d90619674d"",
    ""domain_url"": ""/v2/domains/151dd40c-afa8-4f3c-b39a-cfe915cf3fda"",
    ""space_url"": ""/v2/spaces/90477a11-c3e1-4ed7-bf44-86d90619674d"",
    ""apps_url"": ""/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56/apps""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                UpdateRouteRequest value = new UpdateRouteRequest();


                var obj = cfClient.Routes.UpdateRoute(guid, value).Result;


                Assert.AreEqual("bd6618c9-ff42-4559-9042-28df2d136d56", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:14+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2015-04-16T12:04:14+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("new_host", TestUtil.ToTestableString(obj.Host), true);
                Assert.AreEqual("151dd40c-afa8-4f3c-b39a-cfe915cf3fda", TestUtil.ToTestableString(obj.DomainGuid), true);
                Assert.AreEqual("90477a11-c3e1-4ed7-bf44-86d90619674d", TestUtil.ToTestableString(obj.SpaceGuid), true);
                Assert.AreEqual("/v2/domains/151dd40c-afa8-4f3c-b39a-cfe915cf3fda", TestUtil.ToTestableString(obj.DomainUrl), true);
                Assert.AreEqual("/v2/spaces/90477a11-c3e1-4ed7-bf44-86d90619674d", TestUtil.ToTestableString(obj.SpaceUrl), true);
                Assert.AreEqual("/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
            }
        }
Example #15
0
        /// <summary>
        /// Update a Route
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/routes/update_a_route.html"</para>
        /// </summary>
        public async Task <UpdateRouteResponse> UpdateRoute(Guid?guid, UpdateRouteRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/routes/{0}", 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 <UpdateRouteResponse>(await response.Content.ReadAsStringAsync()));
        }
Example #16
0
        public void UpdateRouteCommand_TimeZero_ThrowValueBiggerThan0()
        {
            //Arrenge
            UpdateRouteRequest request = new UpdateRouteRequest
            {
                PointFromCode = "from",
                PointToCode   = "to",
                Cost          = 10,
                Time          = 0
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsIn(request.PointFromCode), It.IsIn(request.PointToCode)))
            .Returns(new Route()
            {
                PointFromCode = request.PointFromCode,
                PointToCode   = request.PointToCode,
                Cost          = 10,
                Time          = 10
            });

            //Act
            new UpdateRouteCommand(_routedataMock.Object).Execute(request);
        }
Example #17
0
        public IActionResult Update([FromBody] UpdateRouteRequest request)
        {
            _updateRouteCommand.Execute(request);

            return(NoContent());
        }
Example #18
0
        public void Route_test()
        {
            CreateRouteResponse newRoute = null;
            UpdateRouteResponse updatedRoute = null;
            RetrieveRouteResponse retrieveRoute = null;

            CreateRouteRequest request = new CreateRouteRequest();
            request.DomainGuid = domainGuid;
            request.SpaceGuid = spaceGuid;

            try
            {
                newRoute = client.Routes.CreateRoute(request).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while creating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(newRoute);

            try
            {
                retrieveRoute = client.Routes.RetrieveRoute(newRoute.EntityMetadata.Guid).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while reading route: {0}", ex.ToString());
            }
            Assert.IsNotNull(retrieveRoute);

            UpdateRouteRequest updateR = new UpdateRouteRequest();
            updateR.Host = "newtestdomain";

            try
            {
                updatedRoute = client.Routes.UpdateRoute(newRoute.EntityMetadata.Guid, updateR).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while updating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(updatedRoute);
            Assert.AreEqual(updateR.Host, updatedRoute.Host);

            try
            {
                client.Routes.DeleteRoute(newRoute.EntityMetadata.Guid).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while deleting space: {0}", ex.ToString());
            }
        }
Example #19
0
 /// <summary>
 /// Update a Route
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/routes/update_a_route.html"</para>
 /// </summary>
 public async Task<UpdateRouteResponse> UpdateRoute(Guid? guid, UpdateRouteRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/routes/{0}", 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 = JsonConvert.SerializeObject(value).ConvertToStream();
     var expectedReturnStatus = 201;
     var response = await this.SendAsync(client, expectedReturnStatus);
     return Utilities.DeserializeJson<UpdateRouteResponse>(await response.ReadContentAsStringAsync());
 }