Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.45 KB | None | 0 0
  1. openapi: 3.0.0
  2. servers:
  3. - url: 'http://35.160.74.40:8088/'
  4. - url: 'http://127.0.0.1:8088/'
  5. info:
  6. description: 420bits API integration documentation
  7. version: "0.0.1-oas3"
  8. title: 420bits Open API
  9. contact:
  10. email: bits420bits@gmail.com
  11. license:
  12. name: Apache 2.0
  13. url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
  14. paths:
  15. /auth:
  16. post:
  17. tags:
  18. - Auth
  19. summary: Authentication
  20. description: Creates an authentication session
  21. responses:
  22. '200':
  23. description: Credentials
  24. content:
  25. application/json:
  26. schema:
  27. $ref: '#/components/schemas/AuthResponse'
  28. '201':
  29. description: Invalid credentials
  30. content:
  31. application/json:
  32. schema:
  33. $ref: '#/components/schemas/DefaultErrorResponse'
  34. requestBody:
  35. content:
  36. application/json:
  37. schema:
  38. $ref: '#/components/schemas/AuthRequest'
  39. description: User to be created
  40. required: true
  41. /users:
  42. post:
  43. tags:
  44. - Users
  45. summary: Creates a new user
  46. description: Adds a user to the system
  47. parameters:
  48. - $ref: '#/components/parameters/Jwt'
  49. responses:
  50. '200':
  51. description: Success - Authenticate the user and return the credentials
  52. content:
  53. application/json:
  54. schema:
  55. $ref: '#/components/schemas/AuthResponse'
  56. '201':
  57. description: Invalid data
  58. content:
  59. application/json:
  60. schema:
  61. $ref: '#/components/schemas/DefaultErrorResponse'
  62. requestBody:
  63. content:
  64. application/json:
  65. schema:
  66. $ref: '#/components/schemas/CreateUserRequest'
  67. description: User to be created
  68. required: true
  69. delete:
  70. tags:
  71. - Users
  72. summary: Deletes user
  73. description: Delets a user
  74. parameters:
  75. - $ref: '#/components/parameters/Jwt'
  76. responses:
  77. '200':
  78. description: Success
  79. content:
  80. application/json:
  81. schema:
  82. $ref: '#/components/schemas/DeleteUserResponse'
  83. '201':
  84. description: Invalid data
  85. content:
  86. application/json:
  87. schema:
  88. $ref: '#/components/schemas/DefaultErrorResponse'
  89. requestBody:
  90. content:
  91. application/json:
  92. schema:
  93. $ref: '#/components/schemas/DeleteUserRequest'
  94. description: User id to be deleted
  95. required: true
  96. /places:
  97. post:
  98. tags:
  99. - Places
  100. summary: Create or update a place
  101. description: Create or update a new place information.
  102. parameters:
  103. - $ref: '#/components/parameters/Jwt'
  104. responses:
  105. '200':
  106. description: Success
  107. content:
  108. '*/*':
  109. schema:
  110. $ref: '#/components/schemas/CreatePlaceResponse'
  111. '201':
  112. description: Invalid data
  113. content:
  114. '*/*':
  115. schema:
  116. $ref: '#/components/schemas/DefaultErrorResponse'
  117. requestBody:
  118. content:
  119. application/json:
  120. schema:
  121. $ref: '#/components/schemas/CreatePlaceRequest'
  122. description: >-
  123. The information of the place will be created. Include the `_id` field
  124. if you want to update the information.
  125. required: true
  126. get:
  127. tags:
  128. - Places
  129. summary: Places list endpoint
  130. description: Returns the list of places the user has access to
  131. parameters:
  132. - $ref: '#/components/parameters/Jwt'
  133. responses:
  134. '200':
  135. description: Success
  136. content:
  137. application/json:
  138. schema:
  139. $ref: '#/components/schemas/GetPlacesResponse'
  140. '201':
  141. description: Invalid data
  142. content:
  143. application/json:
  144. schema:
  145. $ref: '#/components/schemas/DefaultErrorResponse'
  146. delete:
  147. tags:
  148. - Places
  149. summary: Delete a place
  150. description: Delete a place that the user has access to
  151. parameters:
  152. - $ref: '#/components/parameters/Jwt'
  153. responses:
  154. '200':
  155. description: Success
  156. content:
  157. application/json:
  158. schema:
  159. $ref: '#/components/schemas/DeletePlaceResponse'
  160. '201':
  161. description: Invalid data
  162. content:
  163. application/json:
  164. schema:
  165. $ref: '#/components/schemas/DefaultErrorResponse'
  166. requestBody:
  167. content:
  168. application/json:
  169. schema:
  170. $ref: '#/components/schemas/DeletePlaceRequest'
  171. description: Place id to be deleted
  172. required: true
  173. /rooms:
  174. post:
  175. tags:
  176. - Rooms
  177. summary: Create or update a room information
  178. description: Create or update a room information
  179. parameters:
  180. - $ref: '#/components/parameters/Jwt'
  181. responses:
  182. '200':
  183. description: Success
  184. content:
  185. '*/*':
  186. schema:
  187. $ref: '#/components/schemas/CreateRoomResponse'
  188. '201':
  189. description: Invalid data
  190. content:
  191. '*/*':
  192. schema:
  193. $ref: '#/components/schemas/DefaultErrorResponse'
  194. requestBody:
  195. content:
  196. application/json:
  197. schema:
  198. $ref: '#/components/schemas/CreateRoomRequest'
  199. description: >-
  200. The information of the room will be created. Include the `_id` field
  201. if you want to update the information.
  202. required: true
  203. get:
  204. tags:
  205. - Rooms
  206. summary: Get a list of rooms
  207. description: Returns all the rooms of a specific place
  208. parameters:
  209. - $ref: '#/components/parameters/place_id'
  210. - $ref: '#/components/parameters/Jwt'
  211. responses:
  212. '200':
  213. description: Success
  214. content:
  215. '*/*':
  216. schema:
  217. $ref: '#/components/schemas/GetReoomsResponse'
  218. '201':
  219. description: Invalid data
  220. content:
  221. '*/*':
  222. schema:
  223. $ref: '#/components/schemas/DefaultErrorResponse'
  224. delete:
  225. tags:
  226. - Rooms
  227. summary: Delete a room
  228. description: Delete a room the user has access to
  229. parameters:
  230. - $ref: '#/components/parameters/Jwt'
  231. responses:
  232. '200':
  233. description: Success
  234. content:
  235. application/json:
  236. schema:
  237. $ref: '#/components/schemas/DeleteRoomResponse'
  238. '201':
  239. description: Invalid data
  240. content:
  241. application/json:
  242. schema:
  243. $ref: '#/components/schemas/DefaultErrorResponse'
  244. requestBody:
  245. content:
  246. application/json:
  247. schema:
  248. $ref: '#/components/schemas/DeleteRoomRequest'
  249. description: Room id to be deleted
  250. required: true
  251. /accessory_setup_session:
  252. post:
  253. tags:
  254. - Accessory setup session
  255. summary: Creates a session to setup a new acccessory
  256. description: 'In order to create a new accessory, a session toke is requried'
  257. parameters:
  258. - $ref: '#/components/parameters/Jwt'
  259. - $ref: '#/components/parameters/room_id'
  260. responses:
  261. '200':
  262. description: Success
  263. content:
  264. '*/*':
  265. schema:
  266. $ref: '#/components/schemas/AccessorySetupSessionResponse'
  267. '201':
  268. description: Invalid data
  269. content:
  270. '*/*':
  271. schema:
  272. $ref: '#/components/schemas/DefaultErrorResponse'
  273. '/accessories/[accessory_id]':
  274. post:
  275. tags:
  276. - Accessories
  277. summary: Update accessory
  278. description: >-
  279. Update accessory information given an accessory id. Include ONLY the
  280. parameters you want to update.
  281. parameters:
  282. - $ref: '#/components/parameters/Jwt'
  283. responses:
  284. '200':
  285. description: Success
  286. content:
  287. '*/*':
  288. schema:
  289. $ref: '#/components/schemas/CreateAccessoryObject'
  290. '201':
  291. description: Invalid data
  292. content:
  293. '*/*':
  294. schema:
  295. $ref: '#/components/schemas/DefaultErrorResponse'
  296. requestBody:
  297. content:
  298. application/json:
  299. schema:
  300. $ref: '#/components/schemas/CreateAccessoryObject'
  301. description: The information of the accessories will be updated.
  302. required: true
  303. /accessories:
  304. get:
  305. tags:
  306. - Accessories
  307. summary: All the accessories use has access to
  308. description: This API will return a single list of accessories the use has access to.
  309. parameters:
  310. - $ref: '#/components/parameters/Jwt'
  311. responses:
  312. '200':
  313. description: Success
  314. content:
  315. '*/*':
  316. schema:
  317. $ref: '#/components/schemas/GetAccessoriesResponse'
  318. '201':
  319. description: Invalid data
  320. content:
  321. '*/*':
  322. schema:
  323. $ref: '#/components/schemas/DefaultErrorResponse'
  324. post:
  325. tags:
  326. - Accessories
  327. summary: Create an accessory(ies)
  328. description: Create an accessory(ies)
  329. parameters:
  330. - $ref: '#/components/parameters/Jwt'
  331. - $ref: '#/components/parameters/setup_session_id'
  332. responses:
  333. '200':
  334. description: Success
  335. content:
  336. '*/*':
  337. schema:
  338. $ref: '#/components/schemas/CreateAccessoryResponse'
  339. '201':
  340. description: Invalid data
  341. content:
  342. '*/*':
  343. schema:
  344. $ref: '#/components/schemas/DefaultErrorResponse'
  345. requestBody:
  346. content:
  347. application/json:
  348. schema:
  349. $ref: '#/components/schemas/CreateAccessoryRequest'
  350. description: The information of the accessories will be created.
  351. required: true
  352. delete:
  353. tags:
  354. - Accessories
  355. summary: Delete an accessory
  356. description: Delete an accessory that the user has access to
  357. parameters:
  358. - $ref: '#/components/parameters/Jwt'
  359. responses:
  360. '200':
  361. description: Success
  362. content:
  363. application/json:
  364. schema:
  365. $ref: '#/components/schemas/DeleteAccessoryResponse'
  366. '201':
  367. description: Invalid data
  368. content:
  369. application/json:
  370. schema:
  371. $ref: '#/components/schemas/DefaultErrorResponse'
  372. requestBody:
  373. content:
  374. application/json:
  375. schema:
  376. $ref: '#/components/schemas/DeleteAccessoryRequest'
  377. description: Accessory id to be deleted
  378. required: true
  379. /place_dashboard:
  380. get:
  381. tags:
  382. - Dashboard
  383. summary: The dashboard of a place
  384. description: >-
  385. Return the dashboard of the selected place for the current loged in
  386. user. The accessory can contain a `layout_metadata` field containing
  387. metadata.
  388. parameters:
  389. - $ref: '#/components/parameters/Jwt'
  390. - $ref: '#/components/parameters/place_id'
  391. responses:
  392. '200':
  393. description: Success
  394. content:
  395. '*/*':
  396. schema:
  397. $ref: '#/components/schemas/PlaceDashboardResponse'
  398. '201':
  399. description: Invalid data
  400. content:
  401. '*/*':
  402. schema:
  403. $ref: '#/components/schemas/DefaultErrorResponse'
  404. /room_dashboard:
  405. get:
  406. tags:
  407. - Dashboard
  408. summary: The dashboard of a room
  409. description: >-
  410. Return the dashboard of the selected room for the current loged in user.
  411. The accessory can contain a `layout_metadata` field containing metadata.
  412. parameters:
  413. - $ref: '#/components/parameters/Jwt'
  414. - $ref: '#/components/parameters/room_id'
  415. responses:
  416. '200':
  417. description: Success
  418. content:
  419. '*/*':
  420. schema:
  421. $ref: '#/components/schemas/RoomDashboardResponse'
  422. '201':
  423. description: Invalid data
  424. content:
  425. '*/*':
  426. schema:
  427. $ref: '#/components/schemas/DefaultErrorResponse'
  428. /accessories_logs:
  429. get:
  430. tags:
  431. - Accessories logs
  432. summary: Return a list of accessories data log.
  433. description: >-
  434. Return a list of accessories data log. Mostly used to plot data on
  435. charts.
  436. parameters:
  437. - $ref: '#/components/parameters/Jwt'
  438. - $ref: '#/components/parameters/accessory_id'
  439. - $ref: '#/components/parameters/update_topic'
  440. - $ref: '#/components/parameters/mac_id'
  441. - $ref: '#/components/parameters/local_id'
  442. - $ref: '#/components/parameters/room_id'
  443. responses:
  444. '200':
  445. description: Success
  446. content:
  447. '*/*':
  448. schema:
  449. $ref: '#/components/schemas/AccessoriesLogsResponse'
  450. '201':
  451. description: Invalid data
  452. content:
  453. '*/*':
  454. schema:
  455. $ref: '#/components/schemas/DefaultErrorResponse'
  456. components:
  457. schemas:
  458. DashboardRoom:
  459. type: object
  460. required:
  461. - _id
  462. - name
  463. - accessories
  464. properties:
  465. _id:
  466. type: string
  467. example: 5985270044ed65484b7085a8
  468. name:
  469. type: string
  470. example: My room
  471. accessories:
  472. type: array
  473. items:
  474. $ref: '#/components/schemas/CreateAccessoryObject'
  475. DashboardPlace:
  476. type: object
  477. required:
  478. - _id
  479. - name
  480. - owner_user
  481. - rooms
  482. properties:
  483. _id:
  484. type: string
  485. example: 59851f1f44ed65484b708375
  486. name:
  487. type: string
  488. example: My new place
  489. owner_user:
  490. $ref: '#/components/schemas/UserObject'
  491. rooms:
  492. type: array
  493. items:
  494. $ref: '#/components/schemas/DashboardRoom'
  495. AccessoryLog:
  496. type: object
  497. required:
  498. - creation_date
  499. - accessory
  500. properties:
  501. creation_date:
  502. type: number
  503. example: '1506122645.79601'
  504. accessory:
  505. $ref: '#/components/schemas/CreateAccessoryResponse'
  506. AccessoriesLogsResponse:
  507. type: object
  508. required:
  509. - logs
  510. properties:
  511. logs:
  512. type: array
  513. items:
  514. $ref: '#/components/schemas/AccessoryLog'
  515. PlaceDashboardResponse:
  516. type: object
  517. required:
  518. - place
  519. properties:
  520. place:
  521. $ref: '#/components/schemas/DashboardPlace'
  522. RoomDashboardResponse:
  523. type: object
  524. required:
  525. - room
  526. properties:
  527. room:
  528. $ref: '#/components/schemas/DashboardRoom'
  529. AccessorySetupSession:
  530. type: object
  531. required:
  532. - user_id
  533. - _id
  534. - jwt
  535. properties:
  536. room_id:
  537. type: string
  538. example: 5985270044ed65484b7085a8
  539. user_id:
  540. type: string
  541. example: 59851d5d44ed65484b7082e9
  542. _id:
  543. type: string
  544. example: 59853a1544ed65484b708b1c
  545. jwt:
  546. type: string
  547. example: 1501896038.92-59851d5d44ed65484b7082e9
  548. AccessorySetupSessionResponse:
  549. type: object
  550. required:
  551. - accessory_setup_session
  552. properties:
  553. accessory_setup_session:
  554. $ref: '#/components/schemas/AccessorySetupSession'
  555. CreateAccessoryResponse:
  556. type: array
  557. items:
  558. $ref: '#/components/schemas/CreateAccessoryObject'
  559. CreateAccessoryRequest:
  560. type: array
  561. items:
  562. $ref: '#/components/schemas/CreateAccessoryObject'
  563. CreateAccessoryObject:
  564. type: object
  565. required:
  566. - local_id
  567. - mac_id
  568. - layout_type
  569. - accessory_type
  570. properties:
  571. _id:
  572. type: string
  573. accessory_type:
  574. type: string
  575. example: '1'
  576. layout_type:
  577. type: string
  578. example: '1'
  579. name:
  580. type: string
  581. example: Default accessory name
  582. alias:
  583. type: string
  584. example: Room's light
  585. mac_id:
  586. type: string
  587. example: 'a0:20:a6:1b:5e:97'
  588. local_id:
  589. type: string
  590. example: 'a0:20:a6:1b:5e:97'
  591. is_online:
  592. type: boolean
  593. example: true
  594. last_contact_timestamp:
  595. type: number
  596. example: 1501893040.761755
  597. current_value:
  598. type: string
  599. example: '10'
  600. value_type:
  601. type: string
  602. example: string
  603. values_allowed:
  604. type: array
  605. example:
  606. - '100'
  607. - '10'
  608. - '22'
  609. update_topic:
  610. type: string
  611. example: 'accessory/update/a0:20:a6:1b:5e:97/1'
  612. allow_edit:
  613. type: boolean
  614. example: true
  615. measurement_unit:
  616. type: string
  617. example: ppm
  618. features:
  619. type: array
  620. example:
  621. - timer
  622. owner_user_id:
  623. type: string
  624. example: 592386d9ece9e403a2544657
  625. room_id:
  626. type: string
  627. example: 5985270044ed65484b7085a8
  628. DeleteRoomResponse:
  629. type: object
  630. required:
  631. - deleted
  632. properties:
  633. deleted:
  634. type: string
  635. example: 5985270044ed65484b7085a8
  636. DeleteRoomRequest:
  637. type: object
  638. required:
  639. - _id
  640. properties:
  641. _id:
  642. type: string
  643. example: 5985270044ed65484b7085a8
  644. GetReoomsResponse:
  645. type: array
  646. items:
  647. $ref: '#/components/schemas/RoomObject'
  648. RoomObject:
  649. type: object
  650. required:
  651. - _id
  652. - place
  653. - name
  654. properties:
  655. _id:
  656. type: string
  657. example: 5985270044ed65484b7085a8
  658. name:
  659. type: string
  660. example: My room
  661. place:
  662. $ref: '#/components/schemas/PlaceWithOwner'
  663. CreateRoomResponse:
  664. type: object
  665. required:
  666. - room
  667. properties:
  668. room:
  669. $ref: '#/components/schemas/RoomObject'
  670. DeletePlaceResponse:
  671. type: object
  672. required:
  673. - deleted
  674. properties:
  675. deleted:
  676. type: string
  677. example: 59851f1f44ed65484b708375
  678. DeleteAccessoryResponse:
  679. type: object
  680. required:
  681. - deleted
  682. properties:
  683. deleted:
  684. type: string
  685. example: 59851f1f44ed65484b708375
  686. DeleteAccessoryRequest:
  687. type: object
  688. required:
  689. - _id
  690. properties:
  691. _id:
  692. type: string
  693. example: 59851f1f44ed65484b708375
  694. DeletePlaceRequest:
  695. type: object
  696. required:
  697. - _id
  698. properties:
  699. _id:
  700. type: string
  701. example: 59851f1f44ed65484b708375
  702. CreateRoomRequest:
  703. type: object
  704. required:
  705. - name
  706. - place_id
  707. properties:
  708. name:
  709. type: string
  710. example: My first room
  711. place_id:
  712. type: string
  713. example: 598526b844ed65484b708596
  714. GetPlacesResponse:
  715. type: array
  716. items:
  717. $ref: '#/components/schemas/PlaceObject'
  718. GetAccessoriesResponse:
  719. type: array
  720. items:
  721. $ref: '#/components/schemas/CreateAccessoryResponse'
  722. PlaceWithOwner:
  723. type: object
  724. required:
  725. - _id
  726. - name
  727. - owner_user
  728. properties:
  729. _id:
  730. type: string
  731. example: 59851f1f44ed65484b708375
  732. name:
  733. type: string
  734. example: My new place
  735. owner_user:
  736. $ref: '#/components/schemas/UserObject'
  737. PlaceObject:
  738. type: object
  739. required:
  740. - _id
  741. - name
  742. properties:
  743. _id:
  744. type: string
  745. example: 59851f1f44ed65484b708375
  746. name:
  747. type: string
  748. example: My new place
  749. CreatePlaceResponse:
  750. type: object
  751. required:
  752. - place
  753. - owner_user
  754. properties:
  755. place:
  756. $ref: '#/components/schemas/PlaceObject'
  757. owner_user:
  758. $ref: '#/components/schemas/UserObject'
  759. CreatePlaceRequest:
  760. type: object
  761. required:
  762. - name
  763. properties:
  764. name:
  765. type: string
  766. example: My first place
  767. DeleteUserResponse:
  768. type: object
  769. required:
  770. - deleted
  771. properties:
  772. deleted:
  773. type: string
  774. example: 592386d9ece9e403a2544657
  775. DeleteUserRequest:
  776. type: object
  777. required:
  778. - _id
  779. properties:
  780. _id:
  781. type: string
  782. example: 592386d9ece9e403a2544657
  783. AuthResponse:
  784. type: object
  785. required:
  786. - user
  787. - auth
  788. properties:
  789. user:
  790. $ref: '#/components/schemas/UserObject'
  791. auth:
  792. $ref: '#/components/schemas/AuthObject'
  793. AuthObject:
  794. type: object
  795. required:
  796. - user_id
  797. - jwt
  798. - creation_date
  799. properties:
  800. user_id:
  801. type: string
  802. example: 592386d9ece9e403a2544657
  803. jwt:
  804. type: string
  805. example: 1501892164.01-592386d9ece9e403a2544657
  806. creation_date:
  807. example: 1501893040.761755
  808. type: number
  809. UserObject:
  810. type: object
  811. required:
  812. - name
  813. - username
  814. - _id
  815. properties:
  816. username:
  817. type: string
  818. example: admin
  819. _id:
  820. type: string
  821. example: 592386d9ece9e403a2544657
  822. name:
  823. type: string
  824. example: William hass
  825. AuthRequest:
  826. type: object
  827. required:
  828. - username
  829. - password
  830. properties:
  831. username:
  832. type: string
  833. example: admin
  834. password:
  835. type: string
  836. example: admin
  837. CreateUserRequest:
  838. type: object
  839. required:
  840. - username
  841. - name
  842. - password
  843. properties:
  844. username:
  845. example: admin
  846. type: string
  847. name:
  848. example: William Hass
  849. type: string
  850. password:
  851. example: admin
  852. type: string
  853. UserResponse:
  854. type: object
  855. required:
  856. - username
  857. - name
  858. - id
  859. properties:
  860. username:
  861. type: string
  862. example: admin
  863. name:
  864. type: string
  865. example: William Hass
  866. id:
  867. type: string
  868. example: 592386d9ece9e403a2544657
  869. DefaultError:
  870. type: object
  871. required:
  872. - message
  873. properties:
  874. message:
  875. type: string
  876. example: Message saying what happened
  877. DefaultErrorResponse:
  878. type: object
  879. properties:
  880. errors:
  881. type: array
  882. items:
  883. $ref: '#/components/schemas/DefaultError'
  884. parameters:
  885. accessory_id:
  886. name: _id
  887. in: query
  888. description: The id of an accessory
  889. required: false
  890. schema:
  891. type: string
  892. default: 59c591d2c23bab5fcc993d7a
  893. update_topic:
  894. name: update_topic
  895. in: query
  896. description: The update topic of an accessory
  897. required: false
  898. schema:
  899. type: string
  900. default: '60:01:94:29:96:9d'
  901. mac_id:
  902. name: mac_id
  903. in: query
  904. description: The mac id of the hardware
  905. required: false
  906. schema:
  907. type: string
  908. default: '60:01:94:29:96:9d'
  909. local_id:
  910. name: local_id
  911. in: query
  912. description: The local id of the hardware
  913. required: false
  914. schema:
  915. type: string
  916. default: any34
  917. place_id:
  918. name: place_id
  919. in: query
  920. description: The id of a place
  921. required: true
  922. schema:
  923. type: string
  924. default: 59851ef344ed65484b708363
  925. setup_session_id:
  926. name: setup_session_id
  927. in: query
  928. description: The id of the session to create a new accessory
  929. required: true
  930. schema:
  931. type: string
  932. default: 59853a1544ed65484b708b1c
  933. room_id:
  934. name: room_id
  935. in: query
  936. description: The id of a room
  937. required: true
  938. schema:
  939. type: string
  940. default: 5985270044ed65484b7085a8
  941. Jwt:
  942. name: Jwt
  943. in: header
  944. description: Authetication JWT
  945. required: true
  946. schema:
  947. type: string
  948. default: 1506351020.83-59c5878fc23bab5fcc993d72
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement