# Deployment

<details>

<summary>Deployment Schema</summary>

* **id**: Unique id for every deployment
* **live**: Active/Inactive state of deployment
* **slug**: Unique string of deployment across project
* **settings**: Deployment setting object
* **created\_at**: Create at timestamp
* **modified\_at**: Modified at timestamp
* **organization\_id**: Unique id of the organization this deployment belongs to
* **project\_id**: Unique id of the project this deployment belongs to
* **viewer\_*****group\_*****id:** Unique id of the Viewer group this deployment belongs to
* **host\_link:** Open experience with more control when multiplayer mode is on
* **host\_passocode**: Passcode to be needed when open experience via host link

</details>

## Create Deployment

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/deployment/create`

Create deployment for the project.

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                       | Type   | Description                                   |
| ------------------------------------------ | ------ | --------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark>  | String | Unique slug of the organization               |
| projUuid<mark style="color:red;">\*</mark> | String | Unique identifier of the project(UUID format) |
| deploymentSlug                             | String | Unique slug of the deployment                 |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "id": 11,
        "live": true,
        "slug": "test7__1_",
        "settings": {
            "id": 1666290966851,
            "type": "deployment",
            "props": {
                "deployment_version": 1
            }
        },
        "created_at": "2022-10-20T18:23:20.73652",
        "modified_at": "2022-10-20T18:23:20.73652",
        "organization_id": 6,
        "project_id": 33,
        "viewer_group_id": 3
    }
}
```

{% endtab %}
{% endtabs %}

## Get Deployment

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/deployment/get`

Get deployment by id

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                           | Type   | Description                                   |
| ---------------------------------------------- | ------ | --------------------------------------------- |
| projUuid<mark style="color:red;">\*</mark>     | String | Unique identifier of the project(UUID format) |
| deploymentId<mark style="color:red;">\*</mark> | Number | Unique id of the deployment                   |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": {
        "success": true
    },
    "data": {
        "id": 3,
        "live": true,
        "slug": "saml",
        "settings": {
            "enable_multiplayer_mode": true
        },
        "created_at": "2022-09-08T10:34:19.006662",
        "modified_at": "2022-09-08T14:34:40.261",
        "organization_id": 6,
        "project_id": 3,
        "viewer_group_id": 8,
        "host_link": "http://yzvcei.localhost:3700/saml?host=true",
        "host_passcode": 360689
    }
}
```

{% endtab %}

{% tab title="200: OK No Deployment Found" %}

```javascript
{
    "status": {
        "success": false,
        "errorMessage": "No Deployment found"
    }
}
```

{% endtab %}
{% endtabs %}

## Get All Deployment

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/deployment/getAll`

Get all deployment by project uuid

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| projUuid<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": {
        "success": true
    },
    "data": [
        {
            "id": 1,
            "live": true,
            "slug": "my_first_metaverse",
            "settings": null,
            "created_at": "2022-09-05T08:13:57.415128",
            "modified_at": "2022-09-05T08:14:15.601",
            "organization_id": 6,
            "project_id": 3,
            "viewer_group_id": 6,
            "host_link": "http://yzvcei.localhost:3700/my_first_metaverse?host=true",
            "host_passcode": 388820
        },
        {
            "id": 3,
            "live": true,
            "slug": "saml",
            "settings": {
                "enable_multiplayer_mode": true
            },
            "created_at": "2022-09-08T10:34:19.006662",
            "modified_at": "2022-09-08T14:34:40.261",
            "organization_id": 6,
            "project_id": 3,
            "viewer_group_id": 8,
            "host_link": "http://yzvcei.localhost:3700/saml?host=true",
            "host_passcode": 360689
        },
        {
            "id": 2,
            "live": true,
            "slug": "my_first_metaverse_57",
            "settings": {
                "room_instance_count": 10,
                "enable_room_instance": true,
                "enable_multiplayer_mode": false,
                "room_instance_member_limit": 20
            },
            "created_at": "2022-09-05T08:26:04.685098",
            "modified_at": "2022-09-15T14:41:02.649",
            "organization_id": 6,
            "project_id": 3,
            "viewer_group_id": 1,
            "host_link": "http://yzvcei.localhost:3700/my_first_metaverse_57?host=true",
            "host_passcode": 374676
        },
        {
            "id": 5,
            "live": true,
            "slug": "test_sessions",
            "settings": null,
            "created_at": "2022-09-15T10:15:35.197385",
            "modified_at": "2022-09-20T14:37:39.449",
            "organization_id": 6,
            "project_id": 3,
            "viewer_group_id": 3,
            "host_link": "http://yzvcei.localhost:3700/test_sessions?host=true",
            "host_passcode": 332557
        },
        {
            "id": 6,
            "live": true,
            "slug": "my_first_metaverse_36",
            "settings": null,
            "created_at": "2022-09-27T07:00:21.664727",
            "modified_at": "2022-09-27T09:31:22.655",
            "organization_id": 6,
            "project_id": 3,
            "viewer_group_id": 1,
            "host_link": "http://yzvcei.localhost:3700/my_first_metaverse_36?host=true",
            "host_passcode": 320251
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Update Deployment

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/deployment/update`

Update deployment details by deployment.id

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | String |             |

#### Request Body

| Name                                           | Type    | Description                                                             |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------- |
| orgSlug<mark style="color:red;">\*</mark>      | String  |                                                                         |
| deploymentId<mark style="color:red;">\*</mark> | Number  | Unique id of the deployment                                             |
| slug                                           | String  | New deployment slug                                                     |
| settings                                       | Object  | RecordNode\<RT.deployment>                                              |
| viewerGroupId                                  | Number  | Unique id of the Viewer group this deployment belongs to                |
| live                                           | Boolean | set true will make deployment live and false will make it idle/inactive |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": {
        "success": true,
        "depSlug": "mitultest1-1666130455022" // deployment.slug
    }
}
```

{% endtab %}
{% endtabs %}

## Delete Deployment

<mark style="color:green;">`POST`</mark> `https://api.gmetri.com/sdk/deployment/delete`

Delete deployment by id

#### Headers

| Name                                            | Type   | Description       |
| ----------------------------------------------- | ------ | ----------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Token \<apiToken> |

#### Request Body

| Name                                           | Type   | Description                 |
| ---------------------------------------------- | ------ | --------------------------- |
| projUuid<mark style="color:red;">\*</mark>     | String |                             |
| deploymentId<mark style="color:red;">\*</mark> | Number | Unique id of the deployment |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": {
        "success": true,
        "depSlug": "mitultest1-1666130455022-1666210803862"
    }
}
```

{% endtab %}
{% endtabs %}
