# Anti-Affinity Group


<style>
  span[class^="pill-"] {
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.6em;
    vertical-align: middle;
    margin-right: 12px;
    font-family: sans-serif;
    font-weight: bold;
    display: inline-block;
    line-height: 1;
  }
  span.pill-GET { background-color: #61affe; }
  span.pill-POST { background-color: #49cc90; }
  span.pill-PUT { background-color: #fca130; }
  span.pill-DELETE { background-color: #f93e3e; }
  span.pill-PATCH { background-color: #50e3c2; }
  span[class^="pill-"]:after {
    content: attr(data-label);
    font-size: 0.9rem;
  }
</style>

Anti-affinity groups let you define placement constraints for your Compute instances.

[Read more](https://community.exoscale.com/product/compute/instances/how-to/anti-affinity/)

## <span data-label="POST" class="pill-POST"></span>create-anti-affinity-group

Create an Anti-affinity Group

```
POST /anti-affinity-group
```

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | **yes** | Anti-affinity Group name<br/><br/>Min length: `1`. Max length: `255`. |
| `description` | string | no | Anti-affinity Group description<br/><br/>Max length: `255`. |

<details>
<summary>Example</summary>

```json
{
  "description": "string",
  "name": "string"
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `create-anti-affinity-group`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.CreateAntiAffinityGroup) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.create_anti_affinity_group) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#createAntiAffinityGroup(com.exoscale.sdk.model.CreateAntiAffinityGroupRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api create-anti-affinity-group`

## <span data-label="GET" class="pill-GET"></span>get-anti-affinity-group

Retrieve Anti-affinity Group details

```
GET /anti-affinity-group/{id}
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` | Must be a valid UUID. |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `description` | string | Anti-affinity Group description<br/><br/>Max length: `255`. |
| `id` | string | Anti-affinity Group ID<br/><br/>Must be a valid UUID. |
| `instances` | array of [Instance](/reference/api/_schemas/instance/) | Anti-affinity Group instances |
| `name` | string | Anti-affinity Group name<br/><br/>Min length: `1`. Max length: `255`. |

<details>
<summary>Example output</summary>

```json
{
  "description": "string",
  "id": "string",
  "instances": [
    {
      "anti-affinity-groups": [
        {
          "id": "string"
        }
      ],
      "application-consistent-snapshot-enabled": true,
      "created-at": "2024-01-01T12:00:00Z",
      "deploy-target": {
        "id": "string"
      },
      "disk-encrypted": true,
      "disk-size": 0,
      "elastic-ips": [
        {
          "id": "string"
        }
      ],
      "id": "string",
      "instance-type": {
        "authorized": true,
        "cpus": 0,
        "family": "gpu3",
        "gpus": 0,
        "id": "string",
        "memory": 0,
        "size": "large",
        "zones": [
          "ch-dk-2"
        ]
      },
      "ipv6-address": "string",
      "labels": {},
      "mac-address": "string",
      "manager": {
        "id": "string",
        "type": "sks-nodepool"
      },
      "name": "string",
      "private-networks": [
        {
          "id": "string",
          "mac-address": "string"
        }
      ],
      "public-ip": "string",
      "public-ip-assignment": "inet4",
      "secureboot-enabled": true,
      "security-groups": [
        {
          "id": "string"
        }
      ],
      "snapshots": [
        {
          "id": "string"
        }
      ],
      "ssh-key": {
        "fingerprint": "string",
        "name": "string"
      },
      "ssh-keys": [
        {
          "fingerprint": "string",
          "name": "string"
        }
      ],
      "state": "expunging",
      "template": {
        "application-consistent-snapshot-enabled": true,
        "boot-mode": "legacy",
        "build": "string",
        "checksum": "string",
        "created-at": "2024-01-01T12:00:00Z",
        "default-user": "string",
        "description": "string",
        "family": "string",
        "id": "string",
        "maintainer": "string",
        "name": "string",
        "password-enabled": true,
        "size": 0,
        "ssh-key-enabled": true,
        "url": "string",
        "version": "string",
        "visibility": "private",
        "zones": [
          "ch-dk-2"
        ]
      },
      "tpm-enabled": true,
      "user-data": "string"
    }
  ],
  "name": "string"
}
```
</details>


SDK reference for `get-anti-affinity-group`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.GetAntiAffinityGroup) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.get_anti_affinity_group) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#getAntiAffinityGroup(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api get-anti-affinity-group`

## <span data-label="DELETE" class="pill-DELETE"></span>delete-anti-affinity-group

Delete an Anti-affinity Group

```
DELETE /anti-affinity-group/{id}
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` | Must be a valid UUID. |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `delete-anti-affinity-group`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.DeleteAntiAffinityGroup) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.delete_anti_affinity_group) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#deleteAntiAffinityGroup(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api delete-anti-affinity-group`


---

## Other Operations

## <span data-label="GET" class="pill-GET"></span>list-anti-affinity-groups

List Anti-affinity Groups

```
GET /anti-affinity-group
```

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `anti-affinity-groups` | array of [Anti-affinity Group](/reference/api/_schemas/anti-affinity-group/) |  |

<details>
<summary>Example output</summary>

```json
{
  "anti-affinity-groups": [
    {
      "description": "string",
      "id": "string",
      "instances": [
        {
          "anti-affinity-groups": [
            null
          ],
          "application-consistent-snapshot-enabled": true,
          "created-at": "2024-01-01T12:00:00Z",
          "deploy-target": {
            "id": null
          },
          "disk-encrypted": true,
          "disk-size": 0,
          "elastic-ips": [
            null
          ],
          "id": "string",
          "instance-type": {
            "authorized": null,
            "cpus": null,
            "family": null,
            "gpus": null,
            "id": null,
            "memory": null,
            "size": null,
            "zones": null
          },
          "ipv6-address": "string",
          "labels": {},
          "mac-address": "string",
          "manager": {
            "id": null,
            "type": null
          },
          "name": "string",
          "private-networks": [
            null
          ],
          "public-ip": "string",
          "public-ip-assignment": "inet4",
          "secureboot-enabled": true,
          "security-groups": [
            null
          ],
          "snapshots": [
            null
          ],
          "ssh-key": {
            "fingerprint": null,
            "name": null
          },
          "ssh-keys": [
            null
          ],
          "state": "expunging",
          "template": {
            "application-consistent-snapshot-enabled": null,
            "boot-mode": null,
            "build": null,
            "checksum": null,
            "created-at": null,
            "default-user": null,
            "description": null,
            "family": null,
            "id": null,
            "maintainer": null,
            "name": null,
            "password-enabled": null,
            "size": null,
            "ssh-key-enabled": null,
            "url": null,
            "version": null,
            "visibility": null,
            "zones": null
          },
          "tpm-enabled": true,
          "user-data": "string"
        }
      ],
      "name": "string"
    }
  ]
}
```
</details>


SDK reference for `list-anti-affinity-groups`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.ListAntiAffinityGroups) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.list_anti_affinity_groups) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#listAntiAffinityGroups())

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api list-anti-affinity-groups`


