# Replica Sets

## Get Read Replica Sets

**get** `/projects/{project_id}/services/{service_id}/replicaSets`

Retrieves a list of all read replica sets associated with a primary service within a project.

### Path Parameters

- `project_id: string`

- `service_id: string`

### Returns

- `id: optional string`

- `connection_pooler: optional ConnectionPooler`

  - `endpoint: optional Endpoint`

    - `host: optional string`

    - `port: optional number`

- `cpu_millis: optional number`

  CPU allocation in milli-cores.

- `endpoint: optional Endpoint`

- `memory_gbs: optional number`

  Memory allocation in gigabytes.

- `metadata: optional object { environment }`

  Additional metadata for the read replica set

  - `environment: optional string`

    Environment tag for the read replica set

- `name: optional string`

- `nodes: optional number`

  Number of nodes in the replica set.

- `status: optional "creating" or "active" or "resizing" or 2 more`

  - `"creating"`

  - `"active"`

  - `"resizing"`

  - `"deleting"`

  - `"error"`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY"
```

#### Response

```json
[
  {
    "id": "alb8jicdpr",
    "connection_pooler": {
      "endpoint": {
        "host": "my-service.com",
        "port": 8080
      }
    },
    "cpu_millis": 250,
    "endpoint": {
      "host": "my-service.com",
      "port": 8080
    },
    "memory_gbs": 1,
    "metadata": {
      "environment": "environment"
    },
    "name": "reporting-replica-1",
    "nodes": 2,
    "status": "active"
  }
]
```

## Create a Read Replica Set

**post** `/projects/{project_id}/services/{service_id}/replicaSets`

Creates a new read replica set for a service. This is an asynchronous operation.

### Path Parameters

- `project_id: string`

- `service_id: string`

### Body Parameters

- `cpu_millis: number`

  The initial CPU allocation in milli-cores.

- `memory_gbs: number`

  The initial memory allocation in gigabytes.

- `name: string`

  A human-readable name for the read replica.

- `nodes: number`

  Number of nodes to create in the replica set.

### Returns

- `ReadReplicaSet object { id, connection_pooler, cpu_millis, 6 more }`

  - `id: optional string`

  - `connection_pooler: optional ConnectionPooler`

    - `endpoint: optional Endpoint`

      - `host: optional string`

      - `port: optional number`

  - `cpu_millis: optional number`

    CPU allocation in milli-cores.

  - `endpoint: optional Endpoint`

  - `memory_gbs: optional number`

    Memory allocation in gigabytes.

  - `metadata: optional object { environment }`

    Additional metadata for the read replica set

    - `environment: optional string`

      Environment tag for the read replica set

  - `name: optional string`

  - `nodes: optional number`

    Number of nodes in the replica set.

  - `status: optional "creating" or "active" or "resizing" or 2 more`

    - `"creating"`

    - `"active"`

    - `"resizing"`

    - `"deleting"`

    - `"error"`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY" \
    -d '{
          "cpu_millis": 250,
          "memory_gbs": 1,
          "name": "my-reporting-replica",
          "nodes": 2
        }'
```

#### Response

```json
{
  "id": "alb8jicdpr",
  "connection_pooler": {
    "endpoint": {
      "host": "my-service.com",
      "port": 8080
    }
  },
  "cpu_millis": 250,
  "endpoint": {
    "host": "my-service.com",
    "port": 8080
  },
  "memory_gbs": 1,
  "metadata": {
    "environment": "environment"
  },
  "name": "reporting-replica-1",
  "nodes": 2,
  "status": "active"
}
```

## Delete a Read Replica Set

**delete** `/projects/{project_id}/services/{service_id}/replicaSets/{replica_set_id}`

Deletes a specific read replica set. This is an asynchronous operation.

### Path Parameters

- `project_id: string`

- `service_id: string`

- `replica_set_id: string`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets/$REPLICA_SET_ID \
    -X DELETE \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY"
```

## Resize a Read Replica Set

**post** `/projects/{project_id}/services/{service_id}/replicaSets/{replica_set_id}/resize`

Changes the resource allocation for a specific read replica set.

### Path Parameters

- `project_id: string`

- `service_id: string`

- `replica_set_id: string`

### Body Parameters

- `cpu_millis: string`

  The new CPU allocation in milli-cores.

- `memory_gbs: string`

  The new memory allocation in gigabytes.

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets/$REPLICA_SET_ID/resize \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY" \
    -d '{
          "cpu_millis": "1000",
          "memory_gbs": "4"
        }'
```

## Enable Connection Pooler for a Read Replica

**post** `/projects/{project_id}/services/{service_id}/replicaSets/{replica_set_id}/enablePooler`

Activates the connection pooler for a specific read replica set.

### Path Parameters

- `project_id: string`

- `service_id: string`

- `replica_set_id: string`

### Returns

- `message: optional string`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets/$REPLICA_SET_ID/enablePooler \
    -X POST \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY"
```

#### Response

```json
{
  "message": "Action completed successfully."
}
```

## Disable Connection Pooler for a Read Replica

**post** `/projects/{project_id}/services/{service_id}/replicaSets/{replica_set_id}/disablePooler`

Deactivates the connection pooler for a specific read replica set.

### Path Parameters

- `project_id: string`

- `service_id: string`

- `replica_set_id: string`

### Returns

- `message: optional string`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets/$REPLICA_SET_ID/disablePooler \
    -X POST \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY"
```

#### Response

```json
{
  "message": "Action completed successfully."
}
```

## Set Environment for a Read Replica

**post** `/projects/{project_id}/services/{service_id}/replicaSets/{replica_set_id}/setEnvironment`

Sets the environment type for the read replica set.

### Path Parameters

- `project_id: string`

- `service_id: string`

- `replica_set_id: string`

### Body Parameters

- `environment: "PROD" or "DEV"`

  The target environment for the service.

  - `"PROD"`

  - `"DEV"`

### Returns

- `message: optional string`

### Example

```http
curl http://localhost:8080/projects/$PROJECT_ID/services/$SERVICE_ID/replicaSets/$REPLICA_SET_ID/setEnvironment \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $TIGER_CLOUD_API_KEY" \
    -d '{
          "environment": "PROD"
        }'
```

#### Response

```json
{
  "message": "Action completed successfully."
}
```

## Domain Types

### Read Replica Set

- `ReadReplicaSet object { id, connection_pooler, cpu_millis, 6 more }`

  - `id: optional string`

  - `connection_pooler: optional ConnectionPooler`

    - `endpoint: optional Endpoint`

      - `host: optional string`

      - `port: optional number`

  - `cpu_millis: optional number`

    CPU allocation in milli-cores.

  - `endpoint: optional Endpoint`

  - `memory_gbs: optional number`

    Memory allocation in gigabytes.

  - `metadata: optional object { environment }`

    Additional metadata for the read replica set

    - `environment: optional string`

      Environment tag for the read replica set

  - `name: optional string`

  - `nodes: optional number`

    Number of nodes in the replica set.

  - `status: optional "creating" or "active" or "resizing" or 2 more`

    - `"creating"`

    - `"active"`

    - `"resizing"`

    - `"deleting"`

    - `"error"`

### Replica Set Retrieve Replica Sets Response

- `ReplicaSetRetrieveReplicaSetsResponse = array of ReadReplicaSet`

  - `id: optional string`

  - `connection_pooler: optional ConnectionPooler`

    - `endpoint: optional Endpoint`

      - `host: optional string`

      - `port: optional number`

  - `cpu_millis: optional number`

    CPU allocation in milli-cores.

  - `endpoint: optional Endpoint`

  - `memory_gbs: optional number`

    Memory allocation in gigabytes.

  - `metadata: optional object { environment }`

    Additional metadata for the read replica set

    - `environment: optional string`

      Environment tag for the read replica set

  - `name: optional string`

  - `nodes: optional number`

    Number of nodes in the replica set.

  - `status: optional "creating" or "active" or "resizing" or 2 more`

    - `"creating"`

    - `"active"`

    - `"resizing"`

    - `"deleting"`

    - `"error"`

### Replica Set Enable Pooler Response

- `ReplicaSetEnablePoolerResponse object { message }`

  - `message: optional string`

### Replica Set Disable Pooler Response

- `ReplicaSetDisablePoolerResponse object { message }`

  - `message: optional string`

### Replica Set Set Environment Response

- `ReplicaSetSetEnvironmentResponse object { message }`

  - `message: optional string`
