thirdpartyresources.go 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package unversioned
  14. import (
  15. "k8s.io/kubernetes/pkg/api"
  16. "k8s.io/kubernetes/pkg/apis/extensions"
  17. "k8s.io/kubernetes/pkg/watch"
  18. )
  19. // ThirdPartyResourceNamespacer has methods to work with ThirdPartyResource resources in a namespace
  20. type ThirdPartyResourceNamespacer interface {
  21. ThirdPartyResources() ThirdPartyResourceInterface
  22. }
  23. type ThirdPartyResourceInterface interface {
  24. List(opts api.ListOptions) (*extensions.ThirdPartyResourceList, error)
  25. Get(name string) (*extensions.ThirdPartyResource, error)
  26. Create(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error)
  27. Update(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error)
  28. UpdateStatus(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error)
  29. Delete(name string) error
  30. Watch(opts api.ListOptions) (watch.Interface, error)
  31. }
  32. // thirdPartyResources implements DaemonsSetsNamespacer interface
  33. type thirdPartyResources struct {
  34. r *ExtensionsClient
  35. }
  36. func newThirdPartyResources(c *ExtensionsClient) *thirdPartyResources {
  37. return &thirdPartyResources{c}
  38. }
  39. // Ensure statically that thirdPartyResources implements ThirdPartyResourcesInterface.
  40. var _ ThirdPartyResourceInterface = &thirdPartyResources{}
  41. func (c *thirdPartyResources) List(opts api.ListOptions) (result *extensions.ThirdPartyResourceList, err error) {
  42. result = &extensions.ThirdPartyResourceList{}
  43. err = c.r.Get().Resource("thirdpartyresources").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
  44. return
  45. }
  46. // Get returns information about a particular third party resource.
  47. func (c *thirdPartyResources) Get(name string) (result *extensions.ThirdPartyResource, err error) {
  48. result = &extensions.ThirdPartyResource{}
  49. err = c.r.Get().Resource("thirdpartyresources").Name(name).Do().Into(result)
  50. return
  51. }
  52. // Create creates a new third party resource.
  53. func (c *thirdPartyResources) Create(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) {
  54. result = &extensions.ThirdPartyResource{}
  55. err = c.r.Post().Resource("thirdpartyresources").Body(resource).Do().Into(result)
  56. return
  57. }
  58. // Update updates an existing third party resource.
  59. func (c *thirdPartyResources) Update(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) {
  60. result = &extensions.ThirdPartyResource{}
  61. err = c.r.Put().Resource("thirdpartyresources").Name(resource.Name).Body(resource).Do().Into(result)
  62. return
  63. }
  64. // UpdateStatus updates an existing third party resource status
  65. func (c *thirdPartyResources) UpdateStatus(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) {
  66. result = &extensions.ThirdPartyResource{}
  67. err = c.r.Put().Resource("thirdpartyresources").Name(resource.Name).SubResource("status").Body(resource).Do().Into(result)
  68. return
  69. }
  70. // Delete deletes an existing third party resource.
  71. func (c *thirdPartyResources) Delete(name string) error {
  72. return c.r.Delete().Resource("thirdpartyresources").Name(name).Do().Error()
  73. }
  74. // Watch returns a watch.Interface that watches the requested third party resources.
  75. func (c *thirdPartyResources) Watch(opts api.ListOptions) (watch.Interface, error) {
  76. return c.r.Get().
  77. Prefix("watch").
  78. Resource("thirdpartyresources").
  79. VersionedParams(&opts, api.ParameterCodec).
  80. Watch()
  81. }