**Sites** ================ **Create a New Site** ++++++++++++++++++++++++ .. http:post:: /_config/sites/ **Description** Create a new site with the specified site information. **HTTP Method** POST **Endpoint:** ``/_config/sites/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** Body Parameters - ``site_name`` (string, *required*): The name of the site. - ``location`` (string, *required*): The location of the site. - ``edge_firmware`` (object, *required*): Information about the edge firmware, including the `current_version` and `previous_version`. - ``timezone`` (string, *required*): The timezone of the site. - ``latitude`` (string, *required*): Latitude of the site. - ``longitude`` (string, *required*): Longitude of the site. - ``retention_period`` (long, *optional*): Time period of data retention of the site(collected in months,by default it is 6 months).The value by default is 180 days or 6 months. .. note:: - Parameter "retention_period" although collected from user in number of months, is sent as number of days through the Request. **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/sites/' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ' \ -data '{ "site_name": "sample_site_0", "location": "bangalore", "latitude": "", "longitude": "", "timezone": "UTC", "retention_period": 180, "edge_firmware": { "current_version": "1.0.9", "previous_version": "" } }' **Sample Response** Success .. sourcecode:: json { "id": "5e175ff8-6d1b-4092-ace1-e6eeb8535065" } Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Content Type" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient Inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "sample_site_0 already exists" } } .. sourcecode:: json { "error": { "status": 400, "message": "Error occured during site creation" } } **Delete Site** ++++++++++++++++++++ .. http:delete:: /_config/sites/ **Description** Delete a specific site by its ID. **HTTP Method** DELETE **Endpoint** ``/_config/sites/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** URL Parameters - ``site_id`` (string, *required*) The ID of the site to delete. **Sample Request** .. code-block:: sh curl --location --request DELETE 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \ --header 'Authorization: Basic ' \ --data '' **Sample Response** Success .. sourcecode:: text "Site deleted" Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid site 12380-32974-8291-29273" } } .. sourcecode:: json { "error": { "status": 400, "message": "Plants exists on this site" } } **Update Site** +++++++++++++++++++++ .. http:put:: /_config/sites/ **Description** Update the information of a specific site by its ID. **HTTP Method** PUT **Endpoint** ``/_config/sites/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** Body Parameters - ``location`` (string, *required*): The updated location of the site. - ``timezone`` (string, *optional*): The updated timezone of the site. - ``edge_firmware`` (object, *optional*): Updated information about the edge firmware, including the `current_version` and `previous_version`. - ``latitude`` (string, *optional*): Latitude of the site. - ``longitude`` (string, *optional*): Longitude of the site. - ``retention_period`` (long, *required*): The updated time period of data retention of the site(collected in months,by default it is 6 months). URL Parameters - ``site_id`` (string, *required*) The ID of the site to update. **Sample Request** .. code-block:: sh curl --location --request PUT 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ' \ --data '{ "site_name": "sample_site_0", "location": "Karnataka", "latitude": "45", "longitude": "90", "timezone": "US/Samoa", "retention_period" : 180, "edge_firmware": { "current_version": "1.0.9", "previous_version": "" } }' **Sample Response** Success .. sourcecode:: json "Site Updated" Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Content Type" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient Inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid site" } } **Fetch Site** +++++++++++++++++++++ .. http:get:: /_config/sites/ **Description** Retrieve details of a specific site by its ID. **HTTP Method** GET **Endpoint** ``/_config/sites/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** URL Parameters - ``site_id`` (string, *required*): The ID of the site for which you want to retrieve details. **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/sites/5e175ff8-6d1b-4092-ace1-e6eeb8535065' \ --header 'Authorization: Basic ' **Sample Response** Success .. code-block:: json [ { "site_name": "sample_site_0", "location": "Karnataka", "latitude": "45", "longitude": "90", "edge_firmware": { "current_version": "1.0.8", "previous_version": "" }, "timezone": "US/Samoa", "retention_period": 180, "site_id": "5e175ff8-6d1b-4092-ace1-e6eeb8535065" } ] Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Site 5476481-48e5-b2a0-ae810a948839" } } .. sourcecode:: json { "error": { "status": 405, "message": "Method Not Allowed" } } **Fetch List of Sites** +++++++++++++++++++++++++++++ .. http:GET:: /_config/sites/_list **Description** Retrieve a list of all available sites. **HTTP Method** GET **Endpoint** ``/_config/sites/_list`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** None **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/sites/_list' \ --header 'Authorization: Basic ' **Sample Response** Success .. code-block:: json [ { "site_name": "firmware test", "location": "test", "latitude": "1", "longitude": "-1", "edge_firmware": { "previous_version": "1.0.8", "current_version": "1.0.13", "latest_version": "1.0.13" }, "retention_period": 180, "timezone": "Asia/Kolkata", "site_id": "d83f2d95-f099-41ce-958b-e9472a3e556a" }, { "site_name": "4PX Test", "location": "4PX Lab Bengaluru", "latitude": "0", "longitude": "0", "site_id": "4230adcb-f349-4780-bf79-4a8c94a3b13b", "edge_firmware": { "previous_version": "1.0.9", "current_version": "1.0.12", "latest_version": "1.0.13" }, "retention_period": 180, "timezone": "Asia/Kolkata" }, ] Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } }