# SCIM Host examples

## Operations

This page shows the operations that can be performed for the host object.

### List all

##### Request

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/Host
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 12,
    "startIndex": 1,
    "Resources": [
        {
            "serialNumber": "soffid.bubu.lab:192.168.133.1",
            "os": "ALT",
            "mail": false,
            "ip": "192.168.133.1",
            "dynamicIp": true,
            "description": "Autocreated on  12/13/20 6:49:34 PM",
            "office": false,
            "lastSeen": "2020-12-13 18:49:34",
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1039055",
                "resourceType": "Host"
            },
            "networkCode": "internal",
            "schemas": [
                "urn:soffid:com.soffid.iam.am.api.Host"
            ],
            "name": "soffid.bubu.lab",
            "id": 1039055,
            "hostAlias": [],
            "printersServer": false
        },
        {
            "os": "ALT",
            "mail": false,
            "ip": "10.129.120.4",
            "dynamicIp": false,
            "description": "Discovered host iam.soffid.com",
            "office": false,
            "lastSeen": "2021-04-05 20:06:19",
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1793093",
                "resourceType": "Host"
            },
            "networkCode": "lab1",
            "schemas": [
                "urn:soffid:com.soffid.iam.am.api.Host"
            ],
            "name": "iam.soffid.com",
            "id": 1793093,
            "hostAlias": [],
            "printersServer": false
        },
      ........
    ]
}
```

### List by filter

List all Hosts with a filter expression.

<p class="callout info">It is allowed to use pagination and sort the information, for more information visit the [Sorting](https://bookstack.soffid.com/link/116#bkmrk-sorting) and [Pagination](https://bookstack.soffid.com/link/116#bkmrk-pagination) information.</p>

##### Request

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/Host?filter=os eq LIN and name co archiva
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 1,
    "startIndex": 1,
    "Resources": [
        {
            "os": "LIN",
            "mail": false,
            "ip": "10.129.120.2",
            "dynamicIp": false,
            "description": "Discovered host archiva.dev.lab",
            "office": false,
            "lastSeen": "2021-04-05 20:04:49",
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1793026",
                "resourceType": "Host"
            },
            "networkCode": "lab1",
            "schemas": [
                "urn:soffid:com.soffid.iam.am.api.Host"
            ],
            "name": "archiva.dev.lab",
            "id": 1793026,
            "hostAlias": [],
            "printersServer": false
        }
    ]
}
```

### Query by id

Query a Host by its id (primary key).

##### Request

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/Host/1793093
```

##### Response 200 OK

```JSON
{
    "os": "ALT",
    "mail": false,
    "ip": "10.129.120.4",
    "dynamicIp": false,
    "description": "Discovered host iam.soffid.com",
    "office": false,
    "lastSeen": "2021-04-05 20:06:19",
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1793093",
        "resourceType": "Host"
    },
    "networkCode": "lab1",
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "name": "iam.soffid.com",
    "id": 1793093,
    "hostAlias": [],
    "printersServer": false
}
```

### Create

#### Request

```XML
POST https://<your-domain>/soffid/webservice/scim2/v1/Host
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "name": "billing.dev.lab",
    "description": "Host billing.dev.lab",
    "os": "LIN",
    "mail": false,
    "dynamicIp": false,
    "networkCode": "internal",
    "hostAlias": [
        "aliasHost_1",
        "aliasHost_2"
    ],
    "serialNumber": "123456789",
    "printersServer": false
}
```

##### Response 201 Created

```JSON
{
    "serialNumber": "123456789",
    "os": "LIN",
    "mail": false,
    "dynamicIp": false,
    "description": "Host billing.dev.lab",
    "office": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1976899",
        "resourceType": "Host"
    },
    "networkCode": "internal",
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "name": "billing.dev.lab",
    "id": 1976899,
    "hostAlias": [
      "aliasHost_1",
      "aliasHost_2"
    ],
    "printersServer": false
}
```

### Update partial

Only attributes with changes will be updated, the other will maintain the same value.

##### Request

```XML
PATCH https://<your-domain>/soffid/webservice/scim2/v1/Host/1976899
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "Operations": [
        {
            "op": "replace",
            "path": "networkCode",
            "value": "Lab1"
        },
        {
            "op": "add",
            "path": "hostAlias",
            "value": [
                "aliasHost_3",
                "aliasHost_4"
            ]
        }
    ]
}
```

##### Response 200 OK

```JSON
{
    "serialNumber": "123456789",
    "os": "LIN",
    "mail": false,
    "dynamicIp": false,
    "description": "Host billing.dev.lab",
    "office": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1976899",
        "resourceType": "Host"
    },
    "networkCode": "Lab1",
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "name": "billing.dev.lab",
    "id": 1976899,
    "hostAlias": [
        "aliasHost_1",
        "aliasHost_2",
        "aliasHost_3",
        "aliasHost_4"
    ],
    "printersServer": false
}
```

### Update all

This operation replaces all values in the Hosts.

- Note that the attribute id is required to confirm that the resource "...Host/&lt;id&gt;" is the same that the JSON Host.
- Note that all the attributes not included in the request will be cleared in the Host type and their data will be lost.
- Note that not all the attributes are updatable, for example, tag meta, avoid these tags. For more information visit [Resource data model page](https://bookstack.soffid.com/books/scim/chapter/resource-data-model-schema)

##### Request

```XML
PUT https://<your-domain>/soffid/webservice/scim2/v1/Host/1976899
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "id": 1976899,
    "name": "billing.dev.lab",
    "description": "Host billing.dev.lab",
    "os": "LIN",
    "mail": false,
    "dynamicIp": false,
    "networkCode": "internal",   
    "printersServer": false
}
```

##### Response 200 OK

```JSON
{
    "os": "LIN",
    "mail": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Host/1976899",
        "resourceType": "Host"
    },
    "networkCode": "internal",
    "schemas": [
        "urn:soffid:com.soffid.iam.am.api.Host"
    ],
    "name": "billing.dev.lab",
    "dynamicIp": false,
    "description": "Host billing.dev.lab",
    "id": 1976899,
    "hostAlias": [],
    "printersServer": false
}
```

### Delete

<p class="callout warning">Please note after this delete, the host has to be created again to use it in the next examples.</p>

##### Request

```MarkDown
DELETE https://<your-omain>/soffid/webservice/scim2/v1/Host/1976899
```

##### Response 204 No Content

```
204 No Content
```

### Error response

<p class="callout info">For more information about error response visit [https://bookstack.soffid.com/link/116#bkmrk-error-response](https://bookstack.soffid.com/link/116#bkmrk-error-response)</p>