|
24 | 24 | CreateInstanceRequest, |
25 | 25 | CreateInstanceRequestVolumeDetails, |
26 | 26 | CreateSnapshotRequest, |
| 27 | + CreateUserRequest, |
27 | 28 | EndpointSpec, |
28 | 29 | Instance, |
29 | 30 | ListInstancesResponse, |
|
57 | 58 | unmarshal_ListVersionsResponse, |
58 | 59 | marshal_CreateInstanceRequest, |
59 | 60 | marshal_CreateSnapshotRequest, |
| 61 | + marshal_CreateUserRequest, |
60 | 62 | marshal_RestoreSnapshotRequest, |
61 | 63 | marshal_UpdateInstanceRequest, |
62 | 64 | marshal_UpdateSnapshotRequest, |
@@ -1070,6 +1072,55 @@ async def list_users_all( |
1070 | 1072 | }, |
1071 | 1073 | ) |
1072 | 1074 |
|
| 1075 | + async def create_user( |
| 1076 | + self, |
| 1077 | + *, |
| 1078 | + instance_id: str, |
| 1079 | + name: str, |
| 1080 | + region: Optional[Region] = None, |
| 1081 | + password: Optional[str] = None, |
| 1082 | + ) -> User: |
| 1083 | + """ |
| 1084 | + Create an user on a Database Instance. |
| 1085 | + Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request. |
| 1086 | + :param instance_id: UUID of the Database Instance the user belongs to. |
| 1087 | + :param name: Name of the database user. |
| 1088 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1089 | + :param password: Password of the database user. |
| 1090 | + :return: :class:`User <User>` |
| 1091 | +
|
| 1092 | + Usage: |
| 1093 | + :: |
| 1094 | +
|
| 1095 | + result = await api.create_user( |
| 1096 | + instance_id="example", |
| 1097 | + name="example", |
| 1098 | + ) |
| 1099 | + """ |
| 1100 | + |
| 1101 | + param_region = validate_path_param( |
| 1102 | + "region", region or self.client.default_region |
| 1103 | + ) |
| 1104 | + param_instance_id = validate_path_param("instance_id", instance_id) |
| 1105 | + param_name = validate_path_param("name", name) |
| 1106 | + |
| 1107 | + res = self._request( |
| 1108 | + "POST", |
| 1109 | + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}", |
| 1110 | + body=marshal_CreateUserRequest( |
| 1111 | + CreateUserRequest( |
| 1112 | + instance_id=instance_id, |
| 1113 | + name=name, |
| 1114 | + region=region, |
| 1115 | + password=password, |
| 1116 | + ), |
| 1117 | + self.client, |
| 1118 | + ), |
| 1119 | + ) |
| 1120 | + |
| 1121 | + self._throw_on_error(res) |
| 1122 | + return unmarshal_User(res.json()) |
| 1123 | + |
1073 | 1124 | async def update_user( |
1074 | 1125 | self, |
1075 | 1126 | *, |
|
0 commit comments