servicecertificates.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 identity
  15. import (
  16. "yunion.io/x/onecloud/pkg/mcclient"
  17. modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity"
  18. "yunion.io/x/onecloud/pkg/mcclient/options"
  19. )
  20. func init() {
  21. R(&options.ServiceCertificateCreateOptions{}, "service-cert-create", "Create service cert", func(s *mcclient.ClientSession, opts *options.ServiceCertificateCreateOptions) error {
  22. params, err := opts.Params()
  23. if err != nil {
  24. return err
  25. }
  26. cert, err := modules.ServiceCertificatesV3.Create(s, params)
  27. if err != nil {
  28. return err
  29. }
  30. printObject(cert)
  31. return nil
  32. })
  33. type ServiceCertificateGetOptions struct {
  34. ID string `json:"-"`
  35. }
  36. R(&ServiceCertificateGetOptions{}, "service-cert-show", "Show service cert", func(s *mcclient.ClientSession, opts *ServiceCertificateGetOptions) error {
  37. cert, err := modules.ServiceCertificatesV3.Get(s, opts.ID, nil)
  38. if err != nil {
  39. return err
  40. }
  41. printObject(cert)
  42. return nil
  43. })
  44. type ServiceCertificateListOptions struct {
  45. options.BaseListOptions
  46. }
  47. R(&ServiceCertificateListOptions{}, "service-cert-list", "List service certs", func(s *mcclient.ClientSession, opts *ServiceCertificateListOptions) error {
  48. params, err := options.ListStructToParams(opts)
  49. if err != nil {
  50. return err
  51. }
  52. result, err := modules.ServiceCertificatesV3.List(s, params)
  53. if err != nil {
  54. return err
  55. }
  56. printList(result, modules.ServiceCertificatesV3.GetColumns(s))
  57. return nil
  58. })
  59. type ServiceCertificateDeleteOptions struct {
  60. ID string `json:"-"`
  61. }
  62. R(&ServiceCertificateDeleteOptions{}, "service-cert-delete", "Delete service cert", func(s *mcclient.ClientSession, opts *ServiceCertificateDeleteOptions) error {
  63. cert, err := modules.ServiceCertificatesV3.Delete(s, opts.ID, nil)
  64. if err != nil {
  65. return err
  66. }
  67. printObject(cert)
  68. return nil
  69. })
  70. }