-
Notifications
You must be signed in to change notification settings - Fork 1
/
api-bc.yaml
149 lines (143 loc) · 4.03 KB
/
api-bc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
openapi: 3.0.3
info:
title: BUPT Software Engineering Homework Server-Client API
description: BUPT Software Engineering Homework Server-Client API
version: 1.0.0
servers:
- url: 'http://localhost:11451/api'
description: Local Server
- url: 'http://{ip}:{port}/api'
description: Client WebHook
variables:
ip:
default: localhost
description: Client IP
port:
default: '11451'
description: Client WebHook port
paths:
/device/client:
post:
tags:
- Client Operation
summary: Client Online
requestBody:
content:
application/json:
schema:
type: object
properties:
room_id:
type: string
example: 2-233
required: true
port:
type: string
description: Port for WebHook
required: true
unique_id:
type: string
example: 1145141919810abc # random Unique ID, 16 characters
required: true
signature:
type: string
# SHA256withRSA, RSA 4096, sign text = room_id + unique_id + port
required: true
responses:
'204':
description: Online successfully
'401':
description: Unsigned or signature mismatches
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
/device/client/{room_id}:
post:
tags:
- Client Operation
summary: Client Operation Requests for AC
parameters:
- in: path
name: room_id
schema:
type: string
example: 2-233
required: true
description: Room ID
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/request_entry'
responses:
'204':
description: Operation Request successfully
'401':
description: Unsigned or signature mismatches
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
/control:
post:
tags:
- Server Operation
summary: Server Operations for AC
requestBody:
content:
application/json:
schema:
type: object # data needs encryption with client public key, named 'data'
properties:
operation:
type: string
example: start
# start, stop, temperature, wind_speed, mode, sweep
required: true
data:
type: string
example: 26
# different for operations
required: true
responses:
'204':
description: Operation successfully
'401':
description: Unsigned or signature mismatches
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
components:
schemas:
error_response:
type: object
properties:
error_code:
type: integer
example: 100
request_entry:
type: object
properties:
operation:
type: string
example: start
# start, stop, temperature, wind_speed, mode, sweep
required: true
data:
type: string
example: 26
# different for operations
time:
type: string
example: 2023-09-18T11:45:14+08:00 # ISO 8601
required: true
unique_id:
type: string
example: 1145141919810abc # random Unique ID, 16 characters
required: true
signature:
type: string
# SHA256withRSA, RSA 4096, sign text = operation + unique_id + data + time
required: true