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
;
86 int32_t default_max_buckets
= s
->cct
->_conf
->rgw_user_max_buckets
;
88 RGWUserAdminOpState op_state
;
90 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
91 rgw_user
uid(uid_str
);
93 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
94 RESTArgs::get_string(s
, "email", email
, &email
);
95 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
96 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
97 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
98 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
99 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
100 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
101 RESTArgs::get_int32(s
, "max-buckets", default_max_buckets
, &max_buckets
);
102 RESTArgs::get_bool(s
, "system", false, &system
);
103 RESTArgs::get_bool(s
, "exclusive", false, &exclusive
);
105 if (!s
->user
->system
&& system
) {
106 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
111 // TODO: validate required args are passed in. (for eg. uid and display_name here)
112 op_state
.set_user_id(uid
);
113 op_state
.set_display_name(display_name
);
114 op_state
.set_user_email(email
);
115 op_state
.set_caps(caps
);
116 op_state
.set_access_key(access_key
);
117 op_state
.set_secret_key(secret_key
);
119 if (!key_type_str
.empty()) {
120 int32_t key_type
= KEY_TYPE_UNDEFINED
;
121 if (key_type_str
.compare("swift") == 0)
122 key_type
= KEY_TYPE_SWIFT
;
123 else if (key_type_str
.compare("s3") == 0)
124 key_type
= KEY_TYPE_S3
;
126 op_state
.set_key_type(key_type
);
129 if (max_buckets
!= default_max_buckets
)
130 op_state
.set_max_buckets(max_buckets
);
132 if (s
->info
.args
.exists("suspended"))
133 op_state
.set_suspension(suspended
);
135 if (s
->info
.args
.exists("system"))
136 op_state
.set_system(system
);
138 if (s
->info
.args
.exists("exclusive"))
139 op_state
.set_exclusive(exclusive
);
142 op_state
.set_generate_key();
144 RGWQuotaInfo bucket_quota
;
145 RGWQuotaInfo user_quota
;
147 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
>= 0) {
148 bucket_quota
.max_objects
= s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
;
149 bucket_quota
.enabled
= true;
152 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_size
>= 0) {
153 bucket_quota
.max_size
= s
->cct
->_conf
->rgw_bucket_default_quota_max_size
;
154 bucket_quota
.enabled
= true;
157 if (s
->cct
->_conf
->rgw_user_default_quota_max_objects
>= 0) {
158 user_quota
.max_objects
= s
->cct
->_conf
->rgw_user_default_quota_max_objects
;
159 user_quota
.enabled
= true;
162 if (s
->cct
->_conf
->rgw_user_default_quota_max_size
>= 0) {
163 user_quota
.max_size
= s
->cct
->_conf
->rgw_user_default_quota_max_size
;
164 user_quota
.enabled
= true;
167 if (bucket_quota
.enabled
) {
168 op_state
.set_bucket_quota(bucket_quota
);
171 if (user_quota
.enabled
) {
172 op_state
.set_user_quota(user_quota
);
175 http_ret
= RGWUserAdminOp_User::create(store
, op_state
, flusher
);
178 class RGWOp_User_Modify
: public RGWRESTOp
{
181 RGWOp_User_Modify() {}
183 int check_caps(RGWUserCaps
& caps
) override
{
184 return caps
.check_cap("users", RGW_CAP_WRITE
);
187 void execute() override
;
189 const string
name() override
{ return "modify_user"; }
192 void RGWOp_User_Modify::execute()
195 std::string display_name
;
197 std::string access_key
;
198 std::string secret_key
;
199 std::string key_type_str
;
208 RGWUserAdminOpState op_state
;
210 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
211 rgw_user
uid(uid_str
);
213 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
214 RESTArgs::get_string(s
, "email", email
, &email
);
215 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
216 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
217 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
218 RESTArgs::get_bool(s
, "generate-key", false, &gen_key
);
219 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
220 RESTArgs::get_int32(s
, "max-buckets", RGW_DEFAULT_MAX_BUCKETS
, &max_buckets
);
221 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
223 RESTArgs::get_bool(s
, "system", false, &system
);
225 if (!s
->user
->system
&& system
) {
226 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
231 op_state
.set_user_id(uid
);
232 op_state
.set_display_name(display_name
);
233 op_state
.set_user_email(email
);
234 op_state
.set_caps(caps
);
235 op_state
.set_access_key(access_key
);
236 op_state
.set_secret_key(secret_key
);
238 if (max_buckets
!= RGW_DEFAULT_MAX_BUCKETS
)
239 op_state
.set_max_buckets(max_buckets
);
242 op_state
.set_generate_key();
244 if (!key_type_str
.empty()) {
245 int32_t key_type
= KEY_TYPE_UNDEFINED
;
246 if (key_type_str
.compare("swift") == 0)
247 key_type
= KEY_TYPE_SWIFT
;
248 else if (key_type_str
.compare("s3") == 0)
249 key_type
= KEY_TYPE_S3
;
251 op_state
.set_key_type(key_type
);
254 if (s
->info
.args
.exists("suspended"))
255 op_state
.set_suspension(suspended
);
257 if (s
->info
.args
.exists("system"))
258 op_state
.set_system(system
);
260 http_ret
= RGWUserAdminOp_User::modify(store
, op_state
, flusher
);
263 class RGWOp_User_Remove
: public RGWRESTOp
{
266 RGWOp_User_Remove() {}
268 int check_caps(RGWUserCaps
& caps
) override
{
269 return caps
.check_cap("users", RGW_CAP_WRITE
);
272 void execute() override
;
274 const string
name() override
{ return "remove_user"; }
277 void RGWOp_User_Remove::execute()
282 RGWUserAdminOpState op_state
;
284 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
285 rgw_user
uid(uid_str
);
287 RESTArgs::get_bool(s
, "purge-data", false, &purge_data
);
289 // FIXME: no double checking
291 op_state
.set_user_id(uid
);
293 op_state
.set_purge_data(purge_data
);
295 http_ret
= RGWUserAdminOp_User::remove(store
, op_state
, flusher
);
298 class RGWOp_Subuser_Create
: public RGWRESTOp
{
301 RGWOp_Subuser_Create() {}
303 int check_caps(RGWUserCaps
& caps
) override
{
304 return caps
.check_cap("users", RGW_CAP_WRITE
);
307 void execute() override
;
309 const string
name() override
{ return "create_subuser"; }
312 void RGWOp_Subuser_Create::execute()
316 std::string secret_key
;
317 std::string access_key
;
318 std::string perm_str
;
319 std::string key_type_str
;
321 bool gen_subuser
= false; // FIXME placeholder
325 uint32_t perm_mask
= 0;
326 int32_t key_type
= KEY_TYPE_SWIFT
;
328 RGWUserAdminOpState op_state
;
330 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
331 rgw_user
uid(uid_str
);
333 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
334 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
335 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
336 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
337 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
338 //RESTArgs::get_bool(s, "generate-subuser", false, &gen_subuser);
339 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
340 RESTArgs::get_bool(s
, "gen-access-key", false, &gen_access
);
342 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
343 op_state
.set_perm(perm_mask
);
345 op_state
.set_user_id(uid
);
346 op_state
.set_subuser(subuser
);
347 op_state
.set_access_key(access_key
);
348 op_state
.set_secret_key(secret_key
);
349 op_state
.set_generate_subuser(gen_subuser
);
352 op_state
.set_gen_access();
355 op_state
.set_gen_secret();
357 if (!key_type_str
.empty()) {
358 if (key_type_str
.compare("swift") == 0)
359 key_type
= KEY_TYPE_SWIFT
;
360 else if (key_type_str
.compare("s3") == 0)
361 key_type
= KEY_TYPE_S3
;
363 op_state
.set_key_type(key_type
);
365 http_ret
= RGWUserAdminOp_Subuser::create(store
, op_state
, flusher
);
368 class RGWOp_Subuser_Modify
: public RGWRESTOp
{
371 RGWOp_Subuser_Modify() {}
373 int check_caps(RGWUserCaps
& caps
) override
{
374 return caps
.check_cap("users", RGW_CAP_WRITE
);
377 void execute() override
;
379 const string
name() override
{ return "modify_subuser"; }
382 void RGWOp_Subuser_Modify::execute()
386 std::string secret_key
;
387 std::string key_type_str
;
388 std::string perm_str
;
390 RGWUserAdminOpState op_state
;
393 int32_t key_type
= KEY_TYPE_SWIFT
;
397 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
398 rgw_user
uid(uid_str
);
400 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
401 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
402 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
403 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
404 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
406 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
407 op_state
.set_perm(perm_mask
);
409 op_state
.set_user_id(uid
);
410 op_state
.set_subuser(subuser
);
411 op_state
.set_secret_key(secret_key
);
412 op_state
.set_gen_secret();
414 if (!key_type_str
.empty()) {
415 if (key_type_str
.compare("swift") == 0)
416 key_type
= KEY_TYPE_SWIFT
;
417 else if (key_type_str
.compare("s3") == 0)
418 key_type
= KEY_TYPE_S3
;
420 op_state
.set_key_type(key_type
);
422 http_ret
= RGWUserAdminOp_Subuser::modify(store
, op_state
, flusher
);
425 class RGWOp_Subuser_Remove
: public RGWRESTOp
{
428 RGWOp_Subuser_Remove() {}
430 int check_caps(RGWUserCaps
& caps
) override
{
431 return caps
.check_cap("users", RGW_CAP_WRITE
);
434 void execute() override
;
436 const string
name() override
{ return "remove_subuser"; }
439 void RGWOp_Subuser_Remove::execute()
445 RGWUserAdminOpState op_state
;
447 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
448 rgw_user
uid(uid_str
);
450 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
451 RESTArgs::get_bool(s
, "purge-keys", true, &purge_keys
);
453 op_state
.set_user_id(uid
);
454 op_state
.set_subuser(subuser
);
457 op_state
.set_purge_keys();
459 http_ret
= RGWUserAdminOp_Subuser::remove(store
, op_state
, flusher
);
462 class RGWOp_Key_Create
: public RGWRESTOp
{
465 RGWOp_Key_Create() {}
467 int check_caps(RGWUserCaps
& caps
) override
{
468 return caps
.check_cap("users", RGW_CAP_WRITE
);
471 void execute() override
;
473 const string
name() override
{ return "create_access_key"; }
476 void RGWOp_Key_Create::execute()
480 std::string access_key
;
481 std::string secret_key
;
482 std::string key_type_str
;
486 RGWUserAdminOpState op_state
;
488 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
489 rgw_user
uid(uid_str
);
491 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
492 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
493 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
494 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
495 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
497 op_state
.set_user_id(uid
);
498 op_state
.set_subuser(subuser
);
499 op_state
.set_access_key(access_key
);
500 op_state
.set_secret_key(secret_key
);
503 op_state
.set_generate_key();
505 if (!key_type_str
.empty()) {
506 int32_t key_type
= KEY_TYPE_UNDEFINED
;
507 if (key_type_str
.compare("swift") == 0)
508 key_type
= KEY_TYPE_SWIFT
;
509 else if (key_type_str
.compare("s3") == 0)
510 key_type
= KEY_TYPE_S3
;
512 op_state
.set_key_type(key_type
);
515 http_ret
= RGWUserAdminOp_Key::create(store
, op_state
, flusher
);
518 class RGWOp_Key_Remove
: public RGWRESTOp
{
521 RGWOp_Key_Remove() {}
523 int check_caps(RGWUserCaps
& caps
) override
{
524 return caps
.check_cap("users", RGW_CAP_WRITE
);
527 void execute() override
;
529 const string
name() override
{ return "remove_access_key"; }
532 void RGWOp_Key_Remove::execute()
536 std::string access_key
;
537 std::string key_type_str
;
539 RGWUserAdminOpState op_state
;
541 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
542 rgw_user
uid(uid_str
);
544 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
545 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
546 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
548 op_state
.set_user_id(uid
);
549 op_state
.set_subuser(subuser
);
550 op_state
.set_access_key(access_key
);
552 if (!key_type_str
.empty()) {
553 int32_t key_type
= KEY_TYPE_UNDEFINED
;
554 if (key_type_str
.compare("swift") == 0)
555 key_type
= KEY_TYPE_SWIFT
;
556 else if (key_type_str
.compare("s3") == 0)
557 key_type
= KEY_TYPE_S3
;
559 op_state
.set_key_type(key_type
);
562 http_ret
= RGWUserAdminOp_Key::remove(store
, op_state
, flusher
);
565 class RGWOp_Caps_Add
: public RGWRESTOp
{
570 int check_caps(RGWUserCaps
& caps
) override
{
571 return caps
.check_cap("users", RGW_CAP_WRITE
);
574 void execute() override
;
576 const string
name() override
{ return "add_user_caps"; }
579 void RGWOp_Caps_Add::execute()
584 RGWUserAdminOpState op_state
;
586 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
587 rgw_user
uid(uid_str
);
589 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
591 op_state
.set_user_id(uid
);
592 op_state
.set_caps(caps
);
594 http_ret
= RGWUserAdminOp_Caps::add(store
, op_state
, flusher
);
597 class RGWOp_Caps_Remove
: public RGWRESTOp
{
600 RGWOp_Caps_Remove() {}
602 int check_caps(RGWUserCaps
& caps
) override
{
603 return caps
.check_cap("users", RGW_CAP_WRITE
);
606 void execute() override
;
608 const string
name() override
{ return "remove_user_caps"; }
611 void RGWOp_Caps_Remove::execute()
616 RGWUserAdminOpState op_state
;
618 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
619 rgw_user
uid(uid_str
);
621 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
623 op_state
.set_user_id(uid
);
624 op_state
.set_caps(caps
);
626 http_ret
= RGWUserAdminOp_Caps::remove(store
, op_state
, flusher
);
630 RGWQuotaInfo bucket_quota
;
631 RGWQuotaInfo user_quota
;
635 explicit UserQuotas(RGWUserInfo
& info
) : bucket_quota(info
.bucket_quota
),
636 user_quota(info
.user_quota
) {}
638 void dump(Formatter
*f
) const {
639 encode_json("bucket_quota", bucket_quota
, f
);
640 encode_json("user_quota", user_quota
, f
);
642 void decode_json(JSONObj
*obj
) {
643 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
644 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
648 class RGWOp_Quota_Info
: public RGWRESTOp
{
651 RGWOp_Quota_Info() {}
653 int check_caps(RGWUserCaps
& caps
) override
{
654 return caps
.check_cap("users", RGW_CAP_READ
);
657 void execute() override
;
659 const string
name() override
{ return "get_quota_info"; }
663 void RGWOp_Quota_Info::execute()
665 RGWUserAdminOpState op_state
;
668 std::string quota_type
;
670 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
671 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
673 if (uid_str
.empty()) {
678 rgw_user
uid(uid_str
);
680 bool show_all
= quota_type
.empty();
681 bool show_bucket
= show_all
|| (quota_type
== "bucket");
682 bool show_user
= show_all
|| (quota_type
== "user");
684 if (!(show_all
|| show_bucket
|| show_user
)) {
689 op_state
.set_user_id(uid
);
692 http_ret
= user
.init(store
, op_state
);
698 http_ret
= user
.info(info
, &err_msg
);
704 UserQuotas
quotas(info
);
705 encode_json("quota", quotas
, s
->formatter
);
706 } else if (show_user
) {
707 encode_json("user_quota", info
.user_quota
, s
->formatter
);
709 encode_json("bucket_quota", info
.bucket_quota
, s
->formatter
);
715 class RGWOp_Quota_Set
: public RGWRESTOp
{
720 int check_caps(RGWUserCaps
& caps
) override
{
721 return caps
.check_cap("users", RGW_CAP_WRITE
);
724 void execute() override
;
726 const string
name() override
{ return "set_quota_info"; }
732 * two different ways to set the quota info: as json struct in the message body or via http params.
736 * PUT /admin/user?uid=<uid>["a-type=<type>]
738 * whereas quota-type is optional and is either user, or bucket
740 * if quota-type is not specified then we expect to get a structure that contains both quotas,
741 * otherwise we'll only get the relevant configuration.
743 * E.g., if quota type not specified:
746 * "max_size_kb" : 4096,
747 * "max_objects" : -1,
751 * "max_size_kb" : 1024,
752 * "max_objects" : -1,
758 * or if quota type is specified:
760 * "max_size_kb" : 4096,
761 * "max_objects" : -1,
765 * Another option is not to pass any body and set the following http params:
769 * max-objects=<max objects>
770 * enabled[={true,false}]
772 * all params are optionals and default to the current settings. With this type of configuration the
773 * quota-type param is mandatory.
777 void RGWOp_Quota_Set::execute()
779 RGWUserAdminOpState op_state
;
782 std::string quota_type
;
784 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
785 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
787 if (uid_str
.empty()) {
792 rgw_user
uid(uid_str
);
794 bool set_all
= quota_type
.empty();
795 bool set_bucket
= set_all
|| (quota_type
== "bucket");
796 bool set_user
= set_all
|| (quota_type
== "user");
798 if (!(set_all
|| set_bucket
|| set_user
)) {
799 ldout(store
->ctx(), 20) << "invalid quota type" << dendl
;
804 bool use_http_params
;
806 if (s
->content_length
> 0) {
807 use_http_params
= false;
809 const char *encoding
= s
->info
.env
->get("HTTP_TRANSFER_ENCODING");
810 use_http_params
= (!encoding
|| strcmp(encoding
, "chunked") != 0);
813 if (use_http_params
&& set_all
) {
814 ldout(store
->ctx(), 20) << "quota type was not specified, can't set all quotas via http headers" << dendl
;
819 op_state
.set_user_id(uid
);
822 http_ret
= user
.init(store
, op_state
);
824 ldout(store
->ctx(), 20) << "failed initializing user info: " << http_ret
<< dendl
;
828 #define QUOTA_INPUT_MAX_LEN 1024
832 if ((http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quotas
, QUOTA_INPUT_MAX_LEN
, NULL
)) < 0) {
833 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
837 op_state
.set_user_quota(quotas
.user_quota
);
838 op_state
.set_bucket_quota(quotas
.bucket_quota
);
842 if (!use_http_params
) {
844 http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quota
, QUOTA_INPUT_MAX_LEN
, &empty
);
846 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
850 /* was probably chunked input, but no content provided, configure via http params */
851 use_http_params
= true;
855 if (use_http_params
) {
858 http_ret
= user
.info(info
, &err_msg
);
860 ldout(store
->ctx(), 20) << "failed to get user info: " << http_ret
<< dendl
;
863 RGWQuotaInfo
*old_quota
;
865 old_quota
= &info
.user_quota
;
867 old_quota
= &info
.bucket_quota
;
870 int64_t old_max_size_kb
= rgw_rounded_kb(old_quota
->max_size
);
872 RESTArgs::get_int64(s
, "max-objects", old_quota
->max_objects
, "a
.max_objects
);
873 RESTArgs::get_int64(s
, "max-size-kb", old_max_size_kb
, &max_size_kb
);
874 quota
.max_size
= max_size_kb
* 1024;
875 RESTArgs::get_bool(s
, "enabled", old_quota
->enabled
, "a
.enabled
);
879 op_state
.set_user_quota(quota
);
881 op_state
.set_bucket_quota(quota
);
886 http_ret
= user
.modify(op_state
, &err
);
888 ldout(store
->ctx(), 20) << "failed updating user info: " << http_ret
<< ": " << err
<< dendl
;
893 RGWOp
*RGWHandler_User::op_get()
895 if (s
->info
.args
.sub_resource_exists("quota"))
896 return new RGWOp_Quota_Info
;
898 return new RGWOp_User_Info
;
901 RGWOp
*RGWHandler_User::op_put()
903 if (s
->info
.args
.sub_resource_exists("subuser"))
904 return new RGWOp_Subuser_Create
;
906 if (s
->info
.args
.sub_resource_exists("key"))
907 return new RGWOp_Key_Create
;
909 if (s
->info
.args
.sub_resource_exists("caps"))
910 return new RGWOp_Caps_Add
;
912 if (s
->info
.args
.sub_resource_exists("quota"))
913 return new RGWOp_Quota_Set
;
915 return new RGWOp_User_Create
;
918 RGWOp
*RGWHandler_User::op_post()
920 if (s
->info
.args
.sub_resource_exists("subuser"))
921 return new RGWOp_Subuser_Modify
;
923 return new RGWOp_User_Modify
;
926 RGWOp
*RGWHandler_User::op_delete()
928 if (s
->info
.args
.sub_resource_exists("subuser"))
929 return new RGWOp_Subuser_Remove
;
931 if (s
->info
.args
.sub_resource_exists("key"))
932 return new RGWOp_Key_Remove
;
934 if (s
->info
.args
.sub_resource_exists("caps"))
935 return new RGWOp_Caps_Remove
;
937 return new RGWOp_User_Remove
;