# Machine Registry

## /apis/anagraphics

All the machines that make up a project are described through a series of textual information. To retrieve this information, you can use the following endpoint:

<details>

<summary>Request</summary>

```
HTTP
GET https://{BASE_URL}/apis/anagraphics
```

</details>

By making an HTTP GET request to the specified endpoint, you can retrieve information about all the machines belonging to the project.

### Example

<details>

<summary>Request</summary>

```
HTTP
GET https://matdev.40mat.com/apis/anagraphics
```

</details>

<details>

<summary>Response</summary>

```json
JSON
[
    {
        "customer": "40Factory",
        "customerId": "Line",
        "excludeLine": true,
        "id": "MCCabcabcabcabcabcabcabcabcabcabcabc",
        "location": {
            "latitude": "45.035863",
            "longitude": "9.759874"
        },
        "machineId": "40-line",
        "machineName": "CB231294",
        "machineReference": "M1",
        "machines": {
            "M1": {
                "components": [
                    "motor1",
                    "motor2"
                ]
            },
            "M2": {}
        },
        "model": "Wrapper Machine",
        "parentId": "subtentants/Line",
        "plant": "Piacenza",
        "settings": {
            "cons0Cost": 0.01,
            "cons0RelMean": 10.976927607602123,
            "cons0RelStd": 0.5301137150152502,
            "cons1Cost": 0.000131,
            "cons1RelMean": 1.0349332185509406,
            "cons1RelStd": 0.3433522379337663,
            "cons2Cost": 120,
            "cons2RelMean": 0.0015269034720833677,
            "cons2RelStd": 6.469884712715801e-05,
            "cons3Cost": 600,
            "cons3RelMean": 0.0001470083005766097,
            "cons3RelStd": 0.0022844333558226498,
            "nSigma": 1,
            "trainingEnd": "2024-03-08T23:00:00.000Z",
            "trainingStart": "2024-02-04T23:00:00.000Z"
        },
        "timezone": "Europe/Rome",
        "typeId": null
    },
    {
        "customer": "40Factory",
        "customerId": "Line",
        "excludeLine": true,
        "id": "MCCcdecdecdecdecdecdecdecdecdecdecdecdecde",
        "location": {
            "latitude": "45.035863",
            "longitude": "9.759874"
        },
        "machineId": "40-machine",
        "machineName": "CB231295",
        "machineReference": "M1",
        "machines": {
            "M1": {
                "components": [
                    "motor1",
                    "motor2"
                ]
            },
            "M2": {}
        },
        "model": "Pallettizer Machine",
        "parentId": "subtentants/Line",
        "plant": "Piacenza",
        "settings": {
            "cons0Cost": 0.01,
            "cons0RelMean": 10.976927607602123,
            "cons0RelStd": 0.5301137150152502,
            "cons1Cost": 0.000131,
            "cons1RelMean": 1.0349332185509406,
            "cons1RelStd": 0.3433522379337663,
            "cons2Cost": 120,
            "cons2RelMean": 0.0015269034720833677,
            "cons2RelStd": 6.469884712715801e-05,
            "cons3Cost": 600,
            "cons3RelMean": 0.0001470083005766097,
            "cons3RelStd": 0.0022844333558226498,
            "nSigma": 1,
            "trainingEnd": "2024-03-08T23:00:00.000Z",
            "trainingStart": "2024-02-04T23:00:00.000Z"
        },
        "timezone": "Europe/Rome",
        "typeId": null
    }
]
```

</details>

### Code

{% tabs %}
{% tab title="Python" %}

```python
import requests
import json

# Example data for the header
headers = {
    'App-Name': 'matdev-be',
    'Authorization': 'Bearer ey....xy1w'
}

# URL of the third-party API
myDomain = 'matdev.40mat.com'
endpoint = '/apis/anagraphics'
url = f'https://{myDomain}{endpoint}'


# Make the POST request
response = requests.get(url, headers=headers, )

# Check the response status and return the data
if response.status_code == 200:
    print('Success:')
    print(json.dumps(response.json(), indent=4))
else:
    print('Request failed:')
    print(f'Status code: {response.status_code}')
    print(response.text)

```

{% endtab %}
{% endtabs %}

### OpenAPI

{% openapi src="<https://content.gitbook.com/content/L65nhvmBlLI1fH4sd9ut/blobs/KAvOsMKNpCkRaukQxFnU/OpenAPI_simpliefiedAPIs.yml>" path="/apis/anagraphics" method="get" %}
[OpenAPI\_simpliefiedAPIs.yml](https://content.gitbook.com/content/L65nhvmBlLI1fH4sd9ut/blobs/KAvOsMKNpCkRaukQxFnU/OpenAPI_simpliefiedAPIs.yml)
{% endopenapi %}

## /apis/anagraphics/\<assetId>

To retrieve the information that describes a specific machine in a project, you can use the following endpoint:

<details>

<summary>Request</summary>

```
HTTP
GET https://{BASE_URL}/apis/anagraphics/<assetId>
```

`assetId` : represents the unique ID of the machine you are interested in.

</details>

### Example

<details>

<summary>Request</summary>

```
HTTP
GET https://matdev.40mat.com/apis/anagraphics/40-line
```

</details>

<details>

<summary>Response</summary>

```json
JSON
[
    {
        "customer": "40Factory",
        "customerId": "Line",
        "excludeLine": true,
        "id": "MCCabcabcabcabcabcabcabcabcabcabcabc",
        "location": {
            "latitude": "45.035863",
            "longitude": "9.759874"
        },
        "machineId": "40-line",
        "machineName": "CB231294",
        "machineReference": "M1",
        "machines": {
            "M1": {
                "components": [
                    "motor1",
                    "motor2"
                ]
            },
            "M2": {}
        },
        "model": "Wrapper Machine",
        "parentId": "subtentants/Line",
        "plant": "Piacenza",
        "settings": {
            "cons0Cost": 0.01,
            "cons0RelMean": 10.976927607602123,
            "cons0RelStd": 0.5301137150152502,
            "cons1Cost": 0.000131,
            "cons1RelMean": 1.0349332185509406,
            "cons1RelStd": 0.3433522379337663,
            "cons2Cost": 120,
            "cons2RelMean": 0.0015269034720833677,
            "cons2RelStd": 6.469884712715801e-05,
            "cons3Cost": 600,
            "cons3RelMean": 0.0001470083005766097,
            "cons3RelStd": 0.0022844333558226498,
            "nSigma": 1,
            "trainingEnd": "2024-03-08T23:00:00.000Z",
            "trainingStart": "2024-02-04T23:00:00.000Z"
        },
        "timezone": "Europe/Rome",
        "typeId": null
    }
]
```

</details>

### Code

{% tabs %}
{% tab title="Python" %}

```python
import requests
import json

# Example data for the header
headers = {
    'App-Name': 'matdev-be',
    'Authorization': 'Bearer ey....xy1w'
}

# URL of the third-party API
myDomain = 'matdev.40mat.com'
myAssetId = '40-line'
endpoint = f'/apis/anagraphics/{myAssetId}'
url = f'https://{myDomain}{endpoint}'


# Make the POST request
response = requests.get(url, headers=headers, )

# Check the response status and return the data
if response.status_code == 200:
    print('Success:')
    print(json.dumps(response.json(), indent=4))
else:
    print('Request failed:')
    print(f'Status code: {response.status_code}')
    print(response.text)
```

{% endtab %}
{% endtabs %}

### OpenAPI

{% openapi src="<https://content.gitbook.com/content/L65nhvmBlLI1fH4sd9ut/blobs/KAvOsMKNpCkRaukQxFnU/OpenAPI_simpliefiedAPIs.yml>" path="/apis/anagraphics/{assetId}" method="get" %}
[OpenAPI\_simpliefiedAPIs.yml](https://content.gitbook.com/content/L65nhvmBlLI1fH4sd9ut/blobs/KAvOsMKNpCkRaukQxFnU/OpenAPI_simpliefiedAPIs.yml)
{% endopenapi %}
