Inventory Objects
~~~~~~~~~~~~~~~~~

.. http:get:: /api/v2/objects/

   List of inventory objects.

   **Example request**:

   .. sourcecode:: http

      GET /api/v2/objects/ HTTP/1.1

   **Example response**:

   .. sourcecode:: http

      HTTP 200 OK
      Content-Type: application/json
      Vary: Accept
      Allow: GET, POST, HEAD, OPTIONS

      [
          {
              "id": 353,
              "name": "ci-slave13-scc.fuel-infra.org",
              "location": {
                   "name": "Moscow",
                   "fact": "msk"
              },
              "type": {
                   "name": "HW Server"
              },
              "labels": [],
              "attributes": {
                  "zabbix_host_id": "10586",
                  "puppet_manifests_version": "$Id: 705d0793d2b22d879ec5132c9148685976c68dac $",
                  "fqdn": "ci-slave13-scc.fuel-infra.org",
                  "hardware": ""
              },
              "responsible": []
          },
          ...
      ]

   :query sort: one of ``id``, ``-id``
   :query name: object name
   :query responsible: responsible user id
   :query location__fact: location fact
   :query type__name: type name

.. http:post:: /api/v2/objects/

   Create inventory object.

   **Example request**:

   .. sourcecode:: http

      POST /api/v2/objects/ HTTP/1.1

      {
          "attributes": {
              "fqdn": "myhost.local",
              "zabbix_host_id": "11235"
          },
          "labels": [],
          "location": null,
          "name": "myhost.local",
          "responsible": [],
          "type": null
      }


   **Example response**:

   .. sourcecode:: http

      HTTP/1.1 200 OK

      {
          "attributes": {
              "fqdn": "myhost.local",
              "zabbix_host_id": "11235"
          },
          "labels": [],
          "location": null,
          "name": "myhost.local",
          "responsible": [],
          "type": null
      }


.. http:put:: /api/v2/objects/(int:id)/

   **Example request**:

   .. sourcecode:: http

      PUT /api/v2/objects/ HTTP/1.1

      {
          "attributes": {
              "fqdn": "myhost.local",
              "zabbix_host_id": "11235"
          },
          "id": 1,
          "labels": [],
          "location": null,
          "name": "myhost.local",
          "responsible": [],
          "type": null
      }

   **Example response**:

   .. sourcecode:: http

      HTTP/1.1 200 OK

      {
        "attributes": {
            "fqdn": "myhost.local",
            "zabbix_host_id": "11235"
        },
        "id": 1,
        "labels": [],
        "location": null,
        "name": "myhost.local",
        "responsible": [],
        "type": null
      }


.. http:patch:: /api/v2/objects/(int:id)/

   **Example request**:

   .. sourcecode:: http

      PATCH /api/v2/objects/1/ HTTP/1.1

      {
          "location": {"fact": "newfact"},
          "type": {"name": "newtype"},
      }

   **Example response**:

   .. sourcecode:: http

      HTTP/1.1 200 OK

      {
        "attributes": {
            "fqdn": "myhost.local",
            "zabbix_host_id": "11235"
        },
        "id": 1,
        "labels": [],
        "location": {"name": null, "fact": "newfact"},
        "name": "myhost.local",
        "responsible": [],
        "type": {"name": "newtype"}
      }


.. http:delete:: /api/v2/objects/(int:id)/

   **Example request**:

   .. sourcecode:: http

      DELETE /api/v2/objects/ HTTP/1.1

   **Example response**:

   .. sourcecode:: http

      HTTP/1.1 204 No Content
