summaryrefslogtreecommitdiff
path: root/api-ref/source/user-management.inc
blob: d17be907d2280133a4ae4b4c1f47393299f95437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
.. -*- rst -*-

=============
Users (users)
=============

Creates, lists all, and deletes users.


Enable root user
~~~~~~~~~~~~~~~~

.. rest_method::  POST /v1.0/{accountId}/instances/{instanceId}/root

Enables the root user for a database instance and returns the root password.

This operation generates a root password for the root user and
enables the root user to log in from any host.

Changes that you make as a root user can impact the database instance
and API operations in unpredictable and detrimental ways.  When you
enable the root user, you accept the possibility that we cannot
support your database instance. We might not be able to assist you if
you change core database settings. These changes can be, but are not
limited to, turning off bin logs, removing users that we use to access
your instance, and so on.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId


Response Example
----------------

.. literalinclude:: samples/db-enable-root-user-response.json
   :language: javascript




Show root-enabled status for database instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. rest_method::  GET /v1.0/{accountId}/instances/{instanceId}/root

Shows root-enabled status for a database instance.

Returns ``true`` if root user is enabled for a database instance.
Otherwise, returns ``false``.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId


Response Example
----------------

.. literalinclude:: samples/db-check-root-user-response.json
   :language: javascript




Disable root user
~~~~~~~~~~~~~~~~~

.. rest_method::  DELETE /v1.0/{accountId}/instances/{instanceId}/root

Disables the root user.

Normal response codes: 204

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId




Delete user
~~~~~~~~~~~

.. rest_method::  DELETE /v1.0/{accountId}/instances/{instanceId}/users/{name}

Deletes a user for a database instance.

Normal response codes: 202

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId
   - name: user_name




Create user
~~~~~~~~~~~

.. rest_method::  POST /v1.0/{accountId}/instances/{instanceId}/users

Creates a user for a database instance.

Asynchronously provisions a new user for the database instance by
using the configuration that you define in the request object.
After the API validates the request and starts progress on the
provisioning process, the call returns the ``Accepted (202)``
response code.

If the API cannot fulfill the corresponding request due to
insufficient data or data that is not valid, the API returns the
``Bad Request (400)`` response code with information about the
nature of the failure. You cannot recover from validation errors.
You must correct the cause of the failure and the request again.

This table lists the required attributes for creating users:

**Required attributes for user**

+-----------------+------+------------------------------------+----------+
|    Applies to   | Name |            Description             | Required |
+-----------------+------+------------------------------------+----------+
|       User      | name | Name of the user for the database. |   Yes    |
+-----------------+------+------------------------------------+----------+
|     password    |      | User password for database access. |   Yes    |
+-----------------+------+-------------------------+----------+----------+
| (database) name |      | Name of the database(s) that the   |          |
|                 |      | user can access. You can specify   |   No     |
|                 |      | one or more database names.        |          |
+-----------------+------+------------------------------------+----------+

Name of the database that the user can access. You can specify one or more
database names.

 **Notes**

- The operation grants the user all privileges on the databases.

- Do not use the ``root`` user name, which is reserved.

These tables list the valid characters for database names, user
names, and passwords.

**Valid characters in database name, user name, and password**

+---------------------------------------------------------------------------------------------------------------------------------+
|                                                            Character                                                            |
+---------------------------------------------------------------------------------------------------------------------------------+
|                                             Letters (upper and lower cases allowed)                                             |
+---------------------------------------------------------------------------------------------------------------------------------+
|                                                             Numbers                                                             |
+---------------------------------------------------------------------------------------------------------------------------------+
| ``@``, ``?``, ``#``, and spaces are allowed, but **not** at the beginning and end of the database name, user name, and password |
+---------------------------------------------------------------------------------------------------------------------------------+
|                             ``_`` is allowed anywhere in the database name, user name, and password                             |
+---------------------------------------------------------------------------------------------------------------------------------+

**Characters that are not allowed in database name, user name, and password**

+---------------------------------------------------------+
|                        Character                        |
+---------------------------------------------------------+
|                      Single quotes                      |
+---------------------------------------------------------+
|                      Double quotes                      |
+---------------------------------------------------------+
|                       Back quotes                       |
+---------------------------------------------------------+
|                        Semicolons                       |
+---------------------------------------------------------+
|                          Commas                         |
+---------------------------------------------------------+
|                       Back slashes                      |
+---------------------------------------------------------+
|                     Forward slashes                     |
+---------------------------------------------------------+
| Spaces at the front or end of the user name or password |
+---------------------------------------------------------+

**Length restrictions for database name, user name, and password**

+------------------------------+-----------------------------+
|         Restriction          |            Value            |
+------------------------------+-----------------------------+
| Database name maximum length |              64             |
+------------------------------+-----------------------------+
|   User name maximum length   |              16             |
+------------------------------+-----------------------------+
|   Password maximum length    | unlimited (no restrictions) |
+------------------------------+-----------------------------+

Normal response codes: 202

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId

Request Example
---------------

.. literalinclude:: samples/db-create-users-request.json
   :language: javascript




List database instance users
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. rest_method::  GET /v1.0/{accountId}/instances/{instanceId}/users

Lists the users in a database instance and the associated databases for that
user.

This operation does not return system users. A system user is a
database administrator who administers the health of the database.
Also, this operation returns the ``root`` user only if it is
enabled.

The following notes apply to MySQL users:

- User names can be up to 16 characters long.

- When you create accounts with INSERT, you must use FLUSH
  PRIVILEGES to tell the server to reload the grant tables.

- For additional information, See:
  `http://dev.mysql.com/doc/refman/5.1/en/user-account-
  management.html <http://dev.mysql.com/doc/refman/5.1/en/user-
  account-management.html>`_

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),
instanceFault(500), notImplemented(501), serviceUnavailable(503)


Request
-------

.. rest_parameters:: parameters.yaml

   - instanceId: instanceId
   - accountId: accountId


Response Example
----------------

.. literalinclude:: samples/db-list-users-response.json
   :language: javascript