Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify domains, lists, clients and group names as arrays #1629

Merged
merged 17 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion src/api/docs/content/specs/clients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ components:
schema:
allOf:
- $ref: 'clients.yaml#/components/schemas/clients/get' # identical to GET
- $ref: 'clients.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
'400':
description: Bad request
Expand Down Expand Up @@ -172,6 +173,7 @@ components:
schema:
allOf:
- $ref: 'clients.yaml#/components/schemas/clients/get' # identical to GET
- $ref: 'clients.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
headers:
Location:
Expand Down Expand Up @@ -204,6 +206,7 @@ components:
properties:
clients:
type: array
description: Array of clients
items:
allOf:
- $ref: 'clients.yaml#/components/schemas/client'
Expand All @@ -212,7 +215,7 @@ components:
- $ref: 'clients.yaml#/components/schemas/readonly'
post:
allOf:
- $ref: 'clients.yaml#/components/schemas/client'
- $ref: 'clients.yaml#/components/schemas/client_maybe_array'
- $ref: 'clients.yaml#/components/schemas/comment'
- $ref: 'clients.yaml#/components/schemas/groups'
put:
Expand Down Expand Up @@ -252,6 +255,19 @@ components:
description: client IP / MAC / hostname / interface
type: string
example: 127.0.0.1
client_array:
type: object
properties:
client:
description: array of client IPs / MACs / hostnames / interfaces
type: array
items:
type: string
example: ["127.0.0.1", "192.168.2.12"]
client_maybe_array:
oneOf:
- $ref: 'clients.yaml#/components/schemas/client'
- $ref: 'clients.yaml#/components/schemas/client_array'
comment:
type: object
properties:
Expand Down Expand Up @@ -296,6 +312,47 @@ components:
type: integer
readOnly: true
example: 1611239099
lists_processed:
type: object
properties:
processed:
type: object
nullable: true
description: |
Object containing the number of clients that were successfully
added to the database and the number of clients that could not be
added to the database.
properties:
success:
description: |
Array of clients that were successfully added to the database.
type: array
items:
type: object
properties:
item:
description: Client that was added to the database
type: string
errors:
description: |
Array of errors that occurred during processing.
type: array
items:
type: object
properties:
item:
description: Client that could not be added to the database
type: string
error:
description: Error message
type: string
example:
success:
- item: "127.0.0.1"
- item: "::1"
errors:
- item: "192.168.2.5"
error: "UNIQUE constraint failed: client.ip"
examples:
clients:
value:
Expand All @@ -312,6 +369,13 @@ components:
id: 2
date_added: 1611322675
date_modified: 1611325497
took: 0.012
processed:
success:
- item: "127.0.0.1"
failed:
- item: "127.0.0.2"
error: "UNIQUE constraint failed: clientlist.client"
errors:
uri_error:
item_missing:
Expand Down
65 changes: 62 additions & 3 deletions src/api/docs/content/specs/domains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ components:
application/json:
schema:
allOf:
- $ref: 'domains.yaml#/components/schemas/domains/get'
- $ref: 'domains.yaml#/components/schemas/domains/get' # identical to GET
- $ref: 'domains.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
examples:
domains:
Expand Down Expand Up @@ -180,7 +181,8 @@ components:
application/json:
schema:
allOf:
- $ref: 'domains.yaml#/components/schemas/domains/get'
- $ref: 'domains.yaml#/components/schemas/domains/get' # identical to GET
- $ref: 'domains.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
headers:
Location:
Expand Down Expand Up @@ -217,6 +219,7 @@ components:
properties:
domains:
type: array
description: Array of domains
items:
allOf:
- $ref: 'domains.yaml#/components/schemas/domain'
Expand All @@ -235,7 +238,7 @@ components:
- $ref: 'domains.yaml#/components/schemas/enabled'
post:
allOf:
- $ref: 'domains.yaml#/components/schemas/domain'
- $ref: 'domains.yaml#/components/schemas/domain_maybe_array'
- $ref: 'domains.yaml#/components/schemas/comment'
- $ref: 'domains.yaml#/components/schemas/groups'
- $ref: 'domains.yaml#/components/schemas/enabled'
Expand All @@ -246,6 +249,19 @@ components:
description: Domain
type: string
example: testdomain.com
domain_array:
type: object
properties:
domain:
description: array of domains
type: array
items:
type: string
example: ["testdomain.com", "otherdomain.de"]
domain_maybe_array:
oneOf:
- $ref: 'domains.yaml#/components/schemas/domain'
- $ref: 'domains.yaml#/components/schemas/domain_array'
type:
type: object
properties:
Expand Down Expand Up @@ -305,6 +321,47 @@ components:
description: Unix timestamp of last domain modification
type: integer
readOnly: true
lists_processed:
type: object
properties:
processed:
type: object
nullable: true
description: |
Object containing the number of domains that were successfully
added to the database and the number of domains that could not be
added to the database.
properties:
success:
description: |
Array of domains that were successfully added to the database.
type: array
items:
type: object
properties:
item:
description: Domain that was added to the database
type: string
errors:
description: |
Array of errors that occurred during processing.
type: array
items:
type: object
properties:
item:
description: Domain that could not be added to the database
type: string
error:
description: Error message
type: string
example:
success:
- item: "example.com"
- item: "example3.com"
errors:
- item: "example2.com"
error: "UNIQUE constraint failed: domainlist.domain"
examples:
domains:
summary: Example domains
Expand All @@ -330,6 +387,8 @@ components:
id: 305
date_added: 1611240635
date_modified: 1611241276
took: 0.012
processed: null
errors:
uri_error:
list_imprecise:
Expand Down
62 changes: 60 additions & 2 deletions src/api/docs/content/specs/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ components:
schema:
allOf:
- $ref: 'groups.yaml#/components/schemas/groups/get' # identical to GET
- $ref: 'groups.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
'400':
description: Bad request
Expand Down Expand Up @@ -137,7 +138,8 @@ components:
application/json:
schema:
allOf:
- $ref: 'groups.yaml#/components/schemas/groups/get'
- $ref: 'groups.yaml#/components/schemas/groups/get' # identical to GET
- $ref: 'groups.yaml#/components/schemas/lists_processed'
- $ref: 'common.yaml#/components/schemas/took'
headers:
Location:
Expand Down Expand Up @@ -183,7 +185,7 @@ components:
- $ref: 'groups.yaml#/components/schemas/enabled'
post:
allOf:
- $ref: 'groups.yaml#/components/schemas/name'
- $ref: 'groups.yaml#/components/schemas/name_maybe_array'
- $ref: 'groups.yaml#/components/schemas/comment'
- $ref: 'groups.yaml#/components/schemas/enabled'
name:
Expand All @@ -193,6 +195,19 @@ components:
description: Group name
type: string
example: test_group
name_array:
type: object
properties:
name:
description: array of group names
type: array
items:
type: string
example: ["test1", "test2", "test3"]
name_maybe_array:
oneOf:
- $ref: 'groups.yaml#/components/schemas/name'
- $ref: 'groups.yaml#/components/schemas/name_array'
comment:
type: object
properties:
Expand Down Expand Up @@ -228,6 +243,47 @@ components:
type: integer
readOnly: true
example: 1611239099
lists_processed:
type: object
properties:
processed:
type: object
nullable: true
description: |
Object containing the number of groups that were successfully
added to the database and the number of groups that could not be
added to the database.
properties:
success:
description: |
Array of groups that were successfully added to the database.
type: array
items:
type: object
properties:
item:
description: Group that was added to the database
type: string
errors:
description: |
Array of errors that occurred during processing.
type: array
items:
type: object
properties:
item:
description: Group that could not be added to the database
type: string
error:
description: Error message
type: string
example:
success:
- item: "Home-Automation"
- item: "Children"
errors:
- item: "Garden"
error: "UNIQUE constraint failed: group.name"
examples:
groups:
value:
Expand All @@ -244,6 +300,8 @@ components:
id: 5
date_added: 1604871899
date_modified: 1604871899
took: 0.003
processed: null
errors:
uri_error:
item_missing:
Expand Down
Loading