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
;
37 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
39 // if uid was not supplied in rest argument, error out now, otherwise we'll
40 // end up initializing anonymous user, for which keys.init will eventually
47 rgw_user
uid(uid_str
);
49 RESTArgs::get_bool(s
, "stats", false, &fetch_stats
);
51 RESTArgs::get_bool(s
, "sync", false, &sync_stats
);
53 op_state
.set_user_id(uid
);
54 op_state
.set_fetch_stats(fetch_stats
);
55 op_state
.set_sync_stats(sync_stats
);
57 http_ret
= RGWUserAdminOp_User::info(store
, op_state
, flusher
);
60 class RGWOp_User_Create
: public RGWRESTOp
{
63 RGWOp_User_Create() {}
65 int check_caps(RGWUserCaps
& caps
) override
{
66 return caps
.check_cap("users", RGW_CAP_WRITE
);
69 void execute() override
;
71 const string
name() override
{ return "create_user"; }
74 void RGWOp_User_Create::execute()
77 std::string display_name
;
79 std::string access_key
;
80 std::string secret_key
;
81 std::string key_type_str
;
83 std::string tenant_name
;
91 int32_t default_max_buckets
= s
->cct
->_conf
->rgw_user_max_buckets
;
93 RGWUserAdminOpState op_state
;
95 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
96 rgw_user
uid(uid_str
);
98 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
99 RESTArgs::get_string(s
, "email", email
, &email
);
100 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
101 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
102 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
103 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
104 RESTArgs::get_string(s
, "tenant", tenant_name
, &tenant_name
);
105 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
106 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
107 RESTArgs::get_int32(s
, "max-buckets", default_max_buckets
, &max_buckets
);
108 RESTArgs::get_bool(s
, "system", false, &system
);
109 RESTArgs::get_bool(s
, "exclusive", false, &exclusive
);
111 if (!s
->user
->system
&& system
) {
112 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
117 if (!tenant_name
.empty()) {
118 uid
.tenant
= tenant_name
;
121 // TODO: validate required args are passed in. (for eg. uid and display_name here)
122 op_state
.set_user_id(uid
);
123 op_state
.set_display_name(display_name
);
124 op_state
.set_user_email(email
);
125 op_state
.set_caps(caps
);
126 op_state
.set_access_key(access_key
);
127 op_state
.set_secret_key(secret_key
);
129 if (!key_type_str
.empty()) {
130 int32_t key_type
= KEY_TYPE_UNDEFINED
;
131 if (key_type_str
.compare("swift") == 0)
132 key_type
= KEY_TYPE_SWIFT
;
133 else if (key_type_str
.compare("s3") == 0)
134 key_type
= KEY_TYPE_S3
;
136 op_state
.set_key_type(key_type
);
139 if (max_buckets
!= default_max_buckets
)
140 op_state
.set_max_buckets(max_buckets
);
142 if (s
->info
.args
.exists("suspended"))
143 op_state
.set_suspension(suspended
);
145 if (s
->info
.args
.exists("system"))
146 op_state
.set_system(system
);
148 if (s
->info
.args
.exists("exclusive"))
149 op_state
.set_exclusive(exclusive
);
152 op_state
.set_generate_key();
154 RGWQuotaInfo bucket_quota
;
155 RGWQuotaInfo user_quota
;
157 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
>= 0) {
158 bucket_quota
.max_objects
= s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
;
159 bucket_quota
.enabled
= true;
162 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_size
>= 0) {
163 bucket_quota
.max_size
= s
->cct
->_conf
->rgw_bucket_default_quota_max_size
;
164 bucket_quota
.enabled
= true;
167 if (s
->cct
->_conf
->rgw_user_default_quota_max_objects
>= 0) {
168 user_quota
.max_objects
= s
->cct
->_conf
->rgw_user_default_quota_max_objects
;
169 user_quota
.enabled
= true;
172 if (s
->cct
->_conf
->rgw_user_default_quota_max_size
>= 0) {
173 user_quota
.max_size
= s
->cct
->_conf
->rgw_user_default_quota_max_size
;
174 user_quota
.enabled
= true;
177 if (bucket_quota
.enabled
) {
178 op_state
.set_bucket_quota(bucket_quota
);
181 if (user_quota
.enabled
) {
182 op_state
.set_user_quota(user_quota
);
185 http_ret
= RGWUserAdminOp_User::create(store
, op_state
, flusher
);
188 class RGWOp_User_Modify
: public RGWRESTOp
{
191 RGWOp_User_Modify() {}
193 int check_caps(RGWUserCaps
& caps
) override
{
194 return caps
.check_cap("users", RGW_CAP_WRITE
);
197 void execute() override
;
199 const string
name() override
{ return "modify_user"; }
202 void RGWOp_User_Modify::execute()
205 std::string display_name
;
207 std::string access_key
;
208 std::string secret_key
;
209 std::string key_type_str
;
219 RGWUserAdminOpState op_state
;
221 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
222 rgw_user
uid(uid_str
);
224 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
225 RESTArgs::get_string(s
, "email", email
, &email
, &email_set
);
226 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
227 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
228 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
229 RESTArgs::get_bool(s
, "generate-key", false, &gen_key
);
230 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
231 RESTArgs::get_int32(s
, "max-buckets", RGW_DEFAULT_MAX_BUCKETS
, &max_buckets
, "a_set
);
232 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
234 RESTArgs::get_bool(s
, "system", false, &system
);
236 if (!s
->user
->system
&& system
) {
237 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
242 op_state
.set_user_id(uid
);
243 op_state
.set_display_name(display_name
);
246 op_state
.set_user_email(email
);
248 op_state
.set_caps(caps
);
249 op_state
.set_access_key(access_key
);
250 op_state
.set_secret_key(secret_key
);
253 op_state
.set_max_buckets(max_buckets
);
256 op_state
.set_generate_key();
258 if (!key_type_str
.empty()) {
259 int32_t key_type
= KEY_TYPE_UNDEFINED
;
260 if (key_type_str
.compare("swift") == 0)
261 key_type
= KEY_TYPE_SWIFT
;
262 else if (key_type_str
.compare("s3") == 0)
263 key_type
= KEY_TYPE_S3
;
265 op_state
.set_key_type(key_type
);
268 if (s
->info
.args
.exists("suspended"))
269 op_state
.set_suspension(suspended
);
271 if (s
->info
.args
.exists("system"))
272 op_state
.set_system(system
);
274 http_ret
= RGWUserAdminOp_User::modify(store
, op_state
, flusher
);
277 class RGWOp_User_Remove
: public RGWRESTOp
{
280 RGWOp_User_Remove() {}
282 int check_caps(RGWUserCaps
& caps
) override
{
283 return caps
.check_cap("users", RGW_CAP_WRITE
);
286 void execute() override
;
288 const string
name() override
{ return "remove_user"; }
291 void RGWOp_User_Remove::execute()
296 RGWUserAdminOpState op_state
;
298 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
299 rgw_user
uid(uid_str
);
301 RESTArgs::get_bool(s
, "purge-data", false, &purge_data
);
303 // FIXME: no double checking
305 op_state
.set_user_id(uid
);
307 op_state
.set_purge_data(purge_data
);
309 http_ret
= RGWUserAdminOp_User::remove(store
, op_state
, flusher
);
312 class RGWOp_Subuser_Create
: public RGWRESTOp
{
315 RGWOp_Subuser_Create() {}
317 int check_caps(RGWUserCaps
& caps
) override
{
318 return caps
.check_cap("users", RGW_CAP_WRITE
);
321 void execute() override
;
323 const string
name() override
{ return "create_subuser"; }
326 void RGWOp_Subuser_Create::execute()
330 std::string secret_key
;
331 std::string access_key
;
332 std::string perm_str
;
333 std::string key_type_str
;
335 bool gen_subuser
= false; // FIXME placeholder
339 uint32_t perm_mask
= 0;
340 int32_t key_type
= KEY_TYPE_SWIFT
;
342 RGWUserAdminOpState op_state
;
344 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
345 rgw_user
uid(uid_str
);
347 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
348 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
349 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
350 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
351 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
352 //RESTArgs::get_bool(s, "generate-subuser", false, &gen_subuser);
353 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
354 RESTArgs::get_bool(s
, "gen-access-key", false, &gen_access
);
356 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
357 op_state
.set_perm(perm_mask
);
359 op_state
.set_user_id(uid
);
360 op_state
.set_subuser(subuser
);
361 op_state
.set_access_key(access_key
);
362 op_state
.set_secret_key(secret_key
);
363 op_state
.set_generate_subuser(gen_subuser
);
366 op_state
.set_gen_access();
369 op_state
.set_gen_secret();
371 if (!key_type_str
.empty()) {
372 if (key_type_str
.compare("swift") == 0)
373 key_type
= KEY_TYPE_SWIFT
;
374 else if (key_type_str
.compare("s3") == 0)
375 key_type
= KEY_TYPE_S3
;
377 op_state
.set_key_type(key_type
);
379 http_ret
= RGWUserAdminOp_Subuser::create(store
, op_state
, flusher
);
382 class RGWOp_Subuser_Modify
: public RGWRESTOp
{
385 RGWOp_Subuser_Modify() {}
387 int check_caps(RGWUserCaps
& caps
) override
{
388 return caps
.check_cap("users", RGW_CAP_WRITE
);
391 void execute() override
;
393 const string
name() override
{ return "modify_subuser"; }
396 void RGWOp_Subuser_Modify::execute()
400 std::string secret_key
;
401 std::string key_type_str
;
402 std::string perm_str
;
404 RGWUserAdminOpState op_state
;
407 int32_t key_type
= KEY_TYPE_SWIFT
;
411 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
412 rgw_user
uid(uid_str
);
414 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
415 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
416 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
417 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
418 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
420 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
421 op_state
.set_perm(perm_mask
);
423 op_state
.set_user_id(uid
);
424 op_state
.set_subuser(subuser
);
426 if (!secret_key
.empty())
427 op_state
.set_secret_key(secret_key
);
430 op_state
.set_gen_secret();
432 if (!key_type_str
.empty()) {
433 if (key_type_str
.compare("swift") == 0)
434 key_type
= KEY_TYPE_SWIFT
;
435 else if (key_type_str
.compare("s3") == 0)
436 key_type
= KEY_TYPE_S3
;
438 op_state
.set_key_type(key_type
);
440 http_ret
= RGWUserAdminOp_Subuser::modify(store
, op_state
, flusher
);
443 class RGWOp_Subuser_Remove
: public RGWRESTOp
{
446 RGWOp_Subuser_Remove() {}
448 int check_caps(RGWUserCaps
& caps
) override
{
449 return caps
.check_cap("users", RGW_CAP_WRITE
);
452 void execute() override
;
454 const string
name() override
{ return "remove_subuser"; }
457 void RGWOp_Subuser_Remove::execute()
463 RGWUserAdminOpState op_state
;
465 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
466 rgw_user
uid(uid_str
);
468 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
469 RESTArgs::get_bool(s
, "purge-keys", true, &purge_keys
);
471 op_state
.set_user_id(uid
);
472 op_state
.set_subuser(subuser
);
475 op_state
.set_purge_keys();
477 http_ret
= RGWUserAdminOp_Subuser::remove(store
, op_state
, flusher
);
480 class RGWOp_Key_Create
: public RGWRESTOp
{
483 RGWOp_Key_Create() {}
485 int check_caps(RGWUserCaps
& caps
) override
{
486 return caps
.check_cap("users", RGW_CAP_WRITE
);
489 void execute() override
;
491 const string
name() override
{ return "create_access_key"; }
494 void RGWOp_Key_Create::execute()
498 std::string access_key
;
499 std::string secret_key
;
500 std::string key_type_str
;
504 RGWUserAdminOpState op_state
;
506 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
507 rgw_user
uid(uid_str
);
509 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
510 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
511 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
512 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
513 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
515 op_state
.set_user_id(uid
);
516 op_state
.set_subuser(subuser
);
517 op_state
.set_access_key(access_key
);
518 op_state
.set_secret_key(secret_key
);
521 op_state
.set_generate_key();
523 if (!key_type_str
.empty()) {
524 int32_t key_type
= KEY_TYPE_UNDEFINED
;
525 if (key_type_str
.compare("swift") == 0)
526 key_type
= KEY_TYPE_SWIFT
;
527 else if (key_type_str
.compare("s3") == 0)
528 key_type
= KEY_TYPE_S3
;
530 op_state
.set_key_type(key_type
);
533 http_ret
= RGWUserAdminOp_Key::create(store
, op_state
, flusher
);
536 class RGWOp_Key_Remove
: public RGWRESTOp
{
539 RGWOp_Key_Remove() {}
541 int check_caps(RGWUserCaps
& caps
) override
{
542 return caps
.check_cap("users", RGW_CAP_WRITE
);
545 void execute() override
;
547 const string
name() override
{ return "remove_access_key"; }
550 void RGWOp_Key_Remove::execute()
554 std::string access_key
;
555 std::string key_type_str
;
557 RGWUserAdminOpState op_state
;
559 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
560 rgw_user
uid(uid_str
);
562 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
563 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
564 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
566 op_state
.set_user_id(uid
);
567 op_state
.set_subuser(subuser
);
568 op_state
.set_access_key(access_key
);
570 if (!key_type_str
.empty()) {
571 int32_t key_type
= KEY_TYPE_UNDEFINED
;
572 if (key_type_str
.compare("swift") == 0)
573 key_type
= KEY_TYPE_SWIFT
;
574 else if (key_type_str
.compare("s3") == 0)
575 key_type
= KEY_TYPE_S3
;
577 op_state
.set_key_type(key_type
);
580 http_ret
= RGWUserAdminOp_Key::remove(store
, op_state
, flusher
);
583 class RGWOp_Caps_Add
: public RGWRESTOp
{
588 int check_caps(RGWUserCaps
& caps
) override
{
589 return caps
.check_cap("users", RGW_CAP_WRITE
);
592 void execute() override
;
594 const string
name() override
{ return "add_user_caps"; }
597 void RGWOp_Caps_Add::execute()
602 RGWUserAdminOpState op_state
;
604 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
605 rgw_user
uid(uid_str
);
607 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
609 op_state
.set_user_id(uid
);
610 op_state
.set_caps(caps
);
612 http_ret
= RGWUserAdminOp_Caps::add(store
, op_state
, flusher
);
615 class RGWOp_Caps_Remove
: public RGWRESTOp
{
618 RGWOp_Caps_Remove() {}
620 int check_caps(RGWUserCaps
& caps
) override
{
621 return caps
.check_cap("users", RGW_CAP_WRITE
);
624 void execute() override
;
626 const string
name() override
{ return "remove_user_caps"; }
629 void RGWOp_Caps_Remove::execute()
634 RGWUserAdminOpState op_state
;
636 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
637 rgw_user
uid(uid_str
);
639 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
641 op_state
.set_user_id(uid
);
642 op_state
.set_caps(caps
);
644 http_ret
= RGWUserAdminOp_Caps::remove(store
, op_state
, flusher
);
648 RGWQuotaInfo bucket_quota
;
649 RGWQuotaInfo user_quota
;
653 explicit UserQuotas(RGWUserInfo
& info
) : bucket_quota(info
.bucket_quota
),
654 user_quota(info
.user_quota
) {}
656 void dump(Formatter
*f
) const {
657 encode_json("bucket_quota", bucket_quota
, f
);
658 encode_json("user_quota", user_quota
, f
);
660 void decode_json(JSONObj
*obj
) {
661 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
662 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
666 class RGWOp_Quota_Info
: public RGWRESTOp
{
669 RGWOp_Quota_Info() {}
671 int check_caps(RGWUserCaps
& caps
) override
{
672 return caps
.check_cap("users", RGW_CAP_READ
);
675 void execute() override
;
677 const string
name() override
{ return "get_quota_info"; }
681 void RGWOp_Quota_Info::execute()
683 RGWUserAdminOpState op_state
;
686 std::string quota_type
;
688 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
689 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
691 if (uid_str
.empty()) {
696 rgw_user
uid(uid_str
);
698 bool show_all
= quota_type
.empty();
699 bool show_bucket
= show_all
|| (quota_type
== "bucket");
700 bool show_user
= show_all
|| (quota_type
== "user");
702 if (!(show_all
|| show_bucket
|| show_user
)) {
707 op_state
.set_user_id(uid
);
710 http_ret
= user
.init(store
, op_state
);
714 if (!op_state
.has_existing_user()) {
715 http_ret
= -ERR_NO_SUCH_USER
;
721 http_ret
= user
.info(info
, &err_msg
);
727 UserQuotas
quotas(info
);
728 encode_json("quota", quotas
, s
->formatter
);
729 } else if (show_user
) {
730 encode_json("user_quota", info
.user_quota
, s
->formatter
);
732 encode_json("bucket_quota", info
.bucket_quota
, s
->formatter
);
738 class RGWOp_Quota_Set
: public RGWRESTOp
{
743 int check_caps(RGWUserCaps
& caps
) override
{
744 return caps
.check_cap("users", RGW_CAP_WRITE
);
747 void execute() override
;
749 const string
name() override
{ return "set_quota_info"; }
755 * two different ways to set the quota info: as json struct in the message body or via http params.
759 * PUT /admin/user?uid=<uid>["a-type=<type>]
761 * whereas quota-type is optional and is either user, or bucket
763 * if quota-type is not specified then we expect to get a structure that contains both quotas,
764 * otherwise we'll only get the relevant configuration.
766 * E.g., if quota type not specified:
769 * "max_size_kb" : 4096,
770 * "max_objects" : -1,
774 * "max_size_kb" : 1024,
775 * "max_objects" : -1,
781 * or if quota type is specified:
783 * "max_size_kb" : 4096,
784 * "max_objects" : -1,
788 * Another option is not to pass any body and set the following http params:
792 * max-objects=<max objects>
793 * enabled[={true,false}]
795 * all params are optionals and default to the current settings. With this type of configuration the
796 * quota-type param is mandatory.
800 void RGWOp_Quota_Set::execute()
802 RGWUserAdminOpState op_state
;
805 std::string quota_type
;
807 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
808 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
810 if (uid_str
.empty()) {
815 rgw_user
uid(uid_str
);
817 bool set_all
= quota_type
.empty();
818 bool set_bucket
= set_all
|| (quota_type
== "bucket");
819 bool set_user
= set_all
|| (quota_type
== "user");
821 if (!(set_all
|| set_bucket
|| set_user
)) {
822 ldout(store
->ctx(), 20) << "invalid quota type" << dendl
;
827 bool use_http_params
;
829 if (s
->content_length
> 0) {
830 use_http_params
= false;
832 const char *encoding
= s
->info
.env
->get("HTTP_TRANSFER_ENCODING");
833 use_http_params
= (!encoding
|| strcmp(encoding
, "chunked") != 0);
836 if (use_http_params
&& set_all
) {
837 ldout(store
->ctx(), 20) << "quota type was not specified, can't set all quotas via http headers" << dendl
;
842 op_state
.set_user_id(uid
);
845 http_ret
= user
.init(store
, op_state
);
847 ldout(store
->ctx(), 20) << "failed initializing user info: " << http_ret
<< dendl
;
851 if (!op_state
.has_existing_user()) {
852 http_ret
= -ERR_NO_SUCH_USER
;
856 #define QUOTA_INPUT_MAX_LEN 1024
860 if ((http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quotas
, QUOTA_INPUT_MAX_LEN
, NULL
)) < 0) {
861 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
865 op_state
.set_user_quota(quotas
.user_quota
);
866 op_state
.set_bucket_quota(quotas
.bucket_quota
);
870 if (!use_http_params
) {
872 http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quota
, QUOTA_INPUT_MAX_LEN
, &empty
);
874 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
878 /* was probably chunked input, but no content provided, configure via http params */
879 use_http_params
= true;
883 if (use_http_params
) {
886 http_ret
= user
.info(info
, &err_msg
);
888 ldout(store
->ctx(), 20) << "failed to get user info: " << http_ret
<< dendl
;
891 RGWQuotaInfo
*old_quota
;
893 old_quota
= &info
.user_quota
;
895 old_quota
= &info
.bucket_quota
;
898 int64_t old_max_size_kb
= rgw_rounded_kb(old_quota
->max_size
);
900 RESTArgs::get_int64(s
, "max-objects", old_quota
->max_objects
, "a
.max_objects
);
901 RESTArgs::get_int64(s
, "max-size-kb", old_max_size_kb
, &max_size_kb
);
902 quota
.max_size
= max_size_kb
* 1024;
903 RESTArgs::get_bool(s
, "enabled", old_quota
->enabled
, "a
.enabled
);
907 op_state
.set_user_quota(quota
);
909 op_state
.set_bucket_quota(quota
);
914 http_ret
= user
.modify(op_state
, &err
);
916 ldout(store
->ctx(), 20) << "failed updating user info: " << http_ret
<< ": " << err
<< dendl
;
921 RGWOp
*RGWHandler_User::op_get()
923 if (s
->info
.args
.sub_resource_exists("quota"))
924 return new RGWOp_Quota_Info
;
926 return new RGWOp_User_Info
;
929 RGWOp
*RGWHandler_User::op_put()
931 if (s
->info
.args
.sub_resource_exists("subuser"))
932 return new RGWOp_Subuser_Create
;
934 if (s
->info
.args
.sub_resource_exists("key"))
935 return new RGWOp_Key_Create
;
937 if (s
->info
.args
.sub_resource_exists("caps"))
938 return new RGWOp_Caps_Add
;
940 if (s
->info
.args
.sub_resource_exists("quota"))
941 return new RGWOp_Quota_Set
;
943 return new RGWOp_User_Create
;
946 RGWOp
*RGWHandler_User::op_post()
948 if (s
->info
.args
.sub_resource_exists("subuser"))
949 return new RGWOp_Subuser_Modify
;
951 return new RGWOp_User_Modify
;
954 RGWOp
*RGWHandler_User::op_delete()
956 if (s
->info
.args
.sub_resource_exists("subuser"))
957 return new RGWOp_Subuser_Remove
;
959 if (s
->info
.args
.sub_resource_exists("key"))
960 return new RGWOp_Key_Remove
;
962 if (s
->info
.args
.sub_resource_exists("caps"))
963 return new RGWOp_Caps_Remove
;
965 return new RGWOp_User_Remove
;