baseprojects.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 options
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. )
  19. type SharableProjectizedResourceBaseCreateInput struct {
  20. apis.ProjectizedResourceCreateInput
  21. apis.SharableResourceBaseCreateInput
  22. }
  23. func (opts *SharableProjectizedResourceBaseCreateInput) Params() (*jsonutils.JSONDict, error) {
  24. params, err := optionsStructToParams(opts.SharableResourceBaseCreateInput)
  25. if err != nil {
  26. return nil, err
  27. }
  28. projectInput, err := optionsStructToParams(opts.ProjectizedResourceCreateInput.ProjectizedResourceInput)
  29. if err != nil {
  30. return nil, err
  31. }
  32. domainInput, err := optionsStructToParams(opts.ProjectizedResourceCreateInput.DomainizedResourceInput)
  33. if err != nil {
  34. return nil, err
  35. }
  36. params.Update(projectInput)
  37. params.Update(domainInput)
  38. return params, nil
  39. }
  40. type SharableResourcePublicBaseOptions struct {
  41. Scope string `help:"sharing scope" choices:"system|domain|project"`
  42. SharedProjects []string `help:"Share to projects"`
  43. SharedDomains []string `help:"Share to domains"`
  44. }
  45. type SharableResourcePublicOptions struct {
  46. ID string
  47. SharableResourcePublicBaseOptions
  48. }
  49. func (opts *SharableResourcePublicOptions) Params() (jsonutils.JSONObject, error) {
  50. return jsonutils.Marshal(opts.SharableResourcePublicBaseOptions), nil
  51. }
  52. func (opts *SharableResourcePublicOptions) GetId() string {
  53. return opts.ID
  54. }