Was this helpful?

 

API Platform Base Path: https://api.enterprise.apigee.com/v1/o/{org_name}

API Resource Path:

/environments/{env_name}/targetservers

Description: Creates a TargetServer in the environment specified

Verb: POST
Auth: Basic Auth
Media types:
application/json
text/xml

 

Overview: Use this method to create TargetServer definitions in an environment. TargetServers are used to decouple TargetEndpoint HTTPTargetConnections from concrete URLs for backend services.

To do so, an HTTPConnection can be configured to use a LoadBalancer that lists one or more 'named' TargetSevers. Using TargetServers, you can create an HTTPTargetConnection that calls a different backend server based on the environment where the API proxy is deployed.

For example, instead of the following configuration:

<TargetEndpoint name="default">
  <HTTPTargetConnection>
    <URL>http://weather.yahooapis.com</URL>
  </HTTPTargetConnection>
</TargetEndpoint>
You can reference a TargetServer as follows:
<TargetEndpoint name="default">
    <HTTPTargetConnection>
        <LoadBalancer>
            <Server name="target1" />
        </LoadBalancer>
  </HTTPTargetConnection>
</TargetEndpoint>
You can then set up a TargetServer called target1 in the 'test' environment that points to a test backend service, and a different TargetServer called target1 in the 'prod' environment that points to a production backend. When you 'promote' the API proxy with this configuration from the test to the prod environment, the TargetEndpoint will use the appropriate backend service, without requiring any changes in the API proxy configuration. Sample Request:
$ curl -H "Content-Type:text/xml" -X POST -d \
'<TargetServer name="Target1">
  <Host>1.Mybackendservice.Com</Host>
  <Port>80</Port>
  <IsEnabled>True</IsEnabled>
</TargetServer>' \
https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/targetservers \
-u myname:mypass 
Request Payload Elements:
 
 
 
Name Description Default Required?
Host The network address (URL) of the backend service that this TargetServer definition will call. N/A Yes
IsEnabled A boolean (true/false) that determines whether this TargetServer is enabled or not. You can use this setting to take TargetServers out of rotation, without requiring you to delete the TargetServer definition. false No
Port The port on which the backend service is configured to listen. 0 No
Sample Response:
{
  "host" : "1.mybackendservice.com",
  "isEnabled" : true,
  "name" : "target1",
  "port" : 80
}

 

Add new comment

Provide your email address if you wish to be contacted offline about your comment.
We will not display your email address as part of your comment.

We'd love your feedback and perspective! Please be as specific as possible.
Type the characters you see in this picture. (verify using audio)

Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.