Skip to content

Commit f53b374

Browse files
committed
WIP
1 parent 913a320 commit f53b374

24 files changed

+4556
-50
lines changed

application/controllers/ApiController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function indexAction(): never
3434
{
3535
$this->assertPermission('notifications/api');
3636
$request = $this->getRequest();
37-
if (! $request->isApiRequest() && strtolower($request->getParam('endpoint')) !== ApiCore::OPENAPI_ENDPOINT) {
38-
$this->httpBadRequest('No API request');
39-
}
37+
// if (! $request->isApiRequest() && strtolower($request->getParam('endpoint')) !== ApiCore::OPENAPI_ENDPOINT) {
38+
// $this->httpBadRequest('No API request');
39+
// }
4040

4141
$this->dispatchEndpoint($request);
4242

doc/api/channels.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#openapi: 3.1.0
2+
#info:
3+
# title: Icinga Notifications Channels API
4+
# version: '1.0'
5+
# description: Manage channels for notifications.
6+
#
7+
#servers:
8+
# - url: http://localhost/icingaweb2
9+
# description: Local Icingaweb2 server
10+
openapi: 3.1.0
11+
info:
12+
title: Channel Components
13+
description: Channel Components
14+
version: 1.0.0
15+
paths:
16+
/notifications/api/v1/channels:
17+
$ref: './paths/channels.yml#/~1notifications~1api~1v1~1channels'
18+
/notifications/api/v1/channels/{identifier}:
19+
$ref: './paths/channels.yml#/~1notifications~1api~1v1~1channels~1{identifier}'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Channel Components
4+
description: Channel Components
5+
version: 1.0.0
6+
7+
components:
8+
schemas:
9+
Channel:
10+
type: object
11+
properties:
12+
id:
13+
$ref: './components.yml#/components/schemas/ExternalId'
14+
name:
15+
type: string
16+
type:
17+
$ref: './components.yml#/components/schemas/ChannelTypes'
18+
config:
19+
oneOf:
20+
- $ref: '#/components/schemas/WebhookConfig'
21+
- $ref: '#/components/schemas/EmailConfig'
22+
- $ref: '#/components/schemas/RocketChatConfig'
23+
24+
WebhookConfig:
25+
title: Webhook Config
26+
type: object
27+
properties:
28+
url_template:
29+
$ref: './components.yml#/components/schemas/Url'
30+
required: [url_template]
31+
32+
EmailConfig:
33+
title: Email Config
34+
type: object
35+
properties:
36+
host:
37+
$ref: './components.yml#/components/schemas/Host'
38+
port:
39+
$ref: './components.yml#/components/schemas/Port'
40+
sender_mail:
41+
$ref: './components.yml#/components/schemas/Email'
42+
user:
43+
type: string
44+
password:
45+
type: string
46+
encryption:
47+
$ref: './components.yml#/components/schemas/SMTPTransportEncryption'
48+
required: [host, port, sender_mail, user, password, encryption]
49+
50+
RocketChatConfig:
51+
title: RocketChat Config
52+
type: object
53+
properties:
54+
url:
55+
$ref: './components.yml#/components/schemas/Url'
56+
user_id:
57+
type: string
58+
token:
59+
type: string
60+
required: [url, user_id, token]

doc/api/components/components.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Shared API Components
4+
version: 1.0.0
5+
components:
6+
schemas:
7+
Error:
8+
type: object
9+
properties:
10+
message:
11+
type: string
12+
Id:
13+
type: integer
14+
minimum: 1
15+
maximum: 20
16+
ExternalId:
17+
type: string
18+
minLength: 36
19+
maxLength: 36
20+
Url:
21+
type: string
22+
maxLength: 2048
23+
Host:
24+
type: string
25+
maxLength: 255
26+
Port:
27+
type: integer
28+
minimum: 1
29+
maximum: 65535
30+
Email:
31+
type: string
32+
format: email
33+
maxLength: 320
34+
SMTPTransportEncryption:
35+
title: SMTP Transport Encryption
36+
type: string
37+
enum: [None, TLS, STARTTLS]
38+
ChannelTypes:
39+
type: string
40+
enum: [webhook, email, rocketchat]
41+
42+
responses:
43+
BadRequest:
44+
description: Bad request
45+
content:
46+
application/json:
47+
schema:
48+
$ref: '#/components/schemas/Error'
49+
NotFound:
50+
description: Not found
51+
content:
52+
application/json:
53+
schema:
54+
$ref: '#/components/schemas/Error'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Contact Components
4+
description: Contact Components
5+
version: 1.0.0
6+
7+
components:
8+
schemas:
9+
Contact:
10+
type: object
11+
properties:
12+
id:
13+
$ref: './components.yml#/components/schemas/Id'
14+
full_name:
15+
type: string
16+
username:
17+
type: string
18+
nullable: true
19+
default_channel:
20+
$ref: './components.yml#/components/schemas/Id'
21+
groups:
22+
type: array
23+
items:
24+
$ref: './components.yml#/components/schemas/Id'
25+
addresses:
26+
type: object
27+
additionalProperties:
28+
type: string
29+
ContactInput:
30+
type: object
31+
required:
32+
- id
33+
- full_name
34+
- default_channel
35+
properties:
36+
id:
37+
$ref: './components.yml#/components/schemas/Id'
38+
full_name:
39+
type: string
40+
username:
41+
type: string
42+
default_channel:
43+
$ref: './components.yml#/components/schemas/Id'
44+
groups:
45+
type: array
46+
items:
47+
$ref: './components.yml#/components/schemas/Id'
48+
addresses:
49+
type: object
50+
additionalProperties:
51+
type: string
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Contactgroup Components
4+
description: Contactgroup Components
5+
version: 1.0.0
6+
7+
components:
8+
schemas:
9+
ContactGroup:
10+
type: object
11+
properties:
12+
id:
13+
$ref: './components.yml#/components/schemas/Id'
14+
name:
15+
type: string
16+
users:
17+
type: array
18+
items:
19+
$ref: './components.yml#/components/schemas/Id'
20+
ContactGroupInput:
21+
type: object
22+
required:
23+
- id
24+
- name
25+
properties:
26+
id:
27+
$ref: './components.yml#/components/schemas/Id'
28+
name:
29+
type: string
30+
users:
31+
type: array
32+
items:
33+
$ref: './components.yml#/components/schemas/Id'

doc/api/contactgroups.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Icinga Notifications Contactgroups API
4+
version: '1.0'
5+
description: Manage contactgroups for notifications.
6+
7+
servers:
8+
- url: http://localhost/icingaweb2
9+
description: Local Icingaweb2 server
10+
11+
paths:
12+
/notifications/api/v1/contactgroups:
13+
$ref: './paths/contactgroups.yml#/~1notifications~1api~1v1~1contactgroups'
14+
/notifications/api/v1/contactgroups/{identifier}:
15+
$ref: './paths/contactgroups.yml#/~1notifications~1api~1v1~1contactgroups~1{identifier}'

doc/api/contacts.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Icinga Notifications Contacts API
4+
version: '1.0'
5+
description: Manage contacts for notifications.
6+
7+
servers:
8+
- url: http://localhost/icingaweb2
9+
description: Local Icingaweb2 server
10+
11+
paths:
12+
/notifications/api/v1/contacts:
13+
$ref: './paths/contacts.yml#/~1notifications~1api~1v1~1contacts'
14+
/notifications/api/v1/contacts/{identifier}:
15+
$ref: './paths/contacts.yml#/~1notifications~1api~1v1~1contacts~1{identifier}'

0 commit comments

Comments
 (0)