API: Input types

From Yombo
Jump to: navigation, search

Summary

Input types are used for user input validation. This can be used for entering device variables, device commands, and more. This allows the gateway to validate and optionally coerce user input into a certain formats.

GET - All input types

Retrieve all input types available to the current user. This includes public input types and private input types specific to the user.

Filters

List of available filters:

  • id
  • label
  • machine_label
  • description
  • public
  • status
  • created_at
  • updated_at

Request URLs

  • GET https://api.yombo.net/api/v1/input_type

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/input_type?_pagelimit=2
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/input_type?_pagelimit=2'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/input_type?_pagelimit=2",
 4         "uri_description": "List of input types.",
 5         "doc_uri": "https://yombo.net/API:Input_types",
 6         "input_type": [
 7             {
 8                 "id": "YnDNnDa6",
 9                 "category_id": "dD8X67zW",
10                 "machine_label": "x10_house",
11                 "label": "X10 House",
12                 "description": "X10 House code only. A letter A-P.",
13                 "input_regex": "",
14                 "public": 2,
15                 "status": 1,
16                 "created_at": 1482065387,
17                 "updated_at": 1482065387,
18                 "category_label": "X10",
19                 "category_type": "input_type"
20             },
21             {
22                 "id": "PLDAaDBX",
23                 "category_id": "dD8X67zW",
24                 "machine_label": "x10_unit",
25                 "label": "X10 Unit Code",
26                 "description": "An X10 unit code. A number between 1 and 16.",
27                 "input_regex": "",
28                 "public": 2,
29                 "status": 1,
30                 "created_at": 1482065387,
31                 "updated_at": 1482065387,
32                 "category_label": "X10",
33                 "category_type": "input_type"
34             }
35         ],
36         "locator": "input_type",
37         "locator_type": "objects"
38     },
39     "code": 200,
40     "warnings": [],
41     "pages": {
42         "total_items": 28,
43         "page_limit": 2,
44         "total_pages": 14,
45         "page_start": 1
46     },
47     "message": "OK",
48     "html_message": "OK"
49 }

GET - Specific input type

Retrieve a specific input type id.

Request URLs

  • GET https://api.yombo.net/api/v1/input_type/{input_type_id}

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/input_type/aWvzB0ENZ23JO
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/input_type/aWvzB0ENZ23JO
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/input_type/YnDNnDa6",
 4         "uri_description": "Detailed information for a single input type.",
 5         "doc_uri": "https://yombo.net/API:Input_types",
 6         "input_type": {
 7             "id": "YnDNnDa6",
 8             "category_id": "dD8X67zW",
 9             "machine_label": "x10_house",
10             "label": "X10 House",
11             "description": "X10 House code only. A letter A-P.",
12             "input_regex": "",
13             "public": 2,
14             "status": 1,
15             "created_at": 1482065387,
16             "updated_at": 1482065387,
17             "category_label": "X10",
18             "category_type": "input_type"
19         },
20         "locator": "input_type",
21         "locator_type": "object"
22     },
23     "code": 200,
24     "warnings": [],
25     "message": "OK",
26     "html_message": "OK"
27 }

POST - Create new input type

Creates a new input type. Rules for public and status fields apply.

Request URLs

  • POST https://api.yombo.net/api/v1/input_type

Parameters

Name Type Description
Required
machine_name string Machine name for this input type. Once set, this cannot be changed. Can only contain: a-z and _ (underscore).
label string A short human friendly label for the input type.
description string A detailed description of what the input type checks for.
category_id string What category this input type belongs to. Be sure to use a 'category type' of 'input_type'.
Optional
input_regex string A regex string that is used to validate the input.
status integer Default: 1 - Status for the input type.
public integer Default: 0 - If the input type should be public.

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X POST -d '{"label": "New Input Type", "machine_name": "new_input_type",
"description": "A new input type.", "category_id": "Zr8Raq01"}' \
https://api.yombo.net/api/v1/input_type
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/input_type'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

payload = {
    "label": "New Input Type",
    "machine_name": "new_input_type",
    "description": "A new input type.",
    "category_id": "Zr8Raq01"
    }

response = requests.post(url, headers=headers, json=payload)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/input_type",
 4         "uri_description": "Create new input type.",
 5         "doc_uri": "https://yombo.net/docs/api/#input-types",
 6         "input_type": {
 7             "machine_label": "new_input_type",
 8             "label": "New Input Type",
 9             "description": "A new input type.",
10             "category_id": "Zr8Raq01",
11             "updated_at": 1518689953,
12             "created_at": 1518689953,
13             "id": "b6QxVNwj"
14         },
15         "locator": "input_type",
16         "locator_type": "object"
17     },
18     "code": 201,
19     "warnings": [],
20     "message": "Created",
21     "html_message": "Created"
22 }

PUT / PATCH - Update an input type

Update an input type. When using PUT, all required parameters must be sent. When using PATCH, only send in desired changes.

Request URLs

  • PATCH https://api.yombo.net/api/v1/input_type/{input_type_id}
  • PUT https://api.yombo.net/api/v1/input_type/{input_type_id}

Parameters

See post new input type parameters.

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X PUT -d '{"description": "A new input type, that does everything."}' \
https://api.yombo.net/api/v1/input_type/WQ9akXabloyqb
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/input_type/WQ9akXabloyqb'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

payload = {
    "description": "A new input type, that does everything.",
    }

response = requests.put(url, headers=headers, json=payload)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/input_type/b6QxVNwj",
 4         "uri_description": "Update (patch) input type.",
 5         "doc_uri": "https://yombo.net/API:Input_types",
 6         "input_type": {
 7             "id": "b6QxVNwj",
 8             "category_id": "Zr8Raq01",
 9             "machine_label": "new_input_type",
10             "label": "New Input Type",
11             "description": "A new input type, that does everything.",
12             "platform": null,
13             "public": 0,
14             "status": 1,
15             "created_at": 1518689953,
16             "updated_at": 1518690221,
17             "category_label": "Input Type",
18             "category_type": "input_type"
19         },
20         "locator": "input_type",
21         "locator_type": "object"
22     },
23     "code": 200,
24     "warnings": [],
25     "message": "Updated",
26     "html_message": "Updated"
27 }

DELETE - Delete a input type

Delete an input type. This doesn't actually delete the input type right away, but simply marks it for deletion later. This is the same as setting the status to 2. To undelete the input type, simply change the status back to 1.

Request URLs

  • DELETE https://api.yombo.net/api/v1/input_type/{input_type_id}

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X DELETE https://api.yombo.net/api/v1/input_type/b6QxVNwj
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/input_type/b6QxVNwj'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

response = requests.put(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/input_type/b6QxVNwj",
 4         "uri_description": "Delete a input type.",
 5         "doc_uri": "https://yombo.net/API:Input_types",
 6         "input_type": "Deleted",
 7         "locator": "input_type",
 8         "locator_type": "string"
 9     },
10     "code": 200,
11     "warnings": [],
12     "message": "Deleted",
13     "html_message": "Deleted"
14 }
This page was last edited on 14 September 2018.