fed_resource.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 k8s
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. "yunion.io/x/onecloud/pkg/mcclient/options"
  19. )
  20. type FedResourceListOptions struct {
  21. options.BaseListOptions
  22. }
  23. func (o *FedResourceListOptions) Params() (jsonutils.JSONObject, error) {
  24. return options.ListStructToParams(o)
  25. }
  26. type FedNamespaceResourceListOptions struct {
  27. FedResourceListOptions
  28. Federatednamespace string `json:"federatednamespace"`
  29. }
  30. func (o *FedNamespaceResourceListOptions) Params() (jsonutils.JSONObject, error) {
  31. return options.ListStructToParams(o)
  32. }
  33. type FedResourceCreateOptions struct {
  34. apis.DomainLevelResourceCreateInput
  35. }
  36. type FedResourceClusterJointOptions struct {
  37. ClusterId string `json:"cluster_id" positional:"true" required:"true" help:"ID or name of cluster"`
  38. }
  39. func (o FedResourceClusterJointOptions) Params() (jsonutils.JSONObject, error) {
  40. return jsonutils.Marshal(o), nil
  41. }
  42. type FedResourceClusterShowOptions struct {
  43. CLUSTER string `help:"ID or Name of cluster"`
  44. }
  45. func (o FedResourceClusterShowOptions) GetSlaveId() string {
  46. return o.CLUSTER
  47. }
  48. type FedNamespaceResourceCreateOptions struct {
  49. FEDNAMESPACE string `help:"Federatednamespace id or name"`
  50. FedResourceCreateOptions
  51. }
  52. func (o FedNamespaceResourceCreateOptions) Params() (jsonutils.JSONObject, error) {
  53. params := jsonutils.Marshal(o.FedResourceCreateOptions)
  54. params.(*jsonutils.JSONDict).Add(jsonutils.NewString(o.FEDNAMESPACE), "federatednamespace_id")
  55. return params, nil
  56. }
  57. func (o FedNamespaceResourceCreateOptions) ToInput() FedNamespaceResourceCreateInput {
  58. return FedNamespaceResourceCreateInput{
  59. FedResourceCreateOptions: o.FedResourceCreateOptions,
  60. FederatednamespaceId: o.FEDNAMESPACE,
  61. }
  62. }
  63. type FedNamespaceResourceCreateInput struct {
  64. FedResourceCreateOptions
  65. FederatednamespaceId string `json:"federatednamespace_id"`
  66. }