mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-24 03:31:28 +02:00
API cleanup (#824)
removed all PATCH endpoints updated path parameters for all endpoints removed not implemented endpoints for api doc minor description updates
This commit is contained in:
parent
08db5f5a42
commit
59372ee159
@ -59,13 +59,13 @@ func (h *AccountsHandler) UpdateAccount(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
accountID := vars["id"]
|
accountID := vars["accountId"]
|
||||||
if len(accountID) == 0 {
|
if len(accountID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid accountID ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid accountID ID"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiAccountsIdJSONBody
|
var req api.PutApiAccountsAccountIdJSONBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
|
@ -136,7 +136,7 @@ func TestAccounts_AccountsHandler(t *testing.T) {
|
|||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/accounts", handler.GetAllAccounts).Methods("GET")
|
router.HandleFunc("/api/accounts", handler.GetAllAccounts).Methods("GET")
|
||||||
router.HandleFunc("/api/accounts/{id}", handler.UpdateAccount).Methods("PUT")
|
router.HandleFunc("/api/accounts/{accountId}", handler.UpdateAccount).Methods("PUT")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -6,8 +6,6 @@ info:
|
|||||||
tags:
|
tags:
|
||||||
- name: Users
|
- name: Users
|
||||||
description: Interact with and view information about users.
|
description: Interact with and view information about users.
|
||||||
- name: Tokens
|
|
||||||
description: Interact with and view information about tokens.
|
|
||||||
- name: Peers
|
- name: Peers
|
||||||
description: Interact with and view information about peers.
|
description: Interact with and view information about peers.
|
||||||
- name: Setup Keys
|
- name: Setup Keys
|
||||||
@ -105,15 +103,15 @@ components:
|
|||||||
UserCreateRequest:
|
UserCreateRequest:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
role:
|
|
||||||
description: User's NetBird account role
|
|
||||||
type: string
|
|
||||||
email:
|
email:
|
||||||
description: User's Email to send invite to
|
description: User's Email to send invite to
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
description: User's full name
|
description: User's full name
|
||||||
type: string
|
type: string
|
||||||
|
role:
|
||||||
|
description: User's NetBird account role
|
||||||
|
type: string
|
||||||
auto_groups:
|
auto_groups:
|
||||||
description: Groups to auto-assign to peers registered by this user
|
description: Groups to auto-assign to peers registered by this user
|
||||||
type: array
|
type: array
|
||||||
@ -343,6 +341,8 @@ components:
|
|||||||
expires_in:
|
expires_in:
|
||||||
description: Expiration in days
|
description: Expiration in days
|
||||||
type: integer
|
type: integer
|
||||||
|
minimum: 1
|
||||||
|
maximum: 365
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- expires_in
|
- expires_in
|
||||||
@ -374,33 +374,6 @@ components:
|
|||||||
$ref: '#/components/schemas/PeerMinimum'
|
$ref: '#/components/schemas/PeerMinimum'
|
||||||
required:
|
required:
|
||||||
- peers
|
- peers
|
||||||
PatchMinimum:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
op:
|
|
||||||
description: Patch operation type
|
|
||||||
type: string
|
|
||||||
enum: [ "replace","add","remove" ]
|
|
||||||
value:
|
|
||||||
description: Values to be applied
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- op
|
|
||||||
- value
|
|
||||||
GroupPatchOperation:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/PatchMinimum'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
path:
|
|
||||||
description: Group field to update in form /<field>
|
|
||||||
type: string
|
|
||||||
enum: [ "name","peers" ]
|
|
||||||
required:
|
|
||||||
- path
|
|
||||||
|
|
||||||
RuleMinimum:
|
RuleMinimum:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -446,17 +419,6 @@ components:
|
|||||||
required:
|
required:
|
||||||
- sources
|
- sources
|
||||||
- destinations
|
- destinations
|
||||||
RulePatchOperation:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/PatchMinimum'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
path:
|
|
||||||
description: Rule field to update in form /<field>
|
|
||||||
type: string
|
|
||||||
enum: [ "name","description","disabled","flow","sources","destinations" ]
|
|
||||||
required:
|
|
||||||
- path
|
|
||||||
PolicyRule:
|
PolicyRule:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -585,17 +547,6 @@ components:
|
|||||||
- id
|
- id
|
||||||
- network_type
|
- network_type
|
||||||
- $ref: '#/components/schemas/RouteRequest'
|
- $ref: '#/components/schemas/RouteRequest'
|
||||||
RoutePatchOperation:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/PatchMinimum'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
path:
|
|
||||||
description: Route field to update in form /<field>
|
|
||||||
type: string
|
|
||||||
enum: [ "network","network_id","description","enabled","peer","metric","masquerade", "groups" ]
|
|
||||||
required:
|
|
||||||
- path
|
|
||||||
Nameserver:
|
Nameserver:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -667,17 +618,6 @@ components:
|
|||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- $ref: '#/components/schemas/NameserverGroupRequest'
|
- $ref: '#/components/schemas/NameserverGroupRequest'
|
||||||
NameserverGroupPatchOperation:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/PatchMinimum'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
path:
|
|
||||||
description: Nameserver group field to update in form /<field>
|
|
||||||
type: string
|
|
||||||
enum: [ "name", "description", "enabled", "groups", "nameservers", "primary", "domains" ]
|
|
||||||
required:
|
|
||||||
- path
|
|
||||||
DNSSettings:
|
DNSSettings:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -761,15 +701,23 @@ components:
|
|||||||
type: http
|
type: http
|
||||||
scheme: bearer
|
scheme: bearer
|
||||||
bearerFormat: JWT
|
bearerFormat: JWT
|
||||||
|
TokenAuth:
|
||||||
|
type: apiKey
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
description: >-
|
||||||
|
Enter the token with the `Token` prefix, e.g. "Token nbp_F3f0d.....".
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
paths:
|
paths:
|
||||||
/api/accounts:
|
/api/accounts:
|
||||||
get:
|
get:
|
||||||
summary: Returns a list of accounts of a user. Always returns a list of one account. Only available for admin users.
|
summary: Returns a list of accounts of a user. Always returns a list of one account.
|
||||||
tags: [ Accounts ]
|
tags: [ Accounts ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON array of accounts
|
description: A JSON array of accounts
|
||||||
@ -787,19 +735,20 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/accounts/{id}:
|
/api/accounts/{accountId}:
|
||||||
put:
|
put:
|
||||||
summary: Update information about an account
|
summary: Update information about an account
|
||||||
tags: [ Accounts ]
|
tags: [ Accounts ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: accountId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Account ID
|
description: The unique identifier of an account
|
||||||
requestBody:
|
requestBody:
|
||||||
description: update an account
|
description: update an account
|
||||||
content:
|
content:
|
||||||
@ -832,12 +781,13 @@ paths:
|
|||||||
tags: [ Users ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- in: query
|
||||||
name: service_user
|
name: service_user
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Filters users and returns either normal users or service users
|
description: Filters users and returns either regular users or service users
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON array of Users
|
description: A JSON array of Users
|
||||||
@ -855,12 +805,12 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/users/:
|
|
||||||
post:
|
post:
|
||||||
summary: Create a User (invite)
|
summary: Create a User (or invite)
|
||||||
tags: [ Users ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: User invite information
|
description: User invite information
|
||||||
content:
|
content:
|
||||||
@ -882,19 +832,20 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/users/{id}:
|
/api/users/{userId}:
|
||||||
put:
|
put:
|
||||||
summary: Update information about a User
|
summary: Update information about a User
|
||||||
tags: [ Users ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
requestBody:
|
requestBody:
|
||||||
description: User update
|
description: User update
|
||||||
content:
|
content:
|
||||||
@ -923,11 +874,11 @@ paths:
|
|||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -943,16 +894,17 @@ paths:
|
|||||||
/api/users/{userId}/tokens:
|
/api/users/{userId}/tokens:
|
||||||
get:
|
get:
|
||||||
summary: Returns a list of all tokens for a user
|
summary: Returns a list of all tokens for a user
|
||||||
tags: [ Tokens ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: []
|
- BearerAuth: []
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: userId
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of PersonalAccessTokens
|
description: A JSON Array of PersonalAccessTokens
|
||||||
@ -971,17 +923,18 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
post:
|
post:
|
||||||
summary: Create a new token
|
summary: Create a new token for a user
|
||||||
tags: [ Tokens ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: userId
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
requestBody:
|
requestBody:
|
||||||
description: PersonalAccessToken create parameters
|
description: PersonalAccessToken create parameters
|
||||||
content:
|
content:
|
||||||
@ -1005,23 +958,24 @@ paths:
|
|||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/users/{userId}/tokens/{tokenId}:
|
/api/users/{userId}/tokens/{tokenId}:
|
||||||
get:
|
get:
|
||||||
summary: Returns a specific token
|
summary: Returns a specific token for a user
|
||||||
tags: [ Tokens ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: userId
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
- in: path
|
- in: path
|
||||||
name: tokenId
|
name: tokenId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Token ID
|
description: The unique identifier of a token
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A PersonalAccessTokens Object
|
description: A PersonalAccessTokens Object
|
||||||
@ -1038,23 +992,24 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
delete:
|
delete:
|
||||||
summary: Delete a token
|
summary: Delete a token for a user
|
||||||
tags: [ Tokens ]
|
tags: [ Users ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: userId
|
name: userId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The User ID
|
description: The unique identifier of a user
|
||||||
- in: path
|
- in: path
|
||||||
name: tokenId
|
name: tokenId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Token ID
|
description: The unique identifier of a token
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1073,6 +1028,7 @@ paths:
|
|||||||
tags: [ Peers ]
|
tags: [ Peers ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Peers
|
description: A JSON Array of Peers
|
||||||
@ -1090,19 +1046,20 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/peers/{id}:
|
/api/peers/{peerId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a peer
|
summary: Get information about a peer
|
||||||
tags: [ Peers ]
|
tags: [ Peers ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: peerId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Peer ID
|
description: The unique identifier of a peer
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Peer object
|
description: A Peer object
|
||||||
@ -1123,13 +1080,14 @@ paths:
|
|||||||
tags: [ Peers ]
|
tags: [ Peers ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: peerId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Peer ID
|
description: The unique identifier of a peer
|
||||||
requestBody:
|
requestBody:
|
||||||
description: update a peer
|
description: update a peer
|
||||||
content:
|
content:
|
||||||
@ -1167,13 +1125,14 @@ paths:
|
|||||||
tags: [ Peers ]
|
tags: [ Peers ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: peerId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Peer ID
|
description: The unique identifier of a peer
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1192,6 +1151,7 @@ paths:
|
|||||||
tags: [ Setup Keys ]
|
tags: [ Setup Keys ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Setup keys
|
description: A JSON Array of Setup keys
|
||||||
@ -1214,6 +1174,7 @@ paths:
|
|||||||
tags: [ Setup Keys ]
|
tags: [ Setup Keys ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Setup Key request
|
description: New Setup Key request
|
||||||
content:
|
content:
|
||||||
@ -1235,19 +1196,20 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/setup-keys/{id}:
|
/api/setup-keys/{keyId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Setup Key
|
summary: Get information about a Setup Key
|
||||||
tags: [ Setup Keys ]
|
tags: [ Setup Keys ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: keyId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Setup Key ID
|
description: The unique identifier of a setup key
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Setup Key object
|
description: A Setup Key object
|
||||||
@ -1268,13 +1230,14 @@ paths:
|
|||||||
tags: [ Setup Keys ]
|
tags: [ Setup Keys ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: keyId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Setup Key ID
|
description: The unique identifier of a setup key
|
||||||
requestBody:
|
requestBody:
|
||||||
description: update to Setup Key
|
description: update to Setup Key
|
||||||
content:
|
content:
|
||||||
@ -1296,36 +1259,13 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
delete:
|
|
||||||
summary: Delete a Setup Key
|
|
||||||
tags: [ Setup Keys ]
|
|
||||||
security:
|
|
||||||
- BearerAuth: [ ]
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: The Setup Key ID
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Delete status code
|
|
||||||
content: { }
|
|
||||||
'400':
|
|
||||||
"$ref": "#/components/responses/bad_request"
|
|
||||||
'401':
|
|
||||||
"$ref": "#/components/responses/requires_authentication"
|
|
||||||
'403':
|
|
||||||
"$ref": "#/components/responses/forbidden"
|
|
||||||
'500':
|
|
||||||
"$ref": "#/components/responses/internal_error"
|
|
||||||
/api/groups:
|
/api/groups:
|
||||||
get:
|
get:
|
||||||
summary: Returns a list of all Groups
|
summary: Returns a list of all Groups
|
||||||
tags: [ Groups ]
|
tags: [ Groups ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Groups
|
description: A JSON Array of Groups
|
||||||
@ -1348,6 +1288,7 @@ paths:
|
|||||||
tags: [ Groups ]
|
tags: [ Groups ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Group request
|
description: New Group request
|
||||||
content:
|
content:
|
||||||
@ -1378,19 +1319,20 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
/api/groups/{id}:
|
/api/groups/{groupId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Group
|
summary: Get information about a Group
|
||||||
tags: [ Groups ]
|
tags: [ Groups ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: groupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Group ID
|
description: The unique identifier of a group
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Group object
|
description: A Group object
|
||||||
@ -1411,13 +1353,14 @@ paths:
|
|||||||
tags: [ Groups ]
|
tags: [ Groups ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: groupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Group ID
|
description: The unique identifier of a group
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update Group request
|
description: Update Group request
|
||||||
content:
|
content:
|
||||||
@ -1446,53 +1389,19 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
patch:
|
|
||||||
summary: Update information about a Group
|
|
||||||
tags: [ Groups ]
|
|
||||||
security:
|
|
||||||
- BearerAuth: [ ]
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: The Group ID
|
|
||||||
requestBody:
|
|
||||||
description: Update Group request using a list of json patch objects
|
|
||||||
content:
|
|
||||||
'application/json':
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/GroupPatchOperation'
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: A Group object
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Group'
|
|
||||||
'400':
|
|
||||||
"$ref": "#/components/responses/bad_request"
|
|
||||||
'401':
|
|
||||||
"$ref": "#/components/responses/requires_authentication"
|
|
||||||
'403':
|
|
||||||
"$ref": "#/components/responses/forbidden"
|
|
||||||
'500':
|
|
||||||
"$ref": "#/components/responses/internal_error"
|
|
||||||
delete:
|
delete:
|
||||||
summary: Delete a Group
|
summary: Delete a Group
|
||||||
tags: [ Groups ]
|
tags: [ Groups ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: groupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Group ID
|
description: The unique identifier of a group
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1511,6 +1420,7 @@ paths:
|
|||||||
tags: [ Rules ]
|
tags: [ Rules ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Rules
|
description: A JSON Array of Rules
|
||||||
@ -1533,6 +1443,7 @@ paths:
|
|||||||
tags: [ Rules ]
|
tags: [ Rules ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Rule request
|
description: New Rule request
|
||||||
content:
|
content:
|
||||||
@ -1557,19 +1468,20 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Rule'
|
$ref: '#/components/schemas/Rule'
|
||||||
/api/rules/{id}:
|
/api/rules/{ruleId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Rules
|
summary: Get information about a Rules
|
||||||
tags: [ Rules ]
|
tags: [ Rules ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: ruleId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Rule ID
|
description: The unique identifier of a rule
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Rule object
|
description: A Rule object
|
||||||
@ -1590,13 +1502,14 @@ paths:
|
|||||||
tags: [ Rules ]
|
tags: [ Rules ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: ruleId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Rule ID
|
description: The unique identifier of a rule
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update Rule request
|
description: Update Rule request
|
||||||
content:
|
content:
|
||||||
@ -1634,13 +1547,14 @@ paths:
|
|||||||
tags: [ Rules ]
|
tags: [ Rules ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: ruleId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Rule ID
|
description: The unique identifier of a rule
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1659,6 +1573,7 @@ paths:
|
|||||||
tags: [ Policies ]
|
tags: [ Policies ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Policies
|
description: A JSON Array of Policies
|
||||||
@ -1681,6 +1596,7 @@ paths:
|
|||||||
tags: [ Policies ]
|
tags: [ Policies ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Policy request
|
description: New Policy request
|
||||||
content:
|
content:
|
||||||
@ -1695,19 +1611,20 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Policy'
|
$ref: '#/components/schemas/Policy'
|
||||||
/api/policies/{id}:
|
/api/policies/{policyId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Policies
|
summary: Get information about a Policies
|
||||||
tags: [ Policies ]
|
tags: [ Policies ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: policyId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Policy ID
|
description: The unique identifier of a policy
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Policy object
|
description: A Policy object
|
||||||
@ -1728,13 +1645,14 @@ paths:
|
|||||||
tags: [ Policies ]
|
tags: [ Policies ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: policyId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Policy ID
|
description: The unique identifier of a policy
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update Policy request
|
description: Update Policy request
|
||||||
content:
|
content:
|
||||||
@ -1762,13 +1680,14 @@ paths:
|
|||||||
tags: [ Policies ]
|
tags: [ Policies ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: policyId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Policy ID
|
description: The unique identifier of a policy
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1787,6 +1706,7 @@ paths:
|
|||||||
tags: [ Routes ]
|
tags: [ Routes ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Routes
|
description: A JSON Array of Routes
|
||||||
@ -1809,6 +1729,7 @@ paths:
|
|||||||
tags: [ Routes ]
|
tags: [ Routes ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Routes request
|
description: New Routes request
|
||||||
content:
|
content:
|
||||||
@ -1831,19 +1752,20 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
|
|
||||||
/api/routes/{id}:
|
/api/routes/{routeId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Routes
|
summary: Get information about a Routes
|
||||||
tags: [ Routes ]
|
tags: [ Routes ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: routeId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Route ID
|
description: The unique identifier of a route
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Route object
|
description: A Route object
|
||||||
@ -1864,13 +1786,14 @@ paths:
|
|||||||
tags: [ Routes ]
|
tags: [ Routes ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: routeId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Route ID
|
description: The unique identifier of a route
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update Route request
|
description: Update Route request
|
||||||
content:
|
content:
|
||||||
@ -1892,53 +1815,19 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
patch:
|
|
||||||
summary: Update information about a Route
|
|
||||||
tags: [ Routes ]
|
|
||||||
security:
|
|
||||||
- BearerAuth: [ ]
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: The Route ID
|
|
||||||
requestBody:
|
|
||||||
description: Update Route request using a list of json patch objects
|
|
||||||
content:
|
|
||||||
'application/json':
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/RoutePatchOperation'
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: A Route object
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Route'
|
|
||||||
'400':
|
|
||||||
"$ref": "#/components/responses/bad_request"
|
|
||||||
'401':
|
|
||||||
"$ref": "#/components/responses/requires_authentication"
|
|
||||||
'403':
|
|
||||||
"$ref": "#/components/responses/forbidden"
|
|
||||||
'500':
|
|
||||||
"$ref": "#/components/responses/internal_error"
|
|
||||||
delete:
|
delete:
|
||||||
summary: Delete a Route
|
summary: Delete a Route
|
||||||
tags: [ Routes ]
|
tags: [ Routes ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: routeId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Route ID
|
description: The unique identifier of a route
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -1957,6 +1846,7 @@ paths:
|
|||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Nameserver Groups
|
description: A JSON Array of Nameserver Groups
|
||||||
@ -1979,6 +1869,7 @@ paths:
|
|||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: New Nameserver Groups request
|
description: New Nameserver Groups request
|
||||||
content:
|
content:
|
||||||
@ -2001,19 +1892,20 @@ paths:
|
|||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
|
|
||||||
/api/dns/nameservers/{id}:
|
/api/dns/nameservers/{nsgroupId}:
|
||||||
get:
|
get:
|
||||||
summary: Get information about a Nameserver Groups
|
summary: Get information about a Nameserver Groups
|
||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: nsgroupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Nameserver Group ID
|
description: The unique identifier of a Nameserver Group
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A Nameserver Group object
|
description: A Nameserver Group object
|
||||||
@ -2034,13 +1926,14 @@ paths:
|
|||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: nsgroupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Nameserver Group ID
|
description: The unique identifier of a Nameserver Group
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Update Nameserver Group request
|
description: Update Nameserver Group request
|
||||||
content:
|
content:
|
||||||
@ -2062,53 +1955,19 @@ paths:
|
|||||||
"$ref": "#/components/responses/forbidden"
|
"$ref": "#/components/responses/forbidden"
|
||||||
'500':
|
'500':
|
||||||
"$ref": "#/components/responses/internal_error"
|
"$ref": "#/components/responses/internal_error"
|
||||||
patch:
|
|
||||||
summary: Update information about a Nameserver Group
|
|
||||||
tags: [ DNS ]
|
|
||||||
security:
|
|
||||||
- BearerAuth: [ ]
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: The Nameserver Group ID
|
|
||||||
requestBody:
|
|
||||||
description: Update Nameserver Group request using a list of json patch objects
|
|
||||||
content:
|
|
||||||
'application/json':
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/NameserverGroupPatchOperation'
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: A Nameserver Group object
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/NameserverGroup'
|
|
||||||
'400':
|
|
||||||
"$ref": "#/components/responses/bad_request"
|
|
||||||
'401':
|
|
||||||
"$ref": "#/components/responses/requires_authentication"
|
|
||||||
'403':
|
|
||||||
"$ref": "#/components/responses/forbidden"
|
|
||||||
'500':
|
|
||||||
"$ref": "#/components/responses/internal_error"
|
|
||||||
delete:
|
delete:
|
||||||
summary: Delete a Nameserver Group
|
summary: Delete a Nameserver Group
|
||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: nsgroupId
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: The Nameserver Group ID
|
description: The unique identifier of a Nameserver Group
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Delete status code
|
description: Delete status code
|
||||||
@ -2128,6 +1987,7 @@ paths:
|
|||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Object of DNS Setting
|
description: A JSON Object of DNS Setting
|
||||||
@ -2149,6 +2009,7 @@ paths:
|
|||||||
tags: [ DNS ]
|
tags: [ DNS ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
requestBody:
|
requestBody:
|
||||||
description: A DNS settings object
|
description: A DNS settings object
|
||||||
content:
|
content:
|
||||||
@ -2176,6 +2037,7 @@ paths:
|
|||||||
tags: [ Events ]
|
tags: [ Events ]
|
||||||
security:
|
security:
|
||||||
- BearerAuth: [ ]
|
- BearerAuth: [ ]
|
||||||
|
- TokenAuth: [ ]
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: A JSON Array of Events
|
description: A JSON Array of Events
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
BearerAuthScopes = "BearerAuth.Scopes"
|
BearerAuthScopes = "BearerAuth.Scopes"
|
||||||
|
TokenAuthScopes = "TokenAuth.Scopes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines values for EventActivityCode.
|
// Defines values for EventActivityCode.
|
||||||
@ -54,74 +55,17 @@ const (
|
|||||||
EventActivityCodeUserRoleUpdate EventActivityCode = "user.role.update"
|
EventActivityCodeUserRoleUpdate EventActivityCode = "user.role.update"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines values for GroupPatchOperationOp.
|
|
||||||
const (
|
|
||||||
GroupPatchOperationOpAdd GroupPatchOperationOp = "add"
|
|
||||||
GroupPatchOperationOpRemove GroupPatchOperationOp = "remove"
|
|
||||||
GroupPatchOperationOpReplace GroupPatchOperationOp = "replace"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for GroupPatchOperationPath.
|
|
||||||
const (
|
|
||||||
GroupPatchOperationPathName GroupPatchOperationPath = "name"
|
|
||||||
GroupPatchOperationPathPeers GroupPatchOperationPath = "peers"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for NameserverNsType.
|
// Defines values for NameserverNsType.
|
||||||
const (
|
const (
|
||||||
NameserverNsTypeUdp NameserverNsType = "udp"
|
NameserverNsTypeUdp NameserverNsType = "udp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines values for NameserverGroupPatchOperationOp.
|
|
||||||
const (
|
|
||||||
NameserverGroupPatchOperationOpAdd NameserverGroupPatchOperationOp = "add"
|
|
||||||
NameserverGroupPatchOperationOpRemove NameserverGroupPatchOperationOp = "remove"
|
|
||||||
NameserverGroupPatchOperationOpReplace NameserverGroupPatchOperationOp = "replace"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for NameserverGroupPatchOperationPath.
|
|
||||||
const (
|
|
||||||
NameserverGroupPatchOperationPathDescription NameserverGroupPatchOperationPath = "description"
|
|
||||||
NameserverGroupPatchOperationPathDomains NameserverGroupPatchOperationPath = "domains"
|
|
||||||
NameserverGroupPatchOperationPathEnabled NameserverGroupPatchOperationPath = "enabled"
|
|
||||||
NameserverGroupPatchOperationPathGroups NameserverGroupPatchOperationPath = "groups"
|
|
||||||
NameserverGroupPatchOperationPathName NameserverGroupPatchOperationPath = "name"
|
|
||||||
NameserverGroupPatchOperationPathNameservers NameserverGroupPatchOperationPath = "nameservers"
|
|
||||||
NameserverGroupPatchOperationPathPrimary NameserverGroupPatchOperationPath = "primary"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for PatchMinimumOp.
|
|
||||||
const (
|
|
||||||
PatchMinimumOpAdd PatchMinimumOp = "add"
|
|
||||||
PatchMinimumOpRemove PatchMinimumOp = "remove"
|
|
||||||
PatchMinimumOpReplace PatchMinimumOp = "replace"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for PolicyRuleAction.
|
// Defines values for PolicyRuleAction.
|
||||||
const (
|
const (
|
||||||
PolicyRuleActionAccept PolicyRuleAction = "accept"
|
PolicyRuleActionAccept PolicyRuleAction = "accept"
|
||||||
PolicyRuleActionDrop PolicyRuleAction = "drop"
|
PolicyRuleActionDrop PolicyRuleAction = "drop"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Defines values for RoutePatchOperationOp.
|
|
||||||
const (
|
|
||||||
RoutePatchOperationOpAdd RoutePatchOperationOp = "add"
|
|
||||||
RoutePatchOperationOpRemove RoutePatchOperationOp = "remove"
|
|
||||||
RoutePatchOperationOpReplace RoutePatchOperationOp = "replace"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for RoutePatchOperationPath.
|
|
||||||
const (
|
|
||||||
RoutePatchOperationPathDescription RoutePatchOperationPath = "description"
|
|
||||||
RoutePatchOperationPathEnabled RoutePatchOperationPath = "enabled"
|
|
||||||
RoutePatchOperationPathGroups RoutePatchOperationPath = "groups"
|
|
||||||
RoutePatchOperationPathMasquerade RoutePatchOperationPath = "masquerade"
|
|
||||||
RoutePatchOperationPathMetric RoutePatchOperationPath = "metric"
|
|
||||||
RoutePatchOperationPathNetwork RoutePatchOperationPath = "network"
|
|
||||||
RoutePatchOperationPathNetworkId RoutePatchOperationPath = "network_id"
|
|
||||||
RoutePatchOperationPathPeer RoutePatchOperationPath = "peer"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Defines values for UserStatus.
|
// Defines values for UserStatus.
|
||||||
const (
|
const (
|
||||||
UserStatusActive UserStatus = "active"
|
UserStatusActive UserStatus = "active"
|
||||||
@ -205,24 +149,6 @@ type GroupMinimum struct {
|
|||||||
PeersCount int `json:"peers_count"`
|
PeersCount int `json:"peers_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupPatchOperation defines model for GroupPatchOperation.
|
|
||||||
type GroupPatchOperation struct {
|
|
||||||
// Op Patch operation type
|
|
||||||
Op GroupPatchOperationOp `json:"op"`
|
|
||||||
|
|
||||||
// Path Group field to update in form /<field>
|
|
||||||
Path GroupPatchOperationPath `json:"path"`
|
|
||||||
|
|
||||||
// Value Values to be applied
|
|
||||||
Value []string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupPatchOperationOp Patch operation type
|
|
||||||
type GroupPatchOperationOp string
|
|
||||||
|
|
||||||
// GroupPatchOperationPath Group field to update in form /<field>
|
|
||||||
type GroupPatchOperationPath string
|
|
||||||
|
|
||||||
// Nameserver defines model for Nameserver.
|
// Nameserver defines model for Nameserver.
|
||||||
type Nameserver struct {
|
type Nameserver struct {
|
||||||
// Ip Nameserver IP
|
// Ip Nameserver IP
|
||||||
@ -265,24 +191,6 @@ type NameserverGroup struct {
|
|||||||
Primary bool `json:"primary"`
|
Primary bool `json:"primary"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameserverGroupPatchOperation defines model for NameserverGroupPatchOperation.
|
|
||||||
type NameserverGroupPatchOperation struct {
|
|
||||||
// Op Patch operation type
|
|
||||||
Op NameserverGroupPatchOperationOp `json:"op"`
|
|
||||||
|
|
||||||
// Path Nameserver group field to update in form /<field>
|
|
||||||
Path NameserverGroupPatchOperationPath `json:"path"`
|
|
||||||
|
|
||||||
// Value Values to be applied
|
|
||||||
Value []string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NameserverGroupPatchOperationOp Patch operation type
|
|
||||||
type NameserverGroupPatchOperationOp string
|
|
||||||
|
|
||||||
// NameserverGroupPatchOperationPath Nameserver group field to update in form /<field>
|
|
||||||
type NameserverGroupPatchOperationPath string
|
|
||||||
|
|
||||||
// NameserverGroupRequest defines model for NameserverGroupRequest.
|
// NameserverGroupRequest defines model for NameserverGroupRequest.
|
||||||
type NameserverGroupRequest struct {
|
type NameserverGroupRequest struct {
|
||||||
// Description Nameserver group description
|
// Description Nameserver group description
|
||||||
@ -307,18 +215,6 @@ type NameserverGroupRequest struct {
|
|||||||
Primary bool `json:"primary"`
|
Primary bool `json:"primary"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchMinimum defines model for PatchMinimum.
|
|
||||||
type PatchMinimum struct {
|
|
||||||
// Op Patch operation type
|
|
||||||
Op PatchMinimumOp `json:"op"`
|
|
||||||
|
|
||||||
// Value Values to be applied
|
|
||||||
Value []string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PatchMinimumOp Patch operation type
|
|
||||||
type PatchMinimumOp string
|
|
||||||
|
|
||||||
// Peer defines model for Peer.
|
// Peer defines model for Peer.
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
// Connected Peer to Management connection status
|
// Connected Peer to Management connection status
|
||||||
@ -516,24 +412,6 @@ type Route struct {
|
|||||||
Peer string `json:"peer"`
|
Peer string `json:"peer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoutePatchOperation defines model for RoutePatchOperation.
|
|
||||||
type RoutePatchOperation struct {
|
|
||||||
// Op Patch operation type
|
|
||||||
Op RoutePatchOperationOp `json:"op"`
|
|
||||||
|
|
||||||
// Path Route field to update in form /<field>
|
|
||||||
Path RoutePatchOperationPath `json:"path"`
|
|
||||||
|
|
||||||
// Value Values to be applied
|
|
||||||
Value []string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RoutePatchOperationOp Patch operation type
|
|
||||||
type RoutePatchOperationOp string
|
|
||||||
|
|
||||||
// RoutePatchOperationPath Route field to update in form /<field>
|
|
||||||
type RoutePatchOperationPath string
|
|
||||||
|
|
||||||
// RouteRequest defines model for RouteRequest.
|
// RouteRequest defines model for RouteRequest.
|
||||||
type RouteRequest struct {
|
type RouteRequest struct {
|
||||||
// Description Route description
|
// Description Route description
|
||||||
@ -720,31 +598,25 @@ type UserRequest struct {
|
|||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutApiAccountsIdJSONBody defines parameters for PutApiAccountsId.
|
// PutApiAccountsAccountIdJSONBody defines parameters for PutApiAccountsAccountId.
|
||||||
type PutApiAccountsIdJSONBody struct {
|
type PutApiAccountsAccountIdJSONBody struct {
|
||||||
Settings AccountSettings `json:"settings"`
|
Settings AccountSettings `json:"settings"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchApiDnsNameserversIdJSONBody defines parameters for PatchApiDnsNameserversId.
|
|
||||||
type PatchApiDnsNameserversIdJSONBody = []NameserverGroupPatchOperation
|
|
||||||
|
|
||||||
// PostApiGroupsJSONBody defines parameters for PostApiGroups.
|
// PostApiGroupsJSONBody defines parameters for PostApiGroups.
|
||||||
type PostApiGroupsJSONBody struct {
|
type PostApiGroupsJSONBody struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Peers *[]string `json:"peers,omitempty"`
|
Peers *[]string `json:"peers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchApiGroupsIdJSONBody defines parameters for PatchApiGroupsId.
|
// PutApiGroupsGroupIdJSONBody defines parameters for PutApiGroupsGroupId.
|
||||||
type PatchApiGroupsIdJSONBody = []GroupPatchOperation
|
type PutApiGroupsGroupIdJSONBody struct {
|
||||||
|
|
||||||
// PutApiGroupsIdJSONBody defines parameters for PutApiGroupsId.
|
|
||||||
type PutApiGroupsIdJSONBody struct {
|
|
||||||
Name *string `json:"Name,omitempty"`
|
Name *string `json:"Name,omitempty"`
|
||||||
Peers *[]string `json:"Peers,omitempty"`
|
Peers *[]string `json:"Peers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutApiPeersIdJSONBody defines parameters for PutApiPeersId.
|
// PutApiPeersPeerIdJSONBody defines parameters for PutApiPeersPeerId.
|
||||||
type PutApiPeersIdJSONBody struct {
|
type PutApiPeersPeerIdJSONBody struct {
|
||||||
LoginExpirationEnabled bool `json:"login_expiration_enabled"`
|
LoginExpirationEnabled bool `json:"login_expiration_enabled"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SshEnabled bool `json:"ssh_enabled"`
|
SshEnabled bool `json:"ssh_enabled"`
|
||||||
@ -753,11 +625,8 @@ type PutApiPeersIdJSONBody struct {
|
|||||||
// PostApiPoliciesJSONBody defines parameters for PostApiPolicies.
|
// PostApiPoliciesJSONBody defines parameters for PostApiPolicies.
|
||||||
type PostApiPoliciesJSONBody = PolicyMinimum
|
type PostApiPoliciesJSONBody = PolicyMinimum
|
||||||
|
|
||||||
// PutApiPoliciesIdJSONBody defines parameters for PutApiPoliciesId.
|
// PutApiPoliciesPolicyIdJSONBody defines parameters for PutApiPoliciesPolicyId.
|
||||||
type PutApiPoliciesIdJSONBody = PolicyMinimum
|
type PutApiPoliciesPolicyIdJSONBody = PolicyMinimum
|
||||||
|
|
||||||
// PatchApiRoutesIdJSONBody defines parameters for PatchApiRoutesId.
|
|
||||||
type PatchApiRoutesIdJSONBody = []RoutePatchOperation
|
|
||||||
|
|
||||||
// PostApiRulesJSONBody defines parameters for PostApiRules.
|
// PostApiRulesJSONBody defines parameters for PostApiRules.
|
||||||
type PostApiRulesJSONBody struct {
|
type PostApiRulesJSONBody struct {
|
||||||
@ -776,8 +645,8 @@ type PostApiRulesJSONBody struct {
|
|||||||
Sources *[]string `json:"sources,omitempty"`
|
Sources *[]string `json:"sources,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutApiRulesIdJSONBody defines parameters for PutApiRulesId.
|
// PutApiRulesRuleIdJSONBody defines parameters for PutApiRulesRuleId.
|
||||||
type PutApiRulesIdJSONBody struct {
|
type PutApiRulesRuleIdJSONBody struct {
|
||||||
// Description Rule friendly description
|
// Description Rule friendly description
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Destinations *[]string `json:"destinations,omitempty"`
|
Destinations *[]string `json:"destinations,omitempty"`
|
||||||
@ -795,21 +664,18 @@ type PutApiRulesIdJSONBody struct {
|
|||||||
|
|
||||||
// GetApiUsersParams defines parameters for GetApiUsers.
|
// GetApiUsersParams defines parameters for GetApiUsers.
|
||||||
type GetApiUsersParams struct {
|
type GetApiUsersParams struct {
|
||||||
// ServiceUser Filters users and returns either normal users or service users
|
// ServiceUser Filters users and returns either regular users or service users
|
||||||
ServiceUser *bool `form:"service_user,omitempty" json:"service_user,omitempty"`
|
ServiceUser *bool `form:"service_user,omitempty" json:"service_user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutApiAccountsIdJSONRequestBody defines body for PutApiAccountsId for application/json ContentType.
|
// PutApiAccountsAccountIdJSONRequestBody defines body for PutApiAccountsAccountId for application/json ContentType.
|
||||||
type PutApiAccountsIdJSONRequestBody PutApiAccountsIdJSONBody
|
type PutApiAccountsAccountIdJSONRequestBody PutApiAccountsAccountIdJSONBody
|
||||||
|
|
||||||
// PostApiDnsNameserversJSONRequestBody defines body for PostApiDnsNameservers for application/json ContentType.
|
// PostApiDnsNameserversJSONRequestBody defines body for PostApiDnsNameservers for application/json ContentType.
|
||||||
type PostApiDnsNameserversJSONRequestBody = NameserverGroupRequest
|
type PostApiDnsNameserversJSONRequestBody = NameserverGroupRequest
|
||||||
|
|
||||||
// PatchApiDnsNameserversIdJSONRequestBody defines body for PatchApiDnsNameserversId for application/json ContentType.
|
// PutApiDnsNameserversNsgroupIdJSONRequestBody defines body for PutApiDnsNameserversNsgroupId for application/json ContentType.
|
||||||
type PatchApiDnsNameserversIdJSONRequestBody = PatchApiDnsNameserversIdJSONBody
|
type PutApiDnsNameserversNsgroupIdJSONRequestBody = NameserverGroupRequest
|
||||||
|
|
||||||
// PutApiDnsNameserversIdJSONRequestBody defines body for PutApiDnsNameserversId for application/json ContentType.
|
|
||||||
type PutApiDnsNameserversIdJSONRequestBody = NameserverGroupRequest
|
|
||||||
|
|
||||||
// PutApiDnsSettingsJSONRequestBody defines body for PutApiDnsSettings for application/json ContentType.
|
// PutApiDnsSettingsJSONRequestBody defines body for PutApiDnsSettings for application/json ContentType.
|
||||||
type PutApiDnsSettingsJSONRequestBody = DNSSettings
|
type PutApiDnsSettingsJSONRequestBody = DNSSettings
|
||||||
@ -817,47 +683,41 @@ type PutApiDnsSettingsJSONRequestBody = DNSSettings
|
|||||||
// PostApiGroupsJSONRequestBody defines body for PostApiGroups for application/json ContentType.
|
// PostApiGroupsJSONRequestBody defines body for PostApiGroups for application/json ContentType.
|
||||||
type PostApiGroupsJSONRequestBody PostApiGroupsJSONBody
|
type PostApiGroupsJSONRequestBody PostApiGroupsJSONBody
|
||||||
|
|
||||||
// PatchApiGroupsIdJSONRequestBody defines body for PatchApiGroupsId for application/json ContentType.
|
// PutApiGroupsGroupIdJSONRequestBody defines body for PutApiGroupsGroupId for application/json ContentType.
|
||||||
type PatchApiGroupsIdJSONRequestBody = PatchApiGroupsIdJSONBody
|
type PutApiGroupsGroupIdJSONRequestBody PutApiGroupsGroupIdJSONBody
|
||||||
|
|
||||||
// PutApiGroupsIdJSONRequestBody defines body for PutApiGroupsId for application/json ContentType.
|
// PutApiPeersPeerIdJSONRequestBody defines body for PutApiPeersPeerId for application/json ContentType.
|
||||||
type PutApiGroupsIdJSONRequestBody PutApiGroupsIdJSONBody
|
type PutApiPeersPeerIdJSONRequestBody PutApiPeersPeerIdJSONBody
|
||||||
|
|
||||||
// PutApiPeersIdJSONRequestBody defines body for PutApiPeersId for application/json ContentType.
|
|
||||||
type PutApiPeersIdJSONRequestBody PutApiPeersIdJSONBody
|
|
||||||
|
|
||||||
// PostApiPoliciesJSONRequestBody defines body for PostApiPolicies for application/json ContentType.
|
// PostApiPoliciesJSONRequestBody defines body for PostApiPolicies for application/json ContentType.
|
||||||
type PostApiPoliciesJSONRequestBody = PostApiPoliciesJSONBody
|
type PostApiPoliciesJSONRequestBody = PostApiPoliciesJSONBody
|
||||||
|
|
||||||
// PutApiPoliciesIdJSONRequestBody defines body for PutApiPoliciesId for application/json ContentType.
|
// PutApiPoliciesPolicyIdJSONRequestBody defines body for PutApiPoliciesPolicyId for application/json ContentType.
|
||||||
type PutApiPoliciesIdJSONRequestBody = PutApiPoliciesIdJSONBody
|
type PutApiPoliciesPolicyIdJSONRequestBody = PutApiPoliciesPolicyIdJSONBody
|
||||||
|
|
||||||
// PostApiRoutesJSONRequestBody defines body for PostApiRoutes for application/json ContentType.
|
// PostApiRoutesJSONRequestBody defines body for PostApiRoutes for application/json ContentType.
|
||||||
type PostApiRoutesJSONRequestBody = RouteRequest
|
type PostApiRoutesJSONRequestBody = RouteRequest
|
||||||
|
|
||||||
// PatchApiRoutesIdJSONRequestBody defines body for PatchApiRoutesId for application/json ContentType.
|
// PutApiRoutesRouteIdJSONRequestBody defines body for PutApiRoutesRouteId for application/json ContentType.
|
||||||
type PatchApiRoutesIdJSONRequestBody = PatchApiRoutesIdJSONBody
|
type PutApiRoutesRouteIdJSONRequestBody = RouteRequest
|
||||||
|
|
||||||
// PutApiRoutesIdJSONRequestBody defines body for PutApiRoutesId for application/json ContentType.
|
|
||||||
type PutApiRoutesIdJSONRequestBody = RouteRequest
|
|
||||||
|
|
||||||
// PostApiRulesJSONRequestBody defines body for PostApiRules for application/json ContentType.
|
// PostApiRulesJSONRequestBody defines body for PostApiRules for application/json ContentType.
|
||||||
type PostApiRulesJSONRequestBody PostApiRulesJSONBody
|
type PostApiRulesJSONRequestBody PostApiRulesJSONBody
|
||||||
|
|
||||||
// PutApiRulesIdJSONRequestBody defines body for PutApiRulesId for application/json ContentType.
|
// PutApiRulesRuleIdJSONRequestBody defines body for PutApiRulesRuleId for application/json ContentType.
|
||||||
type PutApiRulesIdJSONRequestBody PutApiRulesIdJSONBody
|
type PutApiRulesRuleIdJSONRequestBody PutApiRulesRuleIdJSONBody
|
||||||
|
|
||||||
// PostApiSetupKeysJSONRequestBody defines body for PostApiSetupKeys for application/json ContentType.
|
// PostApiSetupKeysJSONRequestBody defines body for PostApiSetupKeys for application/json ContentType.
|
||||||
type PostApiSetupKeysJSONRequestBody = SetupKeyRequest
|
type PostApiSetupKeysJSONRequestBody = SetupKeyRequest
|
||||||
|
|
||||||
// PutApiSetupKeysIdJSONRequestBody defines body for PutApiSetupKeysId for application/json ContentType.
|
// PutApiSetupKeysKeyIdJSONRequestBody defines body for PutApiSetupKeysKeyId for application/json ContentType.
|
||||||
type PutApiSetupKeysIdJSONRequestBody = SetupKeyRequest
|
type PutApiSetupKeysKeyIdJSONRequestBody = SetupKeyRequest
|
||||||
|
|
||||||
// PostApiUsersJSONRequestBody defines body for PostApiUsers for application/json ContentType.
|
// PostApiUsersJSONRequestBody defines body for PostApiUsers for application/json ContentType.
|
||||||
type PostApiUsersJSONRequestBody = UserCreateRequest
|
type PostApiUsersJSONRequestBody = UserCreateRequest
|
||||||
|
|
||||||
// PutApiUsersIdJSONRequestBody defines body for PutApiUsersId for application/json ContentType.
|
// PutApiUsersUserIdJSONRequestBody defines body for PutApiUsersUserId for application/json ContentType.
|
||||||
type PutApiUsersIdJSONRequestBody = UserRequest
|
type PutApiUsersUserIdJSONRequestBody = UserRequest
|
||||||
|
|
||||||
// PostApiUsersUserIdTokensJSONRequestBody defines body for PostApiUsersUserIdTokens for application/json ContentType.
|
// PostApiUsersUserIdTokensJSONRequestBody defines body for PostApiUsersUserIdTokens for application/json ContentType.
|
||||||
type PostApiUsersUserIdTokensJSONRequestBody = PersonalAccessTokenRequest
|
type PostApiUsersUserIdTokensJSONRequestBody = PersonalAccessTokenRequest
|
||||||
|
@ -62,7 +62,7 @@ func (h *GroupsHandler) UpdateGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
groupID, ok := vars["id"]
|
groupID, ok := vars["groupId"]
|
||||||
if !ok {
|
if !ok {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "group ID field is missing"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "group ID field is missing"), w)
|
||||||
return
|
return
|
||||||
@ -88,7 +88,7 @@ func (h *GroupsHandler) UpdateGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiGroupsIdJSONRequestBody
|
var req api.PutApiGroupsGroupIdJSONRequestBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -121,110 +121,6 @@ func (h *GroupsHandler) UpdateGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
util.WriteJSONObject(w, toGroupResponse(account, &group))
|
util.WriteJSONObject(w, toGroupResponse(account, &group))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchGroup handles patch updates to a group identified by a given ID
|
|
||||||
func (h *GroupsHandler) PatchGroup(w http.ResponseWriter, r *http.Request) {
|
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
|
||||||
account, _, err := h.accountManager.GetAccountFromToken(claims)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
groupID := vars["id"]
|
|
||||||
if len(groupID) == 0 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid group ID"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, ok := account.Groups[groupID]
|
|
||||||
if !ok {
|
|
||||||
util.WriteError(status.Errorf(status.NotFound, "couldn't find group ID %s", groupID), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
allGroup, err := account.GetGroupAll()
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if allGroup.ID == groupID {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "updating group ALL is not allowed"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var req api.PatchApiGroupsIdJSONRequestBody
|
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(req) == 0 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "no patch instruction received"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var operations []server.GroupUpdateOperation
|
|
||||||
|
|
||||||
for _, patch := range req {
|
|
||||||
switch patch.Path {
|
|
||||||
case api.GroupPatchOperationPathName:
|
|
||||||
if patch.Op != api.GroupPatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"name field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(patch.Value) == 0 || patch.Value[0] == "" {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "group name shouldn't be empty"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
operations = append(operations, server.GroupUpdateOperation{
|
|
||||||
Type: server.UpdateGroupName,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.GroupPatchOperationPathPeers:
|
|
||||||
switch patch.Op {
|
|
||||||
case api.GroupPatchOperationOpReplace:
|
|
||||||
peerKeys := peerIPsToKeys(account, &patch.Value)
|
|
||||||
operations = append(operations, server.GroupUpdateOperation{
|
|
||||||
Type: server.UpdateGroupPeers,
|
|
||||||
Values: peerKeys,
|
|
||||||
})
|
|
||||||
case api.GroupPatchOperationOpRemove:
|
|
||||||
peerKeys := peerIPsToKeys(account, &patch.Value)
|
|
||||||
operations = append(operations, server.GroupUpdateOperation{
|
|
||||||
Type: server.RemovePeersFromGroup,
|
|
||||||
Values: peerKeys,
|
|
||||||
})
|
|
||||||
case api.GroupPatchOperationOpAdd:
|
|
||||||
operations = append(operations, server.GroupUpdateOperation{
|
|
||||||
Type: server.InsertPeersToGroup,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"invalid operation, \"%v\", for PeersHandler field", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid patch path"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group, err := h.accountManager.UpdateGroup(account.Id, groupID, operations)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
util.WriteJSONObject(w, toGroupResponse(account, group))
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateGroup handles group creation request
|
// CreateGroup handles group creation request
|
||||||
func (h *GroupsHandler) CreateGroup(w http.ResponseWriter, r *http.Request) {
|
func (h *GroupsHandler) CreateGroup(w http.ResponseWriter, r *http.Request) {
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
claims := h.claimsExtractor.FromRequestContext(r)
|
||||||
@ -277,7 +173,7 @@ func (h *GroupsHandler) DeleteGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
aID := account.Id
|
aID := account.Id
|
||||||
|
|
||||||
groupID := mux.Vars(r)["id"]
|
groupID := mux.Vars(r)["groupId"]
|
||||||
if len(groupID) == 0 {
|
if len(groupID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid group ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid group ID"), w)
|
||||||
return
|
return
|
||||||
@ -314,7 +210,7 @@ func (h *GroupsHandler) GetGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
groupID := mux.Vars(r)["id"]
|
groupID := mux.Vars(r)["groupId"]
|
||||||
if len(groupID) == 0 {
|
if len(groupID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid group ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid group ID"), w)
|
||||||
return
|
return
|
||||||
@ -335,29 +231,6 @@ func (h *GroupsHandler) GetGroup(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func peerIPsToKeys(account *server.Account, peerIPs *[]string) []string {
|
|
||||||
var mappedPeerKeys []string
|
|
||||||
if peerIPs == nil {
|
|
||||||
return mappedPeerKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
peersChecked := make(map[string]struct{})
|
|
||||||
|
|
||||||
for _, requestPeersIP := range *peerIPs {
|
|
||||||
_, ok := peersChecked[requestPeersIP]
|
|
||||||
if ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
peersChecked[requestPeersIP] = struct{}{}
|
|
||||||
for _, accountPeer := range account.Peers {
|
|
||||||
if accountPeer.IP.String() == requestPeersIP {
|
|
||||||
mappedPeerKeys = append(mappedPeerKeys, accountPeer.Key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mappedPeerKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
func toGroupResponse(account *server.Account, group *server.Group) *api.Group {
|
func toGroupResponse(account *server.Account, group *server.Group) *api.Group {
|
||||||
cache := make(map[string]api.PeerMinimum)
|
cache := make(map[string]api.PeerMinimum)
|
||||||
gr := api.Group{
|
gr := api.Group{
|
||||||
|
@ -136,7 +136,7 @@ func TestGetGroup(t *testing.T) {
|
|||||||
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/groups/{id}", p.GetGroup).Methods("GET")
|
router.HandleFunc("/api/groups/{groupId}", p.GetGroup).Methods("GET")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
@ -230,53 +230,6 @@ func TestWriteGroup(t *testing.T) {
|
|||||||
expectedStatus: http.StatusUnprocessableEntity,
|
expectedStatus: http.StatusUnprocessableEntity,
|
||||||
expectedBody: false,
|
expectedBody: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Write Group PATCH Name OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/groups/id-existed",
|
|
||||||
requestBody: bytes.NewBuffer(
|
|
||||||
[]byte(`[{"op":"replace","path":"name","value":["Default POSTed Group"]}]`)),
|
|
||||||
expectedStatus: http.StatusOK,
|
|
||||||
expectedGroup: &api.Group{
|
|
||||||
Id: "id-existed",
|
|
||||||
Name: "Default POSTed Group",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Write Group PATCH Invalid Name OP",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/groups/id-existed",
|
|
||||||
requestBody: bytes.NewBuffer(
|
|
||||||
[]byte(`[{"op":"insert","path":"name","value":[""]}]`)),
|
|
||||||
expectedStatus: http.StatusUnprocessableEntity,
|
|
||||||
expectedBody: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Write Group PATCH Invalid Name",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/groups/id-existed",
|
|
||||||
requestBody: bytes.NewBuffer(
|
|
||||||
[]byte(`[{"op":"replace","path":"name","value":[]}]`)),
|
|
||||||
expectedStatus: http.StatusUnprocessableEntity,
|
|
||||||
expectedBody: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Write Group PATCH PeersHandler OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/groups/id-existed",
|
|
||||||
requestBody: bytes.NewBuffer(
|
|
||||||
[]byte(`[{"op":"replace","path":"peers","value":["100.100.100.100","200.200.200.200"]}]`)),
|
|
||||||
expectedStatus: http.StatusOK,
|
|
||||||
expectedBody: true,
|
|
||||||
expectedGroup: &api.Group{
|
|
||||||
Id: "id-existed",
|
|
||||||
PeersCount: 2,
|
|
||||||
Peers: []api.PeerMinimum{
|
|
||||||
{Id: "peer-A-ID"},
|
|
||||||
{Id: "peer-B-ID"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adminUser := server.NewAdminUser("test_user")
|
adminUser := server.NewAdminUser("test_user")
|
||||||
@ -289,8 +242,7 @@ func TestWriteGroup(t *testing.T) {
|
|||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/groups", p.CreateGroup).Methods("POST")
|
router.HandleFunc("/api/groups", p.CreateGroup).Methods("POST")
|
||||||
router.HandleFunc("/api/groups/{id}", p.UpdateGroup).Methods("PUT")
|
router.HandleFunc("/api/groups/{groupId}", p.UpdateGroup).Methods("PUT")
|
||||||
router.HandleFunc("/api/groups/{id}", p.PatchGroup).Methods("PATCH")
|
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -96,22 +96,22 @@ func APIHandler(accountManager s.AccountManager, jwtValidator jwtclaims.JWTValid
|
|||||||
|
|
||||||
func (apiHandler *apiHandler) addAccountsEndpoint() {
|
func (apiHandler *apiHandler) addAccountsEndpoint() {
|
||||||
accountsHandler := NewAccountsHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
accountsHandler := NewAccountsHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/accounts/{id}", accountsHandler.UpdateAccount).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/accounts/{accountId}", accountsHandler.UpdateAccount).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/accounts", accountsHandler.GetAllAccounts).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/accounts", accountsHandler.GetAllAccounts).Methods("GET", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addPeersEndpoint() {
|
func (apiHandler *apiHandler) addPeersEndpoint() {
|
||||||
peersHandler := NewPeersHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
peersHandler := NewPeersHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/peers", peersHandler.GetAllPeers).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/peers", peersHandler.GetAllPeers).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/peers/{id}", peersHandler.HandlePeer).
|
apiHandler.Router.HandleFunc("/peers/{peerId}", peersHandler.HandlePeer).
|
||||||
Methods("GET", "PUT", "DELETE", "OPTIONS")
|
Methods("GET", "PUT", "DELETE", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addUsersEndpoint() {
|
func (apiHandler *apiHandler) addUsersEndpoint() {
|
||||||
userHandler := NewUsersHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
userHandler := NewUsersHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/users", userHandler.GetAllUsers).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/users", userHandler.GetAllUsers).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/users/{id}", userHandler.UpdateUser).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/users/{userId}", userHandler.UpdateUser).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/users/{id}", userHandler.DeleteUser).Methods("DELETE", "OPTIONS")
|
apiHandler.Router.HandleFunc("/users/{userId}", userHandler.DeleteUser).Methods("DELETE", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/users", userHandler.CreateUser).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/users", userHandler.CreateUser).Methods("POST", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,56 +127,53 @@ func (apiHandler *apiHandler) addSetupKeysEndpoint() {
|
|||||||
keysHandler := NewSetupKeysHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
keysHandler := NewSetupKeysHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/setup-keys", keysHandler.GetAllSetupKeys).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/setup-keys", keysHandler.GetAllSetupKeys).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/setup-keys", keysHandler.CreateSetupKey).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/setup-keys", keysHandler.CreateSetupKey).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/setup-keys/{id}", keysHandler.GetSetupKey).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/setup-keys/{keyId}", keysHandler.GetSetupKey).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/setup-keys/{id}", keysHandler.UpdateSetupKey).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/setup-keys/{keyId}", keysHandler.UpdateSetupKey).Methods("PUT", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addRulesEndpoint() {
|
func (apiHandler *apiHandler) addRulesEndpoint() {
|
||||||
rulesHandler := NewRulesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
rulesHandler := NewRulesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/rules", rulesHandler.GetAllRules).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/rules", rulesHandler.GetAllRules).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/rules", rulesHandler.CreateRule).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/rules", rulesHandler.CreateRule).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/rules/{id}", rulesHandler.UpdateRule).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/rules/{ruleId}", rulesHandler.UpdateRule).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/rules/{id}", rulesHandler.GetRule).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/rules/{ruleId}", rulesHandler.GetRule).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/rules/{id}", rulesHandler.DeleteRule).Methods("DELETE", "OPTIONS")
|
apiHandler.Router.HandleFunc("/rules/{ruleId}", rulesHandler.DeleteRule).Methods("DELETE", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addPoliciesEndpoint() {
|
func (apiHandler *apiHandler) addPoliciesEndpoint() {
|
||||||
policiesHandler := NewPoliciesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
policiesHandler := NewPoliciesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/policies", policiesHandler.GetAllPolicies).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/policies", policiesHandler.GetAllPolicies).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/policies", policiesHandler.CreatePolicy).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/policies", policiesHandler.CreatePolicy).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/policies/{id}", policiesHandler.UpdatePolicy).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/policies/{policyId}", policiesHandler.UpdatePolicy).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/policies/{id}", policiesHandler.GetPolicy).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/policies/{policyId}", policiesHandler.GetPolicy).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/policies/{id}", policiesHandler.DeletePolicy).Methods("DELETE", "OPTIONS")
|
apiHandler.Router.HandleFunc("/policies/{policyId}", policiesHandler.DeletePolicy).Methods("DELETE", "OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addGroupsEndpoint() {
|
func (apiHandler *apiHandler) addGroupsEndpoint() {
|
||||||
groupsHandler := NewGroupsHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
groupsHandler := NewGroupsHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/groups", groupsHandler.GetAllGroups).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/groups", groupsHandler.GetAllGroups).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/groups", groupsHandler.CreateGroup).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/groups", groupsHandler.CreateGroup).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/groups/{id}", groupsHandler.UpdateGroup).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/groups/{groupId}", groupsHandler.UpdateGroup).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/groups/{id}", groupsHandler.PatchGroup).Methods("PATCH", "OPTIONS")
|
apiHandler.Router.HandleFunc("/groups/{groupId}", groupsHandler.GetGroup).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/groups/{id}", groupsHandler.GetGroup).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/groups/{groupId}", groupsHandler.DeleteGroup).Methods("DELETE", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/groups/{id}", groupsHandler.DeleteGroup).Methods("DELETE", "OPTIONS")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addRoutesEndpoint() {
|
func (apiHandler *apiHandler) addRoutesEndpoint() {
|
||||||
routesHandler := NewRoutesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
routesHandler := NewRoutesHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/routes", routesHandler.GetAllRoutes).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/routes", routesHandler.GetAllRoutes).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/routes", routesHandler.CreateRoute).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/routes", routesHandler.CreateRoute).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/routes/{id}", routesHandler.UpdateRoute).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/routes/{routeId}", routesHandler.UpdateRoute).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/routes/{id}", routesHandler.PatchRoute).Methods("PATCH", "OPTIONS")
|
apiHandler.Router.HandleFunc("/routes/{routeId}", routesHandler.GetRoute).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/routes/{id}", routesHandler.GetRoute).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/routes/{routeId}", routesHandler.DeleteRoute).Methods("DELETE", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/routes/{id}", routesHandler.DeleteRoute).Methods("DELETE", "OPTIONS")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addDNSNameserversEndpoint() {
|
func (apiHandler *apiHandler) addDNSNameserversEndpoint() {
|
||||||
nameserversHandler := NewNameserversHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
nameserversHandler := NewNameserversHandler(apiHandler.AccountManager, apiHandler.AuthCfg)
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers", nameserversHandler.GetAllNameservers).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/dns/nameservers", nameserversHandler.GetAllNameservers).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers", nameserversHandler.CreateNameserverGroup).Methods("POST", "OPTIONS")
|
apiHandler.Router.HandleFunc("/dns/nameservers", nameserversHandler.CreateNameserverGroup).Methods("POST", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers/{id}", nameserversHandler.UpdateNameserverGroup).Methods("PUT", "OPTIONS")
|
apiHandler.Router.HandleFunc("/dns/nameservers/{nsgroupId}", nameserversHandler.UpdateNameserverGroup).Methods("PUT", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers/{id}", nameserversHandler.PatchNameserverGroup).Methods("PATCH", "OPTIONS")
|
apiHandler.Router.HandleFunc("/dns/nameservers/{nsgroupId}", nameserversHandler.GetNameserverGroup).Methods("GET", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers/{id}", nameserversHandler.GetNameserverGroup).Methods("GET", "OPTIONS")
|
apiHandler.Router.HandleFunc("/dns/nameservers/{nsgroupId}", nameserversHandler.DeleteNameserverGroup).Methods("DELETE", "OPTIONS")
|
||||||
apiHandler.Router.HandleFunc("/dns/nameservers/{id}", nameserversHandler.DeleteNameserverGroup).Methods("DELETE", "OPTIONS")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiHandler *apiHandler) addDNSSettingEndpoint() {
|
func (apiHandler *apiHandler) addDNSSettingEndpoint() {
|
||||||
|
@ -99,13 +99,13 @@ func (h *NameserversHandler) UpdateNameserverGroup(w http.ResponseWriter, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGroupID := mux.Vars(r)["id"]
|
nsGroupID := mux.Vars(r)["nsgroupId"]
|
||||||
if len(nsGroupID) == 0 {
|
if len(nsGroupID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiDnsNameserversIdJSONRequestBody
|
var req api.PutApiDnsNameserversNsgroupIdJSONRequestBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -140,88 +140,6 @@ func (h *NameserversHandler) UpdateNameserverGroup(w http.ResponseWriter, r *htt
|
|||||||
util.WriteJSONObject(w, &resp)
|
util.WriteJSONObject(w, &resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchNameserverGroup handles patch updates to a nameserver group identified by a given ID
|
|
||||||
func (h *NameserversHandler) PatchNameserverGroup(w http.ResponseWriter, r *http.Request) {
|
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
|
||||||
account, user, err := h.accountManager.GetAccountFromToken(claims)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGroupID := mux.Vars(r)["id"]
|
|
||||||
if len(nsGroupID) == 0 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var req api.PatchApiDnsNameserversIdJSONRequestBody
|
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var operations []server.NameServerGroupUpdateOperation
|
|
||||||
for _, patch := range req {
|
|
||||||
if patch.Op != api.NameserverGroupPatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"nameserver groups only accepts replace operations, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch patch.Path {
|
|
||||||
case api.NameserverGroupPatchOperationPathName:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupName,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathDescription:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupDescription,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathPrimary:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupPrimary,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathDomains:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupDomains,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathNameservers:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupNameServers,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathGroups:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupGroups,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.NameserverGroupPatchOperationPathEnabled:
|
|
||||||
operations = append(operations, server.NameServerGroupUpdateOperation{
|
|
||||||
Type: server.UpdateNameServerGroupEnabled,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid patch path"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updatedNSGroup, err := h.accountManager.UpdateNameServerGroup(account.Id, nsGroupID, user.Id, operations)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := toNameserverGroupResponse(updatedNSGroup)
|
|
||||||
|
|
||||||
util.WriteJSONObject(w, &resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteNameserverGroup handles nameserver group deletion request
|
// DeleteNameserverGroup handles nameserver group deletion request
|
||||||
func (h *NameserversHandler) DeleteNameserverGroup(w http.ResponseWriter, r *http.Request) {
|
func (h *NameserversHandler) DeleteNameserverGroup(w http.ResponseWriter, r *http.Request) {
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
claims := h.claimsExtractor.FromRequestContext(r)
|
||||||
@ -231,7 +149,7 @@ func (h *NameserversHandler) DeleteNameserverGroup(w http.ResponseWriter, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGroupID := mux.Vars(r)["id"]
|
nsGroupID := mux.Vars(r)["nsgroupId"]
|
||||||
if len(nsGroupID) == 0 {
|
if len(nsGroupID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
||||||
return
|
return
|
||||||
@ -256,7 +174,7 @@ func (h *NameserversHandler) GetNameserverGroup(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGroupID := mux.Vars(r)["id"]
|
nsGroupID := mux.Vars(r)["nsgroupId"]
|
||||||
if len(nsGroupID) == 0 {
|
if len(nsGroupID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid nameserver group ID"), w)
|
||||||
return
|
return
|
||||||
|
@ -227,31 +227,6 @@ func TestNameserversHandlers(t *testing.T) {
|
|||||||
expectedStatus: http.StatusUnprocessableEntity,
|
expectedStatus: http.StatusUnprocessableEntity,
|
||||||
expectedBody: false,
|
expectedBody: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "PATCH OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/dns/nameservers/" + existingNSGroupID,
|
|
||||||
requestBody: bytes.NewBufferString("[{\"op\":\"replace\",\"path\":\"description\",\"value\":[\"NewDesc\"]}]"),
|
|
||||||
expectedStatus: http.StatusOK,
|
|
||||||
expectedBody: true,
|
|
||||||
expectedNSGroup: &api.NameserverGroup{
|
|
||||||
Id: existingNSGroupID,
|
|
||||||
Name: baseExistingNSGroup.Name,
|
|
||||||
Description: "NewDesc",
|
|
||||||
Nameservers: toNameserverGroupResponse(baseExistingNSGroup).Nameservers,
|
|
||||||
Groups: baseExistingNSGroup.Groups,
|
|
||||||
Enabled: baseExistingNSGroup.Enabled,
|
|
||||||
Primary: baseExistingNSGroup.Primary,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "PATCH Invalid Nameserver Group OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/dns/nameservers/" + notFoundRouteID,
|
|
||||||
requestBody: bytes.NewBufferString("[{\"op\":\"replace\",\"path\":\"description\",\"value\":[\"NewDesc\"]}]"),
|
|
||||||
expectedStatus: http.StatusNotFound,
|
|
||||||
expectedBody: false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p := initNameserversTestData()
|
p := initNameserversTestData()
|
||||||
@ -262,11 +237,10 @@ func TestNameserversHandlers(t *testing.T) {
|
|||||||
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/dns/nameservers/{id}", p.GetNameserverGroup).Methods("GET")
|
router.HandleFunc("/api/dns/nameservers/{nsgroupId}", p.GetNameserverGroup).Methods("GET")
|
||||||
router.HandleFunc("/api/dns/nameservers", p.CreateNameserverGroup).Methods("POST")
|
router.HandleFunc("/api/dns/nameservers", p.CreateNameserverGroup).Methods("POST")
|
||||||
router.HandleFunc("/api/dns/nameservers/{id}", p.DeleteNameserverGroup).Methods("DELETE")
|
router.HandleFunc("/api/dns/nameservers/{nsgroupId}", p.DeleteNameserverGroup).Methods("DELETE")
|
||||||
router.HandleFunc("/api/dns/nameservers/{id}", p.UpdateNameserverGroup).Methods("PUT")
|
router.HandleFunc("/api/dns/nameservers/{nsgroupId}", p.UpdateNameserverGroup).Methods("PUT")
|
||||||
router.HandleFunc("/api/dns/nameservers/{id}", p.PatchNameserverGroup).Methods("PATCH")
|
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -42,7 +42,7 @@ func (h *PeersHandler) getPeer(account *server.Account, peerID, userID string, w
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *PeersHandler) updatePeer(account *server.Account, user *server.User, peerID string, w http.ResponseWriter, r *http.Request) {
|
func (h *PeersHandler) updatePeer(account *server.Account, user *server.User, peerID string, w http.ResponseWriter, r *http.Request) {
|
||||||
req := &api.PutApiPeersIdJSONBody{}
|
req := &api.PutApiPeersPeerIdJSONBody{}
|
||||||
err := json.NewDecoder(r.Body).Decode(&req)
|
err := json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -78,7 +78,7 @@ func (h *PeersHandler) HandlePeer(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
peerID := vars["id"]
|
peerID := vars["peerId"]
|
||||||
if len(peerID) == 0 {
|
if len(peerID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid peer ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid peer ID"), w)
|
||||||
return
|
return
|
||||||
|
@ -146,8 +146,8 @@ func TestGetPeers(t *testing.T) {
|
|||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/peers/", p.GetAllPeers).Methods("GET")
|
router.HandleFunc("/api/peers/", p.GetAllPeers).Methods("GET")
|
||||||
router.HandleFunc("/api/peers/{id}", p.HandlePeer).Methods("GET")
|
router.HandleFunc("/api/peers/{peerId}", p.HandlePeer).Methods("GET")
|
||||||
router.HandleFunc("/api/peers/{id}", p.HandlePeer).Methods("PUT")
|
router.HandleFunc("/api/peers/{peerId}", p.HandlePeer).Methods("PUT")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -60,7 +60,7 @@ func (h *Policies) UpdatePolicy(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
policyID := vars["id"]
|
policyID := vars["policyId"]
|
||||||
if len(policyID) == 0 {
|
if len(policyID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
||||||
return
|
return
|
||||||
@ -78,7 +78,7 @@ func (h *Policies) UpdatePolicy(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiPoliciesIdJSONRequestBody
|
var req api.PutApiPoliciesPolicyIdJSONRequestBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -214,7 +214,7 @@ func (h *Policies) DeletePolicy(w http.ResponseWriter, r *http.Request) {
|
|||||||
aID := account.Id
|
aID := account.Id
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
policyID := vars["id"]
|
policyID := vars["policyId"]
|
||||||
if len(policyID) == 0 {
|
if len(policyID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
||||||
return
|
return
|
||||||
@ -240,7 +240,7 @@ func (h *Policies) GetPolicy(w http.ResponseWriter, r *http.Request) {
|
|||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
policyID := vars["id"]
|
policyID := vars["policyId"]
|
||||||
if len(policyID) == 0 {
|
if len(policyID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid policy ID"), w)
|
||||||
return
|
return
|
@ -103,7 +103,7 @@ func (h *RoutesHandler) UpdateRoute(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
routeID := vars["id"]
|
routeID := vars["routeId"]
|
||||||
if len(routeID) == 0 {
|
if len(routeID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
||||||
return
|
return
|
||||||
@ -115,7 +115,7 @@ func (h *RoutesHandler) UpdateRoute(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiRoutesIdJSONRequestBody
|
var req api.PutApiRoutesRouteIdJSONRequestBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -159,147 +159,6 @@ func (h *RoutesHandler) UpdateRoute(w http.ResponseWriter, r *http.Request) {
|
|||||||
util.WriteJSONObject(w, &resp)
|
util.WriteJSONObject(w, &resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchRoute handles patch updates to a route identified by a given ID
|
|
||||||
func (h *RoutesHandler) PatchRoute(w http.ResponseWriter, r *http.Request) {
|
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
|
||||||
account, user, err := h.accountManager.GetAccountFromToken(claims)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
routeID := vars["id"]
|
|
||||||
if len(routeID) == 0 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = h.accountManager.GetRoute(account.Id, routeID, user.Id)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var req api.PatchApiRoutesIdJSONRequestBody
|
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(req) == 0 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "no patch instruction received"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var operations []server.RouteUpdateOperation
|
|
||||||
|
|
||||||
for _, patch := range req {
|
|
||||||
switch patch.Path {
|
|
||||||
case api.RoutePatchOperationPathNetwork:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"network field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteNetwork,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathDescription:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"description field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteDescription,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathNetworkId:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"network Identifier field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteNetworkIdentifier,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathPeer:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"peer field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(patch.Value) > 1 {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"value field only accepts 1 value, got %d", len(patch.Value)), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRoutePeer,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathMetric:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"metric field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteMetric,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathMasquerade:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"masquerade field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteMasquerade,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathEnabled:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"enabled field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteEnabled,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
case api.RoutePatchOperationPathGroups:
|
|
||||||
if patch.Op != api.RoutePatchOperationOpReplace {
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument,
|
|
||||||
"groups field only accepts replace operation, got %s", patch.Op), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
operations = append(operations, server.RouteUpdateOperation{
|
|
||||||
Type: server.UpdateRouteGroups,
|
|
||||||
Values: patch.Value,
|
|
||||||
})
|
|
||||||
default:
|
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid patch path"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
root, err := h.accountManager.UpdateRoute(account.Id, routeID, operations)
|
|
||||||
if err != nil {
|
|
||||||
util.WriteError(err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := toRouteResponse(root)
|
|
||||||
|
|
||||||
util.WriteJSONObject(w, &resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteRoute handles route deletion request
|
// DeleteRoute handles route deletion request
|
||||||
func (h *RoutesHandler) DeleteRoute(w http.ResponseWriter, r *http.Request) {
|
func (h *RoutesHandler) DeleteRoute(w http.ResponseWriter, r *http.Request) {
|
||||||
claims := h.claimsExtractor.FromRequestContext(r)
|
claims := h.claimsExtractor.FromRequestContext(r)
|
||||||
@ -309,7 +168,7 @@ func (h *RoutesHandler) DeleteRoute(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routeID := mux.Vars(r)["id"]
|
routeID := mux.Vars(r)["routeId"]
|
||||||
if len(routeID) == 0 {
|
if len(routeID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
||||||
return
|
return
|
||||||
@ -333,7 +192,7 @@ func (h *RoutesHandler) GetRoute(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routeID := mux.Vars(r)["id"]
|
routeID := mux.Vars(r)["routeId"]
|
||||||
if len(routeID) == 0 {
|
if len(routeID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid route ID"), w)
|
||||||
return
|
return
|
||||||
|
@ -288,61 +288,6 @@ func TestRoutesHandlers(t *testing.T) {
|
|||||||
expectedStatus: http.StatusUnprocessableEntity,
|
expectedStatus: http.StatusUnprocessableEntity,
|
||||||
expectedBody: false,
|
expectedBody: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "PATCH Description OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/routes/" + existingRouteID,
|
|
||||||
requestBody: bytes.NewBufferString("[{\"op\":\"replace\",\"path\":\"description\",\"value\":[\"NewDesc\"]}]"),
|
|
||||||
expectedStatus: http.StatusOK,
|
|
||||||
expectedBody: true,
|
|
||||||
expectedRoute: &api.Route{
|
|
||||||
Id: existingRouteID,
|
|
||||||
Description: "NewDesc",
|
|
||||||
NetworkId: "awesomeNet",
|
|
||||||
Network: baseExistingRoute.Network.String(),
|
|
||||||
NetworkType: route.IPv4NetworkString,
|
|
||||||
Masquerade: baseExistingRoute.Masquerade,
|
|
||||||
Enabled: baseExistingRoute.Enabled,
|
|
||||||
Metric: baseExistingRoute.Metric,
|
|
||||||
Groups: baseExistingRoute.Groups,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "PATCH Peer OK",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/routes/" + existingRouteID,
|
|
||||||
requestBody: bytes.NewBufferString(fmt.Sprintf("[{\"op\":\"replace\",\"path\":\"peer\",\"value\":[\"%s\"]}]", existingPeerID)),
|
|
||||||
expectedStatus: http.StatusOK,
|
|
||||||
expectedBody: true,
|
|
||||||
expectedRoute: &api.Route{
|
|
||||||
Id: existingRouteID,
|
|
||||||
Description: "NewDesc",
|
|
||||||
NetworkId: "awesomeNet",
|
|
||||||
Network: baseExistingRoute.Network.String(),
|
|
||||||
NetworkType: route.IPv4NetworkString,
|
|
||||||
Peer: existingPeerID,
|
|
||||||
Masquerade: baseExistingRoute.Masquerade,
|
|
||||||
Enabled: baseExistingRoute.Enabled,
|
|
||||||
Metric: baseExistingRoute.Metric,
|
|
||||||
Groups: baseExistingRoute.Groups,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "PATCH Not Found Peer",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/routes/" + existingRouteID,
|
|
||||||
requestBody: bytes.NewBufferString(fmt.Sprintf("[{\"op\":\"replace\",\"path\":\"peer\",\"value\":[\"%s\"]}]", notFoundPeerID)),
|
|
||||||
expectedStatus: http.StatusUnprocessableEntity,
|
|
||||||
expectedBody: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "PATCH Not Found Route",
|
|
||||||
requestType: http.MethodPatch,
|
|
||||||
requestPath: "/api/routes/" + notFoundRouteID,
|
|
||||||
requestBody: bytes.NewBufferString("[{\"op\":\"replace\",\"path\":\"network\",\"value\":[\"192.168.0.0/34\"]}]"),
|
|
||||||
expectedStatus: http.StatusNotFound,
|
|
||||||
expectedBody: false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p := initRoutesTestData()
|
p := initRoutesTestData()
|
||||||
@ -353,11 +298,10 @@ func TestRoutesHandlers(t *testing.T) {
|
|||||||
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/routes/{id}", p.GetRoute).Methods("GET")
|
router.HandleFunc("/api/routes/{routeId}", p.GetRoute).Methods("GET")
|
||||||
router.HandleFunc("/api/routes/{id}", p.DeleteRoute).Methods("DELETE")
|
router.HandleFunc("/api/routes/{routeId}", p.DeleteRoute).Methods("DELETE")
|
||||||
router.HandleFunc("/api/routes", p.CreateRoute).Methods("POST")
|
router.HandleFunc("/api/routes", p.CreateRoute).Methods("POST")
|
||||||
router.HandleFunc("/api/routes/{id}", p.UpdateRoute).Methods("PUT")
|
router.HandleFunc("/api/routes/{routeId}", p.UpdateRoute).Methods("PUT")
|
||||||
router.HandleFunc("/api/routes/{id}", p.PatchRoute).Methods("PATCH")
|
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -65,7 +65,7 @@ func (h *RulesHandler) UpdateRule(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
ruleID := vars["id"]
|
ruleID := vars["ruleId"]
|
||||||
if len(ruleID) == 0 {
|
if len(ruleID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
||||||
return
|
return
|
||||||
@ -77,7 +77,7 @@ func (h *RulesHandler) UpdateRule(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var req api.PutApiRulesIdJSONRequestBody
|
var req api.PutApiRulesRuleIdJSONRequestBody
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -210,7 +210,7 @@ func (h *RulesHandler) DeleteRule(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
aID := account.Id
|
aID := account.Id
|
||||||
|
|
||||||
rID := mux.Vars(r)["id"]
|
rID := mux.Vars(r)["ruleId"]
|
||||||
if len(rID) == 0 {
|
if len(rID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
||||||
return
|
return
|
||||||
@ -236,7 +236,7 @@ func (h *RulesHandler) GetRule(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
ruleID := mux.Vars(r)["id"]
|
ruleID := mux.Vars(r)["ruleId"]
|
||||||
if len(ruleID) == 0 {
|
if len(ruleID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid rule ID"), w)
|
||||||
return
|
return
|
||||||
|
@ -133,7 +133,7 @@ func TestRulesGetRule(t *testing.T) {
|
|||||||
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
|
||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/rules/{id}", p.GetRule).Methods("GET")
|
router.HandleFunc("/api/rules/{ruleId}", p.GetRule).Methods("GET")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
@ -235,7 +235,7 @@ func TestRulesWriteRule(t *testing.T) {
|
|||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/rules", p.CreateRule).Methods("POST")
|
router.HandleFunc("/api/rules", p.CreateRule).Methods("POST")
|
||||||
router.HandleFunc("/api/rules/{id}", p.UpdateRule).Methods("PUT")
|
router.HandleFunc("/api/rules/{ruleId}", p.UpdateRule).Methods("PUT")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -84,7 +84,7 @@ func (h *SetupKeysHandler) GetSetupKey(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
keyID := vars["id"]
|
keyID := vars["keyId"]
|
||||||
if len(keyID) == 0 {
|
if len(keyID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid key ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid key ID"), w)
|
||||||
return
|
return
|
||||||
@ -109,13 +109,13 @@ func (h *SetupKeysHandler) UpdateSetupKey(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
keyID := vars["id"]
|
keyID := vars["keyId"]
|
||||||
if len(keyID) == 0 {
|
if len(keyID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid key ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid key ID"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &api.PutApiSetupKeysIdJSONRequestBody{}
|
req := &api.PutApiSetupKeysKeyIdJSONRequestBody{}
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
|
@ -174,8 +174,8 @@ func TestSetupKeysHandlers(t *testing.T) {
|
|||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/api/setup-keys", handler.GetAllSetupKeys).Methods("GET", "OPTIONS")
|
router.HandleFunc("/api/setup-keys", handler.GetAllSetupKeys).Methods("GET", "OPTIONS")
|
||||||
router.HandleFunc("/api/setup-keys", handler.CreateSetupKey).Methods("POST", "OPTIONS")
|
router.HandleFunc("/api/setup-keys", handler.CreateSetupKey).Methods("POST", "OPTIONS")
|
||||||
router.HandleFunc("/api/setup-keys/{id}", handler.GetSetupKey).Methods("GET", "OPTIONS")
|
router.HandleFunc("/api/setup-keys/{keyId}", handler.GetSetupKey).Methods("GET", "OPTIONS")
|
||||||
router.HandleFunc("/api/setup-keys/{id}", handler.UpdateSetupKey).Methods("PUT", "OPTIONS")
|
router.HandleFunc("/api/setup-keys/{keyId}", handler.UpdateSetupKey).Methods("PUT", "OPTIONS")
|
||||||
router.ServeHTTP(recorder, req)
|
router.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
res := recorder.Result()
|
res := recorder.Result()
|
||||||
|
@ -48,13 +48,13 @@ func (h *UsersHandler) UpdateUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
userID := vars["id"]
|
userID := vars["userId"]
|
||||||
if len(userID) == 0 {
|
if len(userID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid user ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid user ID"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &api.PutApiUsersIdJSONRequestBody{}
|
req := &api.PutApiUsersUserIdJSONRequestBody{}
|
||||||
err = json.NewDecoder(r.Body).Decode(&req)
|
err = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w)
|
||||||
@ -94,7 +94,7 @@ func (h *UsersHandler) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
targetUserID := vars["id"]
|
targetUserID := vars["userId"]
|
||||||
if len(targetUserID) == 0 {
|
if len(targetUserID) == 0 {
|
||||||
util.WriteError(status.Errorf(status.InvalidArgument, "invalid user ID"), w)
|
util.WriteError(status.Errorf(status.InvalidArgument, "invalid user ID"), w)
|
||||||
return
|
return
|
||||||
|
@ -219,21 +219,21 @@ func TestDeleteUser(t *testing.T) {
|
|||||||
name: "Delete Regular User",
|
name: "Delete Regular User",
|
||||||
requestType: http.MethodDelete,
|
requestType: http.MethodDelete,
|
||||||
requestPath: "/api/users/" + regularUserID,
|
requestPath: "/api/users/" + regularUserID,
|
||||||
requestVars: map[string]string{"id": regularUserID},
|
requestVars: map[string]string{"userId": regularUserID},
|
||||||
expectedStatus: http.StatusForbidden,
|
expectedStatus: http.StatusForbidden,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Delete Service User",
|
name: "Delete Service User",
|
||||||
requestType: http.MethodDelete,
|
requestType: http.MethodDelete,
|
||||||
requestPath: "/api/users/" + serviceUserID,
|
requestPath: "/api/users/" + serviceUserID,
|
||||||
requestVars: map[string]string{"id": serviceUserID},
|
requestVars: map[string]string{"userId": serviceUserID},
|
||||||
expectedStatus: http.StatusOK,
|
expectedStatus: http.StatusOK,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Delete Not Existing User",
|
name: "Delete Not Existing User",
|
||||||
requestType: http.MethodDelete,
|
requestType: http.MethodDelete,
|
||||||
requestPath: "/api/users/" + notFoundUserID,
|
requestPath: "/api/users/" + notFoundUserID,
|
||||||
requestVars: map[string]string{"id": notFoundUserID},
|
requestVars: map[string]string{"userId": notFoundUserID},
|
||||||
expectedStatus: http.StatusNotFound,
|
expectedStatus: http.StatusNotFound,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user