1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "common/ceph_json.h"
8 #include "rgw_rest_user.h"
10 #include "include/str_list.h"
11 #include "include/assert.h"
13 #define dout_subsys ceph_subsys_rgw
15 class RGWOp_User_Info
: public RGWRESTOp
{
20 int check_caps(RGWUserCaps
& caps
) override
{
21 return caps
.check_cap("users", RGW_CAP_READ
);
24 void execute() override
;
26 const string
name() override
{ return "get_user_info"; }
29 void RGWOp_User_Info::execute()
31 RGWUserAdminOpState op_state
;
36 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
38 // if uid was not supplied in rest argument, error out now, otherwise we'll
39 // end up initializing anonymous user, for which keys.init will eventually
46 rgw_user
uid(uid_str
);
48 RESTArgs::get_bool(s
, "stats", false, &fetch_stats
);
50 op_state
.set_user_id(uid
);
51 op_state
.set_fetch_stats(fetch_stats
);
53 http_ret
= RGWUserAdminOp_User::info(store
, op_state
, flusher
);
56 class RGWOp_User_Create
: public RGWRESTOp
{
59 RGWOp_User_Create() {}
61 int check_caps(RGWUserCaps
& caps
) override
{
62 return caps
.check_cap("users", RGW_CAP_WRITE
);
65 void execute() override
;
67 const string
name() override
{ return "create_user"; }
70 void RGWOp_User_Create::execute()
73 std::string display_name
;
75 std::string access_key
;
76 std::string secret_key
;
77 std::string key_type_str
;
79 std::string tenant_name
;
87 int32_t default_max_buckets
= s
->cct
->_conf
->rgw_user_max_buckets
;
89 RGWUserAdminOpState op_state
;
91 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
92 rgw_user
uid(uid_str
);
94 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
95 RESTArgs::get_string(s
, "email", email
, &email
);
96 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
97 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
98 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
99 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
100 RESTArgs::get_string(s
, "tenant", tenant_name
, &tenant_name
);
101 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
102 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
103 RESTArgs::get_int32(s
, "max-buckets", default_max_buckets
, &max_buckets
);
104 RESTArgs::get_bool(s
, "system", false, &system
);
105 RESTArgs::get_bool(s
, "exclusive", false, &exclusive
);
107 if (!s
->user
->system
&& system
) {
108 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
113 if (!tenant_name
.empty()) {
114 uid
.tenant
= tenant_name
;
117 // TODO: validate required args are passed in. (for eg. uid and display_name here)
118 op_state
.set_user_id(uid
);
119 op_state
.set_display_name(display_name
);
120 op_state
.set_user_email(email
);
121 op_state
.set_caps(caps
);
122 op_state
.set_access_key(access_key
);
123 op_state
.set_secret_key(secret_key
);
125 if (!key_type_str
.empty()) {
126 int32_t key_type
= KEY_TYPE_UNDEFINED
;
127 if (key_type_str
.compare("swift") == 0)
128 key_type
= KEY_TYPE_SWIFT
;
129 else if (key_type_str
.compare("s3") == 0)
130 key_type
= KEY_TYPE_S3
;
132 op_state
.set_key_type(key_type
);
135 if (max_buckets
!= default_max_buckets
)
136 op_state
.set_max_buckets(max_buckets
);
138 if (s
->info
.args
.exists("suspended"))
139 op_state
.set_suspension(suspended
);
141 if (s
->info
.args
.exists("system"))
142 op_state
.set_system(system
);
144 if (s
->info
.args
.exists("exclusive"))
145 op_state
.set_exclusive(exclusive
);
148 op_state
.set_generate_key();
150 RGWQuotaInfo bucket_quota
;
151 RGWQuotaInfo user_quota
;
153 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
>= 0) {
154 bucket_quota
.max_objects
= s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
;
155 bucket_quota
.enabled
= true;
158 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_size
>= 0) {
159 bucket_quota
.max_size
= s
->cct
->_conf
->rgw_bucket_default_quota_max_size
;
160 bucket_quota
.enabled
= true;
163 if (s
->cct
->_conf
->rgw_user_default_quota_max_objects
>= 0) {
164 user_quota
.max_objects
= s
->cct
->_conf
->rgw_user_default_quota_max_objects
;
165 user_quota
.enabled
= true;
168 if (s
->cct
->_conf
->rgw_user_default_quota_max_size
>= 0) {
169 user_quota
.max_size
= s
->cct
->_conf
->rgw_user_default_quota_max_size
;
170 user_quota
.enabled
= true;
173 if (bucket_quota
.enabled
) {
174 op_state
.set_bucket_quota(bucket_quota
);
177 if (user_quota
.enabled
) {
178 op_state
.set_user_quota(user_quota
);
181 http_ret
= RGWUserAdminOp_User::create(store
, op_state
, flusher
);
184 class RGWOp_User_Modify
: public RGWRESTOp
{
187 RGWOp_User_Modify() {}
189 int check_caps(RGWUserCaps
& caps
) override
{
190 return caps
.check_cap("users", RGW_CAP_WRITE
);
193 void execute() override
;
195 const string
name() override
{ return "modify_user"; }
198 void RGWOp_User_Modify::execute()
201 std::string display_name
;
203 std::string access_key
;
204 std::string secret_key
;
205 std::string key_type_str
;
214 RGWUserAdminOpState op_state
;
216 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
217 rgw_user
uid(uid_str
);
219 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
220 RESTArgs::get_string(s
, "email", email
, &email
);
221 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
222 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
223 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
224 RESTArgs::get_bool(s
, "generate-key", false, &gen_key
);
225 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
226 RESTArgs::get_int32(s
, "max-buckets", RGW_DEFAULT_MAX_BUCKETS
, &max_buckets
);
227 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
229 RESTArgs::get_bool(s
, "system", false, &system
);
231 if (!s
->user
->system
&& system
) {
232 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
237 op_state
.set_user_id(uid
);
238 op_state
.set_display_name(display_name
);
239 op_state
.set_user_email(email
);
240 op_state
.set_caps(caps
);
241 op_state
.set_access_key(access_key
);
242 op_state
.set_secret_key(secret_key
);
244 if (max_buckets
!= RGW_DEFAULT_MAX_BUCKETS
)
245 op_state
.set_max_buckets(max_buckets
);
248 op_state
.set_generate_key();
250 if (!key_type_str
.empty()) {
251 int32_t key_type
= KEY_TYPE_UNDEFINED
;
252 if (key_type_str
.compare("swift") == 0)
253 key_type
= KEY_TYPE_SWIFT
;
254 else if (key_type_str
.compare("s3") == 0)
255 key_type
= KEY_TYPE_S3
;
257 op_state
.set_key_type(key_type
);
260 if (s
->info
.args
.exists("suspended"))
261 op_state
.set_suspension(suspended
);
263 if (s
->info
.args
.exists("system"))
264 op_state
.set_system(system
);
266 http_ret
= RGWUserAdminOp_User::modify(store
, op_state
, flusher
);
269 class RGWOp_User_Remove
: public RGWRESTOp
{
272 RGWOp_User_Remove() {}
274 int check_caps(RGWUserCaps
& caps
) override
{
275 return caps
.check_cap("users", RGW_CAP_WRITE
);
278 void execute() override
;
280 const string
name() override
{ return "remove_user"; }
283 void RGWOp_User_Remove::execute()
288 RGWUserAdminOpState op_state
;
290 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
291 rgw_user
uid(uid_str
);
293 RESTArgs::get_bool(s
, "purge-data", false, &purge_data
);
295 // FIXME: no double checking
297 op_state
.set_user_id(uid
);
299 op_state
.set_purge_data(purge_data
);
301 http_ret
= RGWUserAdminOp_User::remove(store
, op_state
, flusher
);
304 class RGWOp_Subuser_Create
: public RGWRESTOp
{
307 RGWOp_Subuser_Create() {}
309 int check_caps(RGWUserCaps
& caps
) override
{
310 return caps
.check_cap("users", RGW_CAP_WRITE
);
313 void execute() override
;
315 const string
name() override
{ return "create_subuser"; }
318 void RGWOp_Subuser_Create::execute()
322 std::string secret_key
;
323 std::string access_key
;
324 std::string perm_str
;
325 std::string key_type_str
;
327 bool gen_subuser
= false; // FIXME placeholder
331 uint32_t perm_mask
= 0;
332 int32_t key_type
= KEY_TYPE_SWIFT
;
334 RGWUserAdminOpState op_state
;
336 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
337 rgw_user
uid(uid_str
);
339 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
340 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
341 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
342 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
343 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
344 //RESTArgs::get_bool(s, "generate-subuser", false, &gen_subuser);
345 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
346 RESTArgs::get_bool(s
, "gen-access-key", false, &gen_access
);
348 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
349 op_state
.set_perm(perm_mask
);
351 op_state
.set_user_id(uid
);
352 op_state
.set_subuser(subuser
);
353 op_state
.set_access_key(access_key
);
354 op_state
.set_secret_key(secret_key
);
355 op_state
.set_generate_subuser(gen_subuser
);
358 op_state
.set_gen_access();
361 op_state
.set_gen_secret();
363 if (!key_type_str
.empty()) {
364 if (key_type_str
.compare("swift") == 0)
365 key_type
= KEY_TYPE_SWIFT
;
366 else if (key_type_str
.compare("s3") == 0)
367 key_type
= KEY_TYPE_S3
;
369 op_state
.set_key_type(key_type
);
371 http_ret
= RGWUserAdminOp_Subuser::create(store
, op_state
, flusher
);
374 class RGWOp_Subuser_Modify
: public RGWRESTOp
{
377 RGWOp_Subuser_Modify() {}
379 int check_caps(RGWUserCaps
& caps
) override
{
380 return caps
.check_cap("users", RGW_CAP_WRITE
);
383 void execute() override
;
385 const string
name() override
{ return "modify_subuser"; }
388 void RGWOp_Subuser_Modify::execute()
392 std::string secret_key
;
393 std::string key_type_str
;
394 std::string perm_str
;
396 RGWUserAdminOpState op_state
;
399 int32_t key_type
= KEY_TYPE_SWIFT
;
403 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
404 rgw_user
uid(uid_str
);
406 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
407 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
408 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
409 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
410 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
412 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
413 op_state
.set_perm(perm_mask
);
415 op_state
.set_user_id(uid
);
416 op_state
.set_subuser(subuser
);
417 op_state
.set_secret_key(secret_key
);
418 op_state
.set_gen_secret();
420 if (!key_type_str
.empty()) {
421 if (key_type_str
.compare("swift") == 0)
422 key_type
= KEY_TYPE_SWIFT
;
423 else if (key_type_str
.compare("s3") == 0)
424 key_type
= KEY_TYPE_S3
;
426 op_state
.set_key_type(key_type
);
428 http_ret
= RGWUserAdminOp_Subuser::modify(store
, op_state
, flusher
);
431 class RGWOp_Subuser_Remove
: public RGWRESTOp
{
434 RGWOp_Subuser_Remove() {}
436 int check_caps(RGWUserCaps
& caps
) override
{
437 return caps
.check_cap("users", RGW_CAP_WRITE
);
440 void execute() override
;
442 const string
name() override
{ return "remove_subuser"; }
445 void RGWOp_Subuser_Remove::execute()
451 RGWUserAdminOpState op_state
;
453 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
454 rgw_user
uid(uid_str
);
456 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
457 RESTArgs::get_bool(s
, "purge-keys", true, &purge_keys
);
459 op_state
.set_user_id(uid
);
460 op_state
.set_subuser(subuser
);
463 op_state
.set_purge_keys();
465 http_ret
= RGWUserAdminOp_Subuser::remove(store
, op_state
, flusher
);
468 class RGWOp_Key_Create
: public RGWRESTOp
{
471 RGWOp_Key_Create() {}
473 int check_caps(RGWUserCaps
& caps
) override
{
474 return caps
.check_cap("users", RGW_CAP_WRITE
);
477 void execute() override
;
479 const string
name() override
{ return "create_access_key"; }
482 void RGWOp_Key_Create::execute()
486 std::string access_key
;
487 std::string secret_key
;
488 std::string key_type_str
;
492 RGWUserAdminOpState op_state
;
494 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
495 rgw_user
uid(uid_str
);
497 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
498 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
499 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
500 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
501 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
503 op_state
.set_user_id(uid
);
504 op_state
.set_subuser(subuser
);
505 op_state
.set_access_key(access_key
);
506 op_state
.set_secret_key(secret_key
);
509 op_state
.set_generate_key();
511 if (!key_type_str
.empty()) {
512 int32_t key_type
= KEY_TYPE_UNDEFINED
;
513 if (key_type_str
.compare("swift") == 0)
514 key_type
= KEY_TYPE_SWIFT
;
515 else if (key_type_str
.compare("s3") == 0)
516 key_type
= KEY_TYPE_S3
;
518 op_state
.set_key_type(key_type
);
521 http_ret
= RGWUserAdminOp_Key::create(store
, op_state
, flusher
);
524 class RGWOp_Key_Remove
: public RGWRESTOp
{
527 RGWOp_Key_Remove() {}
529 int check_caps(RGWUserCaps
& caps
) override
{
530 return caps
.check_cap("users", RGW_CAP_WRITE
);
533 void execute() override
;
535 const string
name() override
{ return "remove_access_key"; }
538 void RGWOp_Key_Remove::execute()
542 std::string access_key
;
543 std::string key_type_str
;
545 RGWUserAdminOpState op_state
;
547 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
548 rgw_user
uid(uid_str
);
550 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
551 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
552 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
554 op_state
.set_user_id(uid
);
555 op_state
.set_subuser(subuser
);
556 op_state
.set_access_key(access_key
);
558 if (!key_type_str
.empty()) {
559 int32_t key_type
= KEY_TYPE_UNDEFINED
;
560 if (key_type_str
.compare("swift") == 0)
561 key_type
= KEY_TYPE_SWIFT
;
562 else if (key_type_str
.compare("s3") == 0)
563 key_type
= KEY_TYPE_S3
;
565 op_state
.set_key_type(key_type
);
568 http_ret
= RGWUserAdminOp_Key::remove(store
, op_state
, flusher
);
571 class RGWOp_Caps_Add
: public RGWRESTOp
{
576 int check_caps(RGWUserCaps
& caps
) override
{
577 return caps
.check_cap("users", RGW_CAP_WRITE
);
580 void execute() override
;
582 const string
name() override
{ return "add_user_caps"; }
585 void RGWOp_Caps_Add::execute()
590 RGWUserAdminOpState op_state
;
592 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
593 rgw_user
uid(uid_str
);
595 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
597 op_state
.set_user_id(uid
);
598 op_state
.set_caps(caps
);
600 http_ret
= RGWUserAdminOp_Caps::add(store
, op_state
, flusher
);
603 class RGWOp_Caps_Remove
: public RGWRESTOp
{
606 RGWOp_Caps_Remove() {}
608 int check_caps(RGWUserCaps
& caps
) override
{
609 return caps
.check_cap("users", RGW_CAP_WRITE
);
612 void execute() override
;
614 const string
name() override
{ return "remove_user_caps"; }
617 void RGWOp_Caps_Remove::execute()
622 RGWUserAdminOpState op_state
;
624 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
625 rgw_user
uid(uid_str
);
627 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
629 op_state
.set_user_id(uid
);
630 op_state
.set_caps(caps
);
632 http_ret
= RGWUserAdminOp_Caps::remove(store
, op_state
, flusher
);
636 RGWQuotaInfo bucket_quota
;
637 RGWQuotaInfo user_quota
;
641 explicit UserQuotas(RGWUserInfo
& info
) : bucket_quota(info
.bucket_quota
),
642 user_quota(info
.user_quota
) {}
644 void dump(Formatter
*f
) const {
645 encode_json("bucket_quota", bucket_quota
, f
);
646 encode_json("user_quota", user_quota
, f
);
648 void decode_json(JSONObj
*obj
) {
649 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
650 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
654 class RGWOp_Quota_Info
: public RGWRESTOp
{
657 RGWOp_Quota_Info() {}
659 int check_caps(RGWUserCaps
& caps
) override
{
660 return caps
.check_cap("users", RGW_CAP_READ
);
663 void execute() override
;
665 const string
name() override
{ return "get_quota_info"; }
669 void RGWOp_Quota_Info::execute()
671 RGWUserAdminOpState op_state
;
674 std::string quota_type
;
676 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
677 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
679 if (uid_str
.empty()) {
684 rgw_user
uid(uid_str
);
686 bool show_all
= quota_type
.empty();
687 bool show_bucket
= show_all
|| (quota_type
== "bucket");
688 bool show_user
= show_all
|| (quota_type
== "user");
690 if (!(show_all
|| show_bucket
|| show_user
)) {
695 op_state
.set_user_id(uid
);
698 http_ret
= user
.init(store
, op_state
);
702 if (!op_state
.has_existing_user()) {
703 http_ret
= -ERR_NO_SUCH_USER
;
709 http_ret
= user
.info(info
, &err_msg
);
715 UserQuotas
quotas(info
);
716 encode_json("quota", quotas
, s
->formatter
);
717 } else if (show_user
) {
718 encode_json("user_quota", info
.user_quota
, s
->formatter
);
720 encode_json("bucket_quota", info
.bucket_quota
, s
->formatter
);
726 class RGWOp_Quota_Set
: public RGWRESTOp
{
731 int check_caps(RGWUserCaps
& caps
) override
{
732 return caps
.check_cap("users", RGW_CAP_WRITE
);
735 void execute() override
;
737 const string
name() override
{ return "set_quota_info"; }
743 * two different ways to set the quota info: as json struct in the message body or via http params.
747 * PUT /admin/user?uid=<uid>["a-type=<type>]
749 * whereas quota-type is optional and is either user, or bucket
751 * if quota-type is not specified then we expect to get a structure that contains both quotas,
752 * otherwise we'll only get the relevant configuration.
754 * E.g., if quota type not specified:
757 * "max_size_kb" : 4096,
758 * "max_objects" : -1,
762 * "max_size_kb" : 1024,
763 * "max_objects" : -1,
769 * or if quota type is specified:
771 * "max_size_kb" : 4096,
772 * "max_objects" : -1,
776 * Another option is not to pass any body and set the following http params:
780 * max-objects=<max objects>
781 * enabled[={true,false}]
783 * all params are optionals and default to the current settings. With this type of configuration the
784 * quota-type param is mandatory.
788 void RGWOp_Quota_Set::execute()
790 RGWUserAdminOpState op_state
;
793 std::string quota_type
;
795 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
796 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
798 if (uid_str
.empty()) {
803 rgw_user
uid(uid_str
);
805 bool set_all
= quota_type
.empty();
806 bool set_bucket
= set_all
|| (quota_type
== "bucket");
807 bool set_user
= set_all
|| (quota_type
== "user");
809 if (!(set_all
|| set_bucket
|| set_user
)) {
810 ldout(store
->ctx(), 20) << "invalid quota type" << dendl
;
815 bool use_http_params
;
817 if (s
->content_length
> 0) {
818 use_http_params
= false;
820 const char *encoding
= s
->info
.env
->get("HTTP_TRANSFER_ENCODING");
821 use_http_params
= (!encoding
|| strcmp(encoding
, "chunked") != 0);
824 if (use_http_params
&& set_all
) {
825 ldout(store
->ctx(), 20) << "quota type was not specified, can't set all quotas via http headers" << dendl
;
830 op_state
.set_user_id(uid
);
833 http_ret
= user
.init(store
, op_state
);
835 ldout(store
->ctx(), 20) << "failed initializing user info: " << http_ret
<< dendl
;
839 if (!op_state
.has_existing_user()) {
840 http_ret
= -ERR_NO_SUCH_USER
;
844 #define QUOTA_INPUT_MAX_LEN 1024
848 if ((http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quotas
, QUOTA_INPUT_MAX_LEN
, NULL
)) < 0) {
849 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
853 op_state
.set_user_quota(quotas
.user_quota
);
854 op_state
.set_bucket_quota(quotas
.bucket_quota
);
858 if (!use_http_params
) {
860 http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quota
, QUOTA_INPUT_MAX_LEN
, &empty
);
862 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
866 /* was probably chunked input, but no content provided, configure via http params */
867 use_http_params
= true;
871 if (use_http_params
) {
874 http_ret
= user
.info(info
, &err_msg
);
876 ldout(store
->ctx(), 20) << "failed to get user info: " << http_ret
<< dendl
;
879 RGWQuotaInfo
*old_quota
;
881 old_quota
= &info
.user_quota
;
883 old_quota
= &info
.bucket_quota
;
886 int64_t old_max_size_kb
= rgw_rounded_kb(old_quota
->max_size
);
888 RESTArgs::get_int64(s
, "max-objects", old_quota
->max_objects
, "a
.max_objects
);
889 RESTArgs::get_int64(s
, "max-size-kb", old_max_size_kb
, &max_size_kb
);
890 quota
.max_size
= max_size_kb
* 1024;
891 RESTArgs::get_bool(s
, "enabled", old_quota
->enabled
, "a
.enabled
);
895 op_state
.set_user_quota(quota
);
897 op_state
.set_bucket_quota(quota
);
902 http_ret
= user
.modify(op_state
, &err
);
904 ldout(store
->ctx(), 20) << "failed updating user info: " << http_ret
<< ": " << err
<< dendl
;
909 RGWOp
*RGWHandler_User::op_get()
911 if (s
->info
.args
.sub_resource_exists("quota"))
912 return new RGWOp_Quota_Info
;
914 return new RGWOp_User_Info
;
917 RGWOp
*RGWHandler_User::op_put()
919 if (s
->info
.args
.sub_resource_exists("subuser"))
920 return new RGWOp_Subuser_Create
;
922 if (s
->info
.args
.sub_resource_exists("key"))
923 return new RGWOp_Key_Create
;
925 if (s
->info
.args
.sub_resource_exists("caps"))
926 return new RGWOp_Caps_Add
;
928 if (s
->info
.args
.sub_resource_exists("quota"))
929 return new RGWOp_Quota_Set
;
931 return new RGWOp_User_Create
;
934 RGWOp
*RGWHandler_User::op_post()
936 if (s
->info
.args
.sub_resource_exists("subuser"))
937 return new RGWOp_Subuser_Modify
;
939 return new RGWOp_User_Modify
;
942 RGWOp
*RGWHandler_User::op_delete()
944 if (s
->info
.args
.sub_resource_exists("subuser"))
945 return new RGWOp_Subuser_Remove
;
947 if (s
->info
.args
.sub_resource_exists("key"))
948 return new RGWOp_Key_Remove
;
950 if (s
->info
.args
.sub_resource_exists("caps"))
951 return new RGWOp_Caps_Remove
;
953 return new RGWOp_User_Remove
;