-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UpdateUser endpoint for Databases (#847)
- Loading branch information
1 parent
e3fe224
commit cbd1bc6
Showing
5 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
specification/resources/databases/databases_update_user.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
operationId: databases_update_user | ||
|
||
summary: Update a Database User | ||
|
||
description: | | ||
To update an existing database user, send a PUT request to `/v2/databases/$DATABASE_ID/users/$USERNAME` | ||
with the desired settings. | ||
**Note**: only `settings` can be updated via this type of request. If you wish to change the name of a user, | ||
you must recreate a new user. | ||
The response will be a JSON object with a key called `user`. The value of this will be an | ||
object that contains the name of the update database user, along with the `settings` object that | ||
has been updated. | ||
tags: | ||
- Databases | ||
|
||
parameters: | ||
- $ref: 'parameters.yml#/database_cluster_uuid' | ||
- $ref: 'parameters.yml#/username' | ||
|
||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- type: object | ||
properties: | ||
settings: | ||
$ref: './models/user_settings.yml' | ||
required: | ||
- settings | ||
examples: | ||
Update User Kafka ACLs: | ||
value: | ||
settings: | ||
acl: | ||
- id: acl128aaaa99239 | ||
permission: produceconsume | ||
topic: customer-events | ||
- id: acl293098flskdf | ||
permission: produce | ||
topic: customer-events.* | ||
- id: acl128ajei20123 | ||
permission: consume | ||
topic: customer-events | ||
|
||
responses: | ||
'201': | ||
$ref: 'responses/user.yml' | ||
|
||
'401': | ||
$ref: '../../shared/responses/unauthorized.yml' | ||
|
||
'404': | ||
$ref: '../../shared/responses/not_found.yml' | ||
|
||
'429': | ||
$ref: '../../shared/responses/too_many_requests.yml' | ||
|
||
'500': | ||
$ref: '../../shared/responses/server_error.yml' | ||
|
||
default: | ||
$ref: '../../shared/responses/unexpected_error.yml' | ||
|
||
x-codeSamples: | ||
- $ref: 'examples/curl/databases_update_user.yml' | ||
- $ref: 'examples/go/databases_update_user.yml' | ||
|
||
security: | ||
- bearer_auth: | ||
- 'write' |
7 changes: 7 additions & 0 deletions
7
specification/resources/databases/examples/curl/databases_update_user.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lang: cURL | ||
source: |- | ||
curl -X PUT \ | ||
-H "Content-Type: application/json" \ | ||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ | ||
-d '{"settings": {"acl": [{"topic": "events", "permission": "produce"}]}}' \ | ||
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/users" |
33 changes: 33 additions & 0 deletions
33
specification/resources/databases/examples/go/databases_update_user.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
lang: Go | ||
source: |- | ||
import ( | ||
"context" | ||
"os" | ||
"github.com/digitalocean/godo" | ||
) | ||
func main() { | ||
token := os.Getenv("DIGITALOCEAN_TOKEN") | ||
client := godo.NewFromToken(token) | ||
ctx := context.TODO() | ||
userName := "test-user" | ||
updateUserRequest := &godo.DatabaseUpdateUserRequest{ | ||
Settings: { | ||
ACL: [ | ||
{ | ||
Permssion: "consume", | ||
Topic: "events", | ||
} | ||
{ | ||
Permission: "produce", | ||
Topic: "metrics", | ||
} | ||
] | ||
} | ||
} | ||
user, _, err := client.Databases.UpdateUser(ctx, "88055188-9e54-4f21-ab11-8a918ed79ee2", userName, updateUserRequest) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters