Skip to content

Commit

Permalink
KAZOO-6051: fix ips assignments (2600hz#5526)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson authored and lazedo committed Feb 19, 2019
1 parent 4f5873c commit daa2528
Show file tree
Hide file tree
Showing 12 changed files with 547 additions and 212 deletions.
42 changes: 28 additions & 14 deletions applications/crossbar/doc/ips.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ IP addresses assigned to the account

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`ips.[]` | | `string()` | | `false` |
`ips` | List of IP addresses | `array(string())` | | `false` |
`ips.[]` | | `string()|string()` | | |
`ips` | List of IP addresses | `array()` | | `false` |



Expand Down Expand Up @@ -53,24 +53,38 @@ curl -v -X GET \
```shell
curl -v -X POST \
-H "X-Auth-Token: {AUTH_TOKEN}" \
-d '{"data":["1.2.3.4"]}' \
-d '{"data": {"ips" :["1.2.3.4", "5.6.7.8"]}}' \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/ips
```

```json
{
"auth_token": "{AUTH_TOKEN}",
"data": [
{
"assigned_to": "{ACCOUNT_ID}",
"host": "proxy1.us-east.myswitch.com",
"id": "1.2.3.4",
"ip": "1.2.3.4",
"status": "assigned",
"type": "dedicated_ip",
"zone": "us-east"
}
],
"data": {
"ips": ["1.2.3.4", "5.6.7.8"]
},
"request_id": "{REQUEST_ID}",
"revision": "{REVISION}",
"status": "success"
}
```

## Remove IPs from Account

> DELETE /v2/accounts/{ACCOUNT_ID}/ips
```shell
curl -v -X DELETE \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/ips
```

```json
{
"auth_token": "{AUTH_TOKEN}",
"data": {
"ips": ["1.2.3.4", "5.6.7.8"]
},
"request_id": "{REQUEST_ID}",
"revision": "{REVISION}",
"status": "success"
Expand Down
14 changes: 12 additions & 2 deletions applications/crossbar/doc/ref/ips.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ IP addresses assigned to the account

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`ips.[]` | | `string()` | | `false` |
`ips` | List of IP addresses | `array(string())` | | `false` |
`ips.[]` | | `string()|string()` | | |
`ips` | List of IP addresses | `array()` | | `false` |



Expand Down Expand Up @@ -45,6 +45,16 @@ curl -v -X POST \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/ips
```

## Remove

> DELETE /v2/accounts/{ACCOUNT_ID}/ips
```shell
curl -v -X DELETE \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/ips
```

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/ips/{IP_ADDRESS}
Expand Down
59 changes: 58 additions & 1 deletion applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6178,14 +6178,56 @@
],
"type": "object"
},
"ip": {
"description": "IP address assigned to the cluster",
"properties": {
"host": {
"description": "The hostname the IP belongs to",
"minLength": 1,
"type": "string"
},
"ip": {
"description": "The IP addresses",
"oneOf": [
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"zone": {
"description": "The zone name the IP belongs to",
"minLength": 1,
"type": "string"
}
},
"required": [
"ip",
"zone",
"host"
]
},
"ips": {
"description": "IP addresses assigned to the account",
"properties": {
"ips": {
"description": "List of IP addresses",
"items": {
"description": "IP address",
"type": "string"
"oneOf": [
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"minItems": 1,
"type": "array"
Expand Down Expand Up @@ -39628,6 +39670,21 @@
}
},
"/accounts/{ACCOUNT_ID}/ips": {
"delete": {
"parameters": [
{
"$ref": "#/parameters/auth_token_header"
},
{
"$ref": "#/parameters/ACCOUNT_ID"
}
],
"responses": {
"200": {
"description": "request succeeded"
}
}
},
"get": {
"parameters": [
{
Expand Down
35 changes: 35 additions & 0 deletions applications/crossbar/priv/couchdb/schemas/ip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"_id": "ip",
"description": "IP address assigned to the cluster",
"properties": {
"host": {
"description": "The hostname the IP belongs to",
"minLength": 1,
"type": "string"
},
"ip": {
"description": "The IP addresses",
"oneOf": [
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"zone": {
"description": "The zone name the IP belongs to",
"minLength": 1,
"type": "string"
}
},
"required": [
"ip",
"zone",
"host"
]
}
11 changes: 10 additions & 1 deletion applications/crossbar/priv/couchdb/schemas/ips.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
"description": "List of IP addresses",
"items": {
"description": "IP address",
"type": "string"
"oneOf": [
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"minItems": 1,
"type": "array"
Expand Down
1 change: 0 additions & 1 deletion applications/crossbar/src/cb_context.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,6 @@ add_validation_error(Property, Code, Message, Context) ->
)
),
ErrorsJObj = validation_errors(Context),

Context#cb_context{validation_errors=kz_json:merge_jobjs(ErrorJObj, ErrorsJObj)
,resp_status='error'
,resp_error_code=ErrorCode
Expand Down
Loading

0 comments on commit daa2528

Please sign in to comment.