Gateways-Create
  • 25 Oct 2024
  • 1 Minute to read
  • Dark
    Light

Gateways-Create

  • Dark
    Light

Article summary

A Gateway is a GPU-accelerated interface between on-premises network cameras and the Cogniac cloud. Gateway objects act as a configuration node for our on-premises box.

Name

Example

Description

gateway_id

"Ajr2t45p"

(readonly) Unique ID used to identify the gateway.

name

"Headquarters office gateway"

(optional) Gateway name should be brief and descriptive.

description

"Security cameras gateway"

(optional) Brief yet complete description of the gateway's focus.

location

"cogniac-hq"

(optional) Location of the gateway.

poll_interval

20

(optional) Interval for updates to gateway configuration in seconds. Defaults to 20 seconds, accepts values ≥ 1 second.

mac_address

"01-23-45-67-89-ab"

(readonly) MAC address of the gateway device, derived from the first discovered ethernet device. The value is immutable.

serial_number

"1234567-890-aabb"

(readonly) Serial number of the gateway device.

ip_address

"123.45.67.89"

(readonly) IP address of the gateway device, assigned based on the requesting device's IP during creation.

created_at

1463179215

(readonly) Unix timestamp indicating when the gateway was created.

modified_at

1463179215

(readonly) Unix timestamp indicating when the gateway was last modified.

created_by

"admin-user@cognicac.co"

(readonly) User who created the gateway.

tenant_id

"rt06diepwc3i"

(readonly) Tenant ID for the gateway.

POST /1/gateways
Host: https://api.cogniac.io

Example: Create Gateway

curl -X POST https://api.cogniac.io/1/gateways \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d '{
"name" : "test gateway",
"serial_number": "MF0X8EZ0-A821-21D3-AC0F-3897F789E41A",
"mac_address" : "98975699e41a",
"model" : "RM-M60X"
}'


import requests
import json
from pprint import pprint

url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}
gateway_data = {
"name" : "Fake non-existent gateway 2",
"serial_number": "MF0X8EZ0-A821-21D3-AC0F-3897F789E41A",
"mac_address" : "98975699e41a",
"model" : "RM-M60X"
}
url = f'{url_prefix}/{api_version}/gateways'
res = requests.post(url, json=gateway_data, headers=headers)

# Add the necessary logic for handling the 'status_code'
if res.status_code == 200:
    response_data = json.loads(res.content)
    pprint(response_data)
else:
    print(f"Error: {res.status_code}, {res.text}")

{
  "name" : "test gateway",
  "serial_number": "MF0X8EZ0-A821-21D3-AC0F-3897F789E41A",
  "mac_address" : "98975699e41a"
}
{
  "gateway_id": "Ajr2t45p!",
  "location": "cogniac-hq",
  "poll_interval": 20,
  "name": "test gateway",
  "description": "test gateway at cogniac",
  "created_at": 1463179215.124683,
  "modified_at": 1463179215.124683,
  "tenant_id": "rt06diepwc3i",
  "created_by": "test@cogniac.co",
  "ip_address": "127.0.0.1",
  "serial_number": "MF0X8EZ0-A821-21D3-AC0F-3897F789E41A",
  "mac_address" : "98975699e41a"
}

Update Gateway

POST /1/gateways/{gateway_id}
Host: https://api.cogniac.io
{
  "name": "updated gateway"
}
{
  "gateway_id": "Ajr2t45p",
	"location": "cogniac-hq",
	"poll_interval": 20,
  "name": "updated gateway",
  "description": "test gateway at cogniac",
  "created_at": 1463179215.124683,
  "modified_at": 1463179215.124683,
  "tenant_id": "rt06diepwc3i",
  "created_by": "test@cogniac.co",
  "ip_address": "127.0.0.1",
  "serial_number": "MF0X8EZ0-A821-21D3-AC0F-3897F789E41A",
  "mac_address" : "98975699e41a"
}

Delete Gateway

DELETE /1/gateways/{gateway_id}
Host: https://api.cogniac.io
HTTP 204 Code (with no body)

Admin Requirement

User must be a member of the Tenant's admin group to delete a gateway


Was this article helpful?