podsecuritypolicy.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. Copyright 2014 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. type PodSecurityPoliciesInterface interface {
  20. PodSecurityPolicies() PodSecurityPolicyInterface
  21. }
  22. type PodSecurityPolicyInterface interface {
  23. Get(name string) (result *extensions.PodSecurityPolicy, err error)
  24. Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error)
  25. List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error)
  26. Delete(name string) error
  27. Update(*extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error)
  28. Watch(opts api.ListOptions) (watch.Interface, error)
  29. }
  30. // podSecurityPolicy implements PodSecurityPolicyInterface
  31. type podSecurityPolicy struct {
  32. client *ExtensionsClient
  33. }
  34. // newPodSecurityPolicy returns a podSecurityPolicy object.
  35. func newPodSecurityPolicy(c *ExtensionsClient) *podSecurityPolicy {
  36. return &podSecurityPolicy{c}
  37. }
  38. func (s *podSecurityPolicy) Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) {
  39. result := &extensions.PodSecurityPolicy{}
  40. err := s.client.Post().
  41. Resource("podsecuritypolicies").
  42. Body(psp).
  43. Do().
  44. Into(result)
  45. return result, err
  46. }
  47. // List returns a list of PodSecurityPolicies matching the selectors.
  48. func (s *podSecurityPolicy) List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) {
  49. result := &extensions.PodSecurityPolicyList{}
  50. err := s.client.Get().
  51. Resource("podsecuritypolicies").
  52. VersionedParams(&opts, api.ParameterCodec).
  53. Do().
  54. Into(result)
  55. return result, err
  56. }
  57. // Get returns the given PodSecurityPolicy, or an error.
  58. func (s *podSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy, error) {
  59. result := &extensions.PodSecurityPolicy{}
  60. err := s.client.Get().
  61. Resource("podsecuritypolicies").
  62. Name(name).
  63. Do().
  64. Into(result)
  65. return result, err
  66. }
  67. // Watch starts watching for PodSecurityPolicies matching the given selectors.
  68. func (s *podSecurityPolicy) Watch(opts api.ListOptions) (watch.Interface, error) {
  69. return s.client.Get().
  70. Prefix("watch").
  71. Resource("podsecuritypolicies").
  72. VersionedParams(&opts, api.ParameterCodec).
  73. Watch()
  74. }
  75. func (s *podSecurityPolicy) Delete(name string) error {
  76. return s.client.Delete().
  77. Resource("podsecuritypolicies").
  78. Name(name).
  79. Do().
  80. Error()
  81. }
  82. func (s *podSecurityPolicy) Update(psp *extensions.PodSecurityPolicy) (result *extensions.PodSecurityPolicy, err error) {
  83. result = &extensions.PodSecurityPolicy{}
  84. err = s.client.Put().
  85. Resource("podsecuritypolicies").
  86. Name(psp.Name).
  87. Body(psp).
  88. Do().
  89. Into(result)
  90. return
  91. }