# Integrate using Eureka Rest APIs

You can use the Eureka Rest APIs explained [here](https://github.com/Netflix/eureka/wiki/Eureka-REST-operations).

**REST Endpoints Documentation**

**appID** is the name of the application and **instanceID** is the unique identifier associated with the instance. In AWS cloud, instanceID is the **instance id** of the instance and in other data centers, it is the **hostname** of the instance.

| ***Operation***                                  | ***HTTP action***                                                                                                                                                                                          | ***Description***                                                         |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Register new application instance                | <mark style="color:blue;">POST</mark> /eureka/apps/**appID**                                                                                                                                               | *Input*: JSON/XML payload *Output*: HTTP Code: 204 on success             |
| De-register application instance                 | <mark style="color:red;">DELETE</mark> /eureka/apps/appID/instanceID                                                                                                                                       | *Output*: HTTP Code: 200 on success                                       |
| Send application instance heartbeat              | <mark style="color:orange;">PUT</mark> /eureka/apps/**appID**/**instanceID**                                                                                                                               | *Output*: HTTP Code: 200 on *success* 404 if **instanceID** doesn't exist |
| Take instance out of service                     | <mark style="color:orange;">PUT</mark> /eureka/apps/**appID**/**instanceID**/status?value=OUT\_OF\_SERVICE                                                                                                 | *Output* HTTP Code: 200 on *success* 500 on *failure*                     |
| Move instance back into service (remove override | <mark style="color:red;">DELETE</mark> /eureka/apps/**appID**/**instanceID**/status?value=UP (The value=UP is optional, it is used as a suggestion for the fallback status due to removal of the override) | *Output* HTTP Code: 200 on *success* 500 on *failure*                     |
| Update metadata                                  | <mark style="color:orange;">PUT</mark> /eureka/apps/**appID**/**instanceID**/metadata?key=value                                                                                                            | *Output* HTTP Code: 200 on *success* 500 on *failure*                     |

For JSON/XML, the content types supplied must be **application/xml** or **application/json**.

When you register, you’ll need to post an XML (or JSON) body which conforms to this XSD:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xsd:element name="instance">
        <xsd:complexType>
            <xsd:all>
                <!-- hostName in ec2 should be the public dns name, within ec2 public dns name will
                     always resolve to its private IP -->
                <xsd:element name="hostName" type="xsd:string" />
                <xsd:element name="app" type="xsd:string" />
                <xsd:element name="ipAddr" type="xsd:string" />
                <xsd:element name="vipAddress" type="xsd:string" />
                <xsd:element name="secureVipAddress" type="xsd:string" />
                <xsd:element name="status" type="statusType" />
                <xsd:element name="port" type="xsd:positiveInteger" minOccurs="0" />
                <xsd:element name="securePort" type="xsd:positiveInteger" />
                <xsd:element name="homePageUrl" type="xsd:string" />
                <xsd:element name="statusPageUrl" type="xsd:string" />
                <xsd:element name="healthCheckUrl" type="xsd:string" />
               <xsd:element ref="dataCenterInfo" minOccurs="1" maxOccurs="1" />
                <!-- optional -->
                <xsd:element ref="leaseInfo" minOccurs="0"/>
                <!-- optional app specific metadata -->
                <xsd:element name="metadata" type="appMetadataType" minOccurs="0" />
            </xsd:all>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dataCenterInfo">
        <xsd:complexType>
             <xsd:all>
                 <xsd:element name="name" type="dcNameType" />
                 <!-- metadata is only required if name is Amazon -->
                 <xsd:element name="metadata" type="amazonMetdataType" minOccurs="0"/>
             </xsd:all>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="leaseInfo">
        <xsd:complexType>
            <xsd:all>
                <!-- (optional) if you want to change the length of lease - default if 90 secs -->
                <xsd:element name="evictionDurationInSecs" minOccurs="0"  type="xsd:positiveInteger"/>
            </xsd:all>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="dcNameType">
        <!-- Restricting the values to a set of value using 'enumeration' -->
        <xsd:restriction base = "xsd:string">
            <xsd:enumeration value = "MyOwn"/>
            <xsd:enumeration value = "Amazon"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="statusType">
        <!-- Restricting the values to a set of value using 'enumeration' -->
        <xsd:restriction base = "xsd:string">
            <xsd:enumeration value = "UP"/>
            <xsd:enumeration value = "DOWN"/>
            <xsd:enumeration value = "STARTING"/>
            <xsd:enumeration value = "OUT_OF_SERVICE"/>
            <xsd:enumeration value = "UNKNOWN"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="amazonMetdataType">
        <!-- From <a class="jive-link-external-small" href="http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?AESDG-chapter-instancedata.html" target="_blank">http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?AESDG-chapter-instancedata.html</a> -->
        <xsd:all>
            <xsd:element name="ami-launch-index" type="xsd:string" />
            <xsd:element name="local-hostname" type="xsd:string" />
            <xsd:element name="availability-zone" type="xsd:string" />
            <xsd:element name="instance-id" type="xsd:string" />
            <xsd:element name="public-ipv4" type="xsd:string" />
            <xsd:element name="public-hostname" type="xsd:string" />
            <xsd:element name="ami-manifest-path" type="xsd:string" />
            <xsd:element name="local-ipv4" type="xsd:string" />
            <xsd:element name="hostname" type="xsd:string"/>
            <xsd:element name="ami-id" type="xsd:string" />
            <xsd:element name="instance-type" type="xsd:string" />
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="appMetadataType">
        <xsd:sequence>
            <!-- this is optional application specific name, value metadata -->
            <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
        </xsd:sequence>
    </xsd:complexType>

</xsd:schema>
```

**Examples**

**RENEW / HEARTBEAT**

Example : <mark style="color:orange;">`PUT`</mark>` ``/eureka/apps/MYAPP/i-6589ef6`

Response Status:

* <mark style="color:green;">`200`</mark> (on success)
* <mark style="color:orange;">`404`</mark> (eureka doesn't know about you, Register yourself first)
* <mark style="color:red;">`500`</mark> (failure)

(If Eureka doesn't get heartbeats from the service node within the evictionDurationInSecs, then the node will get automatically de-registered )

**CANCEL**

Example : <mark style="color:red;">`DELETE`</mark>` ``/eureka/apps/MYAPP/i-6589ef6`

Response Status:

* <mark style="color:green;">`200`</mark> (on success)
* <mark style="color:red;">`500`</mark> (failure)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.industryapps.net/connect-to-the-platform/integrate-using-eureka-rest-apis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
