clouduser.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package cloudid
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient/options"
  18. )
  19. type ClouduserListOptions struct {
  20. options.BaseListOptions
  21. CloudaccountId string `help:"Cloudaccount Id"`
  22. CloudproviderId string `help:"Cloudprovider Id"`
  23. CloudpolicyId string `help:"filter cloudusers by cloudpolicy"`
  24. CloudgroupId string `help:"filter cloudusers by cloudgroup"`
  25. }
  26. func (opts *ClouduserListOptions) Params() (jsonutils.JSONObject, error) {
  27. return options.ListStructToParams(opts)
  28. }
  29. type ClouduserCreateOptions struct {
  30. NAME string `help:"Clouduser name"`
  31. MANAGER_ID string `help:"Cloudprovider Id"`
  32. OwnerId string `help:"Owner Id"`
  33. CloudpolicyIds []string `help:"cloudpolicy ids"`
  34. CloudgroupIds []string `help:"cloudgroup ids"`
  35. Email string `help:"email address"`
  36. MobilePhone string `help:"phone number"`
  37. IsConsoleLogin *bool `help:"is console login"`
  38. Password string `help:"clouduser password"`
  39. Notify *bool `help:"Notify user which set email when clouduser created"`
  40. }
  41. func (opts *ClouduserCreateOptions) Params() (jsonutils.JSONObject, error) {
  42. return jsonutils.Marshal(opts), nil
  43. }
  44. type ClouduserIdOption struct {
  45. ID string `help:"Clouduser Id or name"`
  46. }
  47. func (opts *ClouduserIdOption) GetId() string {
  48. return opts.ID
  49. }
  50. func (opts *ClouduserIdOption) Params() (jsonutils.JSONObject, error) {
  51. return nil, nil
  52. }
  53. type ClouduserSyncOptions struct {
  54. ClouduserIdOption
  55. PolicyOnly bool `help:"Ony sync clouduser policies for cloud"`
  56. }
  57. func (opts *ClouduserSyncOptions) Params() (jsonutils.JSONObject, error) {
  58. return jsonutils.Marshal(map[string]bool{"policy_only": opts.PolicyOnly}), nil
  59. }
  60. type ClouduserPolicyOptions struct {
  61. ClouduserIdOption
  62. CLOUDPOLICY_ID string `help:"cloudpolicy Id"`
  63. }
  64. func (opts *ClouduserPolicyOptions) Params() (jsonutils.JSONObject, error) {
  65. return jsonutils.Marshal(map[string]string{
  66. "cloudpolicy_id": opts.CLOUDPOLICY_ID,
  67. }), nil
  68. }
  69. type ClouduserPasswordOptions struct {
  70. ClouduserIdOption
  71. Password string `help:"clouduser password"`
  72. }
  73. func (opts *ClouduserPasswordOptions) Params() (jsonutils.JSONObject, error) {
  74. return jsonutils.Marshal(map[string]string{"password": opts.Password}), nil
  75. }
  76. type ClouduserChangeOwnerOptions struct {
  77. ClouduserIdOption
  78. UserId string `help:"local user id"`
  79. }
  80. func (opts *ClouduserChangeOwnerOptions) Params() (jsonutils.JSONObject, error) {
  81. return jsonutils.Marshal(map[string]string{"user_id": opts.UserId}), nil
  82. }
  83. type ClouduserGroupOptions struct {
  84. ClouduserIdOption
  85. CLOUDGROUP_ID string `help:"cloudgroup id" json:"cloudgroup_id"`
  86. }
  87. func (opts *ClouduserGroupOptions) Params() (jsonutils.JSONObject, error) {
  88. return jsonutils.Marshal(map[string]string{"cloudgroup_id": opts.CLOUDGROUP_ID}), nil
  89. }
  90. type ClouduserResetPasswordOptions struct {
  91. ClouduserIdOption
  92. Password string `help:"password"`
  93. }
  94. func (opts *ClouduserResetPasswordOptions) Params() (jsonutils.JSONObject, error) {
  95. return jsonutils.Marshal(map[string]string{"password": opts.Password}), nil
  96. }
  97. type ClouduserCreateAccessKeyInput struct {
  98. ClouduserIdOption
  99. Name string `json:"Name"`
  100. }
  101. func (opts *ClouduserCreateAccessKeyInput) Params() (jsonutils.JSONObject, error) {
  102. return jsonutils.Marshal(map[string]string{"id": opts.ID, "name": opts.Name}), nil
  103. }
  104. type ClouduserDeleteAccessKeyInput struct {
  105. ClouduserIdOption
  106. AccessKey string `json:"access_key"`
  107. }
  108. func (opts *ClouduserDeleteAccessKeyInput) Params() (jsonutils.JSONObject, error) {
  109. return jsonutils.Marshal(map[string]string{"access_key": opts.AccessKey}), nil
  110. }
  111. type ClouduserListAccessKeyInput struct {
  112. ClouduserIdOption
  113. }
  114. func (opts *ClouduserListAccessKeyInput) Params() (jsonutils.JSONObject, error) {
  115. return nil, nil
  116. }