/
InitializerConfiguration.purs
246 lines (221 loc) · 18.1 KB
/
InitializerConfiguration.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
module Kubernetes.Api.AdmissionRegistration.V1Alpha1.InitializerConfiguration where
import Prelude
import Control.Monad.Aff (Aff)
import Data.Either (Either(Left,Right))
import Data.Foreign.Class (class Decode, class Encode, encode, decode)
import Data.Foreign.Generic (encodeJSON, genericEncode, genericDecode)
import Data.Foreign.Index (readProp)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(Just,Nothing))
import Data.Newtype (class Newtype)
import Data.StrMap (StrMap)
import Data.StrMap as StrMap
import Data.Tuple (Tuple(Tuple))
import Kubernetes.Client as Client
import Kubernetes.Config (Config)
import Kubernetes.Default (class Default)
import Kubernetes.Json (assertPropEq, decodeMaybe, encodeMaybe, jsonOptions)
import Node.HTTP (HTTP)
import Kubernetes.Api.AdmissionRegistration.V1Alpha1 as AdmissionRegistrationV1Alpha1
import Kubernetes.Api.Meta.V1 as MetaV1
-- | create an InitializerConfiguration
create :: forall e. Config -> AdmissionRegistrationV1Alpha1.InitializerConfiguration -> Aff (http :: HTTP | e) (Either MetaV1.Status AdmissionRegistrationV1Alpha1.InitializerConfiguration)
create cfg body = Client.makeRequest (Client.post cfg url (Just encodedBody))
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations"
encodedBody = encodeJSON body
-- | Fields:
-- | - `gracePeriodSeconds`: The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.
-- | - `orphanDependents`: Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.
-- | - `propagationPolicy`: Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.
newtype DeleteOptions = DeleteOptions
{ gracePeriodSeconds :: (Maybe Int)
, orphanDependents :: (Maybe Boolean)
, propagationPolicy :: (Maybe String) }
derive instance newtypeDeleteOptions :: Newtype DeleteOptions _
derive instance genericDeleteOptions :: Generic DeleteOptions _
instance showDeleteOptions :: Show DeleteOptions where show a = genericShow a
instance decodeDeleteOptions :: Decode DeleteOptions where
decode a = do
gracePeriodSeconds <- decodeMaybe "gracePeriodSeconds" a
orphanDependents <- decodeMaybe "orphanDependents" a
propagationPolicy <- decodeMaybe "propagationPolicy" a
pure $ DeleteOptions { gracePeriodSeconds, orphanDependents, propagationPolicy }
instance encodeDeleteOptions :: Encode DeleteOptions where
encode (DeleteOptions a) = encode $ StrMap.fromFoldable $
[ Tuple "gracePeriodSeconds" (encodeMaybe a.gracePeriodSeconds)
, Tuple "orphanDependents" (encodeMaybe a.orphanDependents)
, Tuple "propagationPolicy" (encodeMaybe a.propagationPolicy) ]
instance defaultDeleteOptions :: Default DeleteOptions where
default = DeleteOptions
{ gracePeriodSeconds: Nothing
, orphanDependents: Nothing
, propagationPolicy: Nothing }
-- | delete an InitializerConfiguration
delete :: forall e. Config -> MetaV1.DeleteOptions -> DeleteOptions -> Aff (http :: HTTP | e) (Either MetaV1.Status MetaV1.Status)
delete cfg body options = Client.makeRequest (Client.delete cfg url (Just encodedBody))
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations/{name}" <> Client.formatQueryString options
encodedBody = encodeJSON body
-- | Fields:
-- | - `continue`: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server the server will respond with a 410 ResourceExpired error indicating the client must restart their list without the continue field. This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.
-- | - `fieldSelector`: A selector to restrict the list of returned objects by their fields. Defaults to everything.
-- | - `includeUninitialized`: If true, partially initialized resources are included in the response.
-- | - `labelSelector`: A selector to restrict the list of returned objects by their labels. Defaults to everything.
-- | - `limit`: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.
-- |
-- | The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.
-- | - `resourceVersion`: When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. When specified for list: - if unset, then the result is returned from remote storage based on quorum-read flag; - if it's 0, then we simply return what we currently have in cache, no guarantee; - if set to non zero, then the result is at least as fresh as given rv.
-- | - `timeoutSeconds`: Timeout for the list/watch call.
-- | - `watch`: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.
newtype DeleteCollectionOptions = DeleteCollectionOptions
{ continue :: (Maybe String)
, fieldSelector :: (Maybe String)
, includeUninitialized :: (Maybe Boolean)
, labelSelector :: (Maybe String)
, limit :: (Maybe Int)
, resourceVersion :: (Maybe String)
, timeoutSeconds :: (Maybe Int)
, watch :: (Maybe Boolean) }
derive instance newtypeDeleteCollectionOptions :: Newtype DeleteCollectionOptions _
derive instance genericDeleteCollectionOptions :: Generic DeleteCollectionOptions _
instance showDeleteCollectionOptions :: Show DeleteCollectionOptions where show a = genericShow a
instance decodeDeleteCollectionOptions :: Decode DeleteCollectionOptions where
decode a = do
continue <- decodeMaybe "continue" a
fieldSelector <- decodeMaybe "fieldSelector" a
includeUninitialized <- decodeMaybe "includeUninitialized" a
labelSelector <- decodeMaybe "labelSelector" a
limit <- decodeMaybe "limit" a
resourceVersion <- decodeMaybe "resourceVersion" a
timeoutSeconds <- decodeMaybe "timeoutSeconds" a
watch <- decodeMaybe "watch" a
pure $ DeleteCollectionOptions { continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch }
instance encodeDeleteCollectionOptions :: Encode DeleteCollectionOptions where
encode (DeleteCollectionOptions a) = encode $ StrMap.fromFoldable $
[ Tuple "continue" (encodeMaybe a.continue)
, Tuple "fieldSelector" (encodeMaybe a.fieldSelector)
, Tuple "includeUninitialized" (encodeMaybe a.includeUninitialized)
, Tuple "labelSelector" (encodeMaybe a.labelSelector)
, Tuple "limit" (encodeMaybe a.limit)
, Tuple "resourceVersion" (encodeMaybe a.resourceVersion)
, Tuple "timeoutSeconds" (encodeMaybe a.timeoutSeconds)
, Tuple "watch" (encodeMaybe a.watch) ]
instance defaultDeleteCollectionOptions :: Default DeleteCollectionOptions where
default = DeleteCollectionOptions
{ continue: Nothing
, fieldSelector: Nothing
, includeUninitialized: Nothing
, labelSelector: Nothing
, limit: Nothing
, resourceVersion: Nothing
, timeoutSeconds: Nothing
, watch: Nothing }
-- | delete collection of InitializerConfiguration
deleteCollection :: forall e. Config -> DeleteCollectionOptions -> Aff (http :: HTTP | e) (Either MetaV1.Status MetaV1.Status)
deleteCollection cfg options = Client.makeRequest (Client.delete cfg url Nothing)
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations" <> Client.formatQueryString options
-- | Fields:
-- | - `continue`: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server the server will respond with a 410 ResourceExpired error indicating the client must restart their list without the continue field. This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.
-- | - `fieldSelector`: A selector to restrict the list of returned objects by their fields. Defaults to everything.
-- | - `includeUninitialized`: If true, partially initialized resources are included in the response.
-- | - `labelSelector`: A selector to restrict the list of returned objects by their labels. Defaults to everything.
-- | - `limit`: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.
-- |
-- | The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.
-- | - `resourceVersion`: When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. When specified for list: - if unset, then the result is returned from remote storage based on quorum-read flag; - if it's 0, then we simply return what we currently have in cache, no guarantee; - if set to non zero, then the result is at least as fresh as given rv.
-- | - `timeoutSeconds`: Timeout for the list/watch call.
-- | - `watch`: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.
newtype ListOptions = ListOptions
{ continue :: (Maybe String)
, fieldSelector :: (Maybe String)
, includeUninitialized :: (Maybe Boolean)
, labelSelector :: (Maybe String)
, limit :: (Maybe Int)
, resourceVersion :: (Maybe String)
, timeoutSeconds :: (Maybe Int)
, watch :: (Maybe Boolean) }
derive instance newtypeListOptions :: Newtype ListOptions _
derive instance genericListOptions :: Generic ListOptions _
instance showListOptions :: Show ListOptions where show a = genericShow a
instance decodeListOptions :: Decode ListOptions where
decode a = do
continue <- decodeMaybe "continue" a
fieldSelector <- decodeMaybe "fieldSelector" a
includeUninitialized <- decodeMaybe "includeUninitialized" a
labelSelector <- decodeMaybe "labelSelector" a
limit <- decodeMaybe "limit" a
resourceVersion <- decodeMaybe "resourceVersion" a
timeoutSeconds <- decodeMaybe "timeoutSeconds" a
watch <- decodeMaybe "watch" a
pure $ ListOptions { continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch }
instance encodeListOptions :: Encode ListOptions where
encode (ListOptions a) = encode $ StrMap.fromFoldable $
[ Tuple "continue" (encodeMaybe a.continue)
, Tuple "fieldSelector" (encodeMaybe a.fieldSelector)
, Tuple "includeUninitialized" (encodeMaybe a.includeUninitialized)
, Tuple "labelSelector" (encodeMaybe a.labelSelector)
, Tuple "limit" (encodeMaybe a.limit)
, Tuple "resourceVersion" (encodeMaybe a.resourceVersion)
, Tuple "timeoutSeconds" (encodeMaybe a.timeoutSeconds)
, Tuple "watch" (encodeMaybe a.watch) ]
instance defaultListOptions :: Default ListOptions where
default = ListOptions
{ continue: Nothing
, fieldSelector: Nothing
, includeUninitialized: Nothing
, labelSelector: Nothing
, limit: Nothing
, resourceVersion: Nothing
, timeoutSeconds: Nothing
, watch: Nothing }
-- | list or watch objects of kind InitializerConfiguration
list :: forall e. Config -> ListOptions -> Aff (http :: HTTP | e) (Either MetaV1.Status AdmissionRegistrationV1Alpha1.InitializerConfigurationList)
list cfg options = Client.makeRequest (Client.get cfg url Nothing)
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations" <> Client.formatQueryString options
-- | Fields:
-- | - `exact`: Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'.
-- | - `export`: Should this value be exported. Export strips fields that a user can not specify.
newtype ReadOptions = ReadOptions
{ exact :: (Maybe Boolean)
, export :: (Maybe Boolean) }
derive instance newtypeReadOptions :: Newtype ReadOptions _
derive instance genericReadOptions :: Generic ReadOptions _
instance showReadOptions :: Show ReadOptions where show a = genericShow a
instance decodeReadOptions :: Decode ReadOptions where
decode a = do
exact <- decodeMaybe "exact" a
export <- decodeMaybe "export" a
pure $ ReadOptions { exact, export }
instance encodeReadOptions :: Encode ReadOptions where
encode (ReadOptions a) = encode $ StrMap.fromFoldable $
[ Tuple "exact" (encodeMaybe a.exact)
, Tuple "export" (encodeMaybe a.export) ]
instance defaultReadOptions :: Default ReadOptions where
default = ReadOptions
{ exact: Nothing
, export: Nothing }
-- | read the specified InitializerConfiguration
read :: forall e. Config -> ReadOptions -> Aff (http :: HTTP | e) (Either MetaV1.Status AdmissionRegistrationV1Alpha1.InitializerConfiguration)
read cfg options = Client.makeRequest (Client.get cfg url Nothing)
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations/{name}" <> Client.formatQueryString options
-- | replace the specified InitializerConfiguration
replace :: forall e. Config -> AdmissionRegistrationV1Alpha1.InitializerConfiguration -> Aff (http :: HTTP | e) (Either MetaV1.Status AdmissionRegistrationV1Alpha1.InitializerConfiguration)
replace cfg body = Client.makeRequest (Client.put cfg url (Just encodedBody))
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/initializerconfigurations/{name}"
encodedBody = encodeJSON body
-- | watch changes to an object of kind InitializerConfiguration
watch :: forall e. Config -> Aff (http :: HTTP | e) (Either MetaV1.Status MetaV1.WatchEvent)
watch cfg = Client.makeRequest (Client.get cfg url Nothing)
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/watch/initializerconfigurations/{name}"
-- | watch individual changes to a list of InitializerConfiguration
watchList :: forall e. Config -> Aff (http :: HTTP | e) (Either MetaV1.Status MetaV1.WatchEvent)
watchList cfg = Client.makeRequest (Client.get cfg url Nothing)
where
url = "/apis/admissionregistration.k8s.io/v1alpha1/watch/initializerconfigurations"