1# coding: utf-8
2"""
3    Kubernetes
4
5    No description provided (generated by Swagger Codegen
6    https://github.com/swagger-api/swagger-codegen)
7
8    OpenAPI spec version: v1.14.4
9
10    Generated by: https://github.com/swagger-api/swagger-codegen.git
11"""
12
13from pprint import pformat
14from six import iteritems
15import re
16
17
18class V1ServiceSpec(object):
19  """
20    NOTE: This class is auto generated by the swagger code generator program.
21    Do not edit the class manually.
22    """
23  """
24    Attributes:
25      swagger_types (dict): The key is attribute name and the value is attribute
26        type.
27      attribute_map (dict): The key is attribute name and the value is json key
28        in definition.
29  """
30  swagger_types = {
31      'cluster_ip': 'str',
32      'external_i_ps': 'list[str]',
33      'external_name': 'str',
34      'external_traffic_policy': 'str',
35      'health_check_node_port': 'int',
36      'load_balancer_ip': 'str',
37      'load_balancer_source_ranges': 'list[str]',
38      'ports': 'list[V1ServicePort]',
39      'publish_not_ready_addresses': 'bool',
40      'selector': 'dict(str, str)',
41      'session_affinity': 'str',
42      'session_affinity_config': 'V1SessionAffinityConfig',
43      'type': 'str'
44  }
45
46  attribute_map = {
47      'cluster_ip': 'clusterIP',
48      'external_i_ps': 'externalIPs',
49      'external_name': 'externalName',
50      'external_traffic_policy': 'externalTrafficPolicy',
51      'health_check_node_port': 'healthCheckNodePort',
52      'load_balancer_ip': 'loadBalancerIP',
53      'load_balancer_source_ranges': 'loadBalancerSourceRanges',
54      'ports': 'ports',
55      'publish_not_ready_addresses': 'publishNotReadyAddresses',
56      'selector': 'selector',
57      'session_affinity': 'sessionAffinity',
58      'session_affinity_config': 'sessionAffinityConfig',
59      'type': 'type'
60  }
61
62  def __init__(self,
63               cluster_ip=None,
64               external_i_ps=None,
65               external_name=None,
66               external_traffic_policy=None,
67               health_check_node_port=None,
68               load_balancer_ip=None,
69               load_balancer_source_ranges=None,
70               ports=None,
71               publish_not_ready_addresses=None,
72               selector=None,
73               session_affinity=None,
74               session_affinity_config=None,
75               type=None):
76    """
77        V1ServiceSpec - a model defined in Swagger
78        """
79
80    self._cluster_ip = None
81    self._external_i_ps = None
82    self._external_name = None
83    self._external_traffic_policy = None
84    self._health_check_node_port = None
85    self._load_balancer_ip = None
86    self._load_balancer_source_ranges = None
87    self._ports = None
88    self._publish_not_ready_addresses = None
89    self._selector = None
90    self._session_affinity = None
91    self._session_affinity_config = None
92    self._type = None
93    self.discriminator = None
94
95    if cluster_ip is not None:
96      self.cluster_ip = cluster_ip
97    if external_i_ps is not None:
98      self.external_i_ps = external_i_ps
99    if external_name is not None:
100      self.external_name = external_name
101    if external_traffic_policy is not None:
102      self.external_traffic_policy = external_traffic_policy
103    if health_check_node_port is not None:
104      self.health_check_node_port = health_check_node_port
105    if load_balancer_ip is not None:
106      self.load_balancer_ip = load_balancer_ip
107    if load_balancer_source_ranges is not None:
108      self.load_balancer_source_ranges = load_balancer_source_ranges
109    if ports is not None:
110      self.ports = ports
111    if publish_not_ready_addresses is not None:
112      self.publish_not_ready_addresses = publish_not_ready_addresses
113    if selector is not None:
114      self.selector = selector
115    if session_affinity is not None:
116      self.session_affinity = session_affinity
117    if session_affinity_config is not None:
118      self.session_affinity_config = session_affinity_config
119    if type is not None:
120      self.type = type
121
122  @property
123  def cluster_ip(self):
124    """
125        Gets the cluster_ip of this V1ServiceSpec.
126        clusterIP is the IP address of the service and is usually assigned
127        randomly by the master. If an address is specified manually and is not
128        in use by others, it will be allocated to the service; otherwise,
129        creation of the service will fail. This field can not be changed through
130        updates. Valid values are \"None\", empty string (\"\"), or a valid IP
131        address. \"None\" can be specified for headless services when proxying
132        is not required. Only applies to types ClusterIP, NodePort, and
133        LoadBalancer. Ignored if type is ExternalName. More info:
134        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
135
136        :return: The cluster_ip of this V1ServiceSpec.
137        :rtype: str
138        """
139    return self._cluster_ip
140
141  @cluster_ip.setter
142  def cluster_ip(self, cluster_ip):
143    """
144        Sets the cluster_ip of this V1ServiceSpec.
145        clusterIP is the IP address of the service and is usually assigned
146        randomly by the master. If an address is specified manually and is not
147        in use by others, it will be allocated to the service; otherwise,
148        creation of the service will fail. This field can not be changed through
149        updates. Valid values are \"None\", empty string (\"\"), or a valid IP
150        address. \"None\" can be specified for headless services when proxying
151        is not required. Only applies to types ClusterIP, NodePort, and
152        LoadBalancer. Ignored if type is ExternalName. More info:
153        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
154
155        :param cluster_ip: The cluster_ip of this V1ServiceSpec.
156        :type: str
157        """
158
159    self._cluster_ip = cluster_ip
160
161  @property
162  def external_i_ps(self):
163    """
164        Gets the external_i_ps of this V1ServiceSpec.
165        externalIPs is a list of IP addresses for which nodes in the cluster
166        will also accept traffic for this service.  These IPs are not managed by
167        Kubernetes.  The user is responsible for ensuring that traffic arrives
168        at a node with this IP.  A common example is external load-balancers
169        that are not part of the Kubernetes system.
170
171        :return: The external_i_ps of this V1ServiceSpec.
172        :rtype: list[str]
173        """
174    return self._external_i_ps
175
176  @external_i_ps.setter
177  def external_i_ps(self, external_i_ps):
178    """
179        Sets the external_i_ps of this V1ServiceSpec.
180        externalIPs is a list of IP addresses for which nodes in the cluster
181        will also accept traffic for this service.  These IPs are not managed by
182        Kubernetes.  The user is responsible for ensuring that traffic arrives
183        at a node with this IP.  A common example is external load-balancers
184        that are not part of the Kubernetes system.
185
186        :param external_i_ps: The external_i_ps of this V1ServiceSpec.
187        :type: list[str]
188        """
189
190    self._external_i_ps = external_i_ps
191
192  @property
193  def external_name(self):
194    """
195        Gets the external_name of this V1ServiceSpec.
196        externalName is the external reference that kubedns or equivalent will
197        return as a CNAME record for this service. No proxying will be involved.
198        Must be a valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
199        and requires Type to be ExternalName.
200
201        :return: The external_name of this V1ServiceSpec.
202        :rtype: str
203        """
204    return self._external_name
205
206  @external_name.setter
207  def external_name(self, external_name):
208    """
209        Sets the external_name of this V1ServiceSpec.
210        externalName is the external reference that kubedns or equivalent will
211        return as a CNAME record for this service. No proxying will be involved.
212        Must be a valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
213        and requires Type to be ExternalName.
214
215        :param external_name: The external_name of this V1ServiceSpec.
216        :type: str
217        """
218
219    self._external_name = external_name
220
221  @property
222  def external_traffic_policy(self):
223    """
224        Gets the external_traffic_policy of this V1ServiceSpec.
225        externalTrafficPolicy denotes if this Service desires to route external
226        traffic to node-local or cluster-wide endpoints. \"Local\" preserves the
227        client source IP and avoids a second hop for LoadBalancer and Nodeport
228        type services, but risks potentially imbalanced traffic spreading.
229        \"Cluster\" obscures the client source IP and may cause a second hop to
230        another node, but should have good overall load-spreading.
231
232        :return: The external_traffic_policy of this V1ServiceSpec.
233        :rtype: str
234        """
235    return self._external_traffic_policy
236
237  @external_traffic_policy.setter
238  def external_traffic_policy(self, external_traffic_policy):
239    """
240        Sets the external_traffic_policy of this V1ServiceSpec.
241        externalTrafficPolicy denotes if this Service desires to route external
242        traffic to node-local or cluster-wide endpoints. \"Local\" preserves the
243        client source IP and avoids a second hop for LoadBalancer and Nodeport
244        type services, but risks potentially imbalanced traffic spreading.
245        \"Cluster\" obscures the client source IP and may cause a second hop to
246        another node, but should have good overall load-spreading.
247
248        :param external_traffic_policy: The external_traffic_policy of this
249        V1ServiceSpec.
250        :type: str
251        """
252
253    self._external_traffic_policy = external_traffic_policy
254
255  @property
256  def health_check_node_port(self):
257    """
258        Gets the health_check_node_port of this V1ServiceSpec.
259        healthCheckNodePort specifies the healthcheck nodePort for the service.
260        If not specified, HealthCheckNodePort is created by the service api
261        backend with the allocated nodePort. Will use user-specified nodePort
262        value if specified by the client. Only effects when Type is set to
263        LoadBalancer and ExternalTrafficPolicy is set to Local.
264
265        :return: The health_check_node_port of this V1ServiceSpec.
266        :rtype: int
267        """
268    return self._health_check_node_port
269
270  @health_check_node_port.setter
271  def health_check_node_port(self, health_check_node_port):
272    """
273        Sets the health_check_node_port of this V1ServiceSpec.
274        healthCheckNodePort specifies the healthcheck nodePort for the service.
275        If not specified, HealthCheckNodePort is created by the service api
276        backend with the allocated nodePort. Will use user-specified nodePort
277        value if specified by the client. Only effects when Type is set to
278        LoadBalancer and ExternalTrafficPolicy is set to Local.
279
280        :param health_check_node_port: The health_check_node_port of this
281        V1ServiceSpec.
282        :type: int
283        """
284
285    self._health_check_node_port = health_check_node_port
286
287  @property
288  def load_balancer_ip(self):
289    """
290        Gets the load_balancer_ip of this V1ServiceSpec.
291        Only applies to Service Type: LoadBalancer LoadBalancer will get created
292        with the IP specified in this field. This feature depends on whether the
293        underlying cloud-provider supports specifying the loadBalancerIP when a
294        load balancer is created. This field will be ignored if the
295        cloud-provider does not support the feature.
296
297        :return: The load_balancer_ip of this V1ServiceSpec.
298        :rtype: str
299        """
300    return self._load_balancer_ip
301
302  @load_balancer_ip.setter
303  def load_balancer_ip(self, load_balancer_ip):
304    """
305        Sets the load_balancer_ip of this V1ServiceSpec.
306        Only applies to Service Type: LoadBalancer LoadBalancer will get created
307        with the IP specified in this field. This feature depends on whether the
308        underlying cloud-provider supports specifying the loadBalancerIP when a
309        load balancer is created. This field will be ignored if the
310        cloud-provider does not support the feature.
311
312        :param load_balancer_ip: The load_balancer_ip of this V1ServiceSpec.
313        :type: str
314        """
315
316    self._load_balancer_ip = load_balancer_ip
317
318  @property
319  def load_balancer_source_ranges(self):
320    """
321        Gets the load_balancer_source_ranges of this V1ServiceSpec.
322        If specified and supported by the platform, this will restrict traffic
323        through the cloud-provider load-balancer will be restricted to the
324        specified client IPs. This field will be ignored if the cloud-provider
325        does not support the feature.\" More info:
326        https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/
327
328        :return: The load_balancer_source_ranges of this V1ServiceSpec.
329        :rtype: list[str]
330        """
331    return self._load_balancer_source_ranges
332
333  @load_balancer_source_ranges.setter
334  def load_balancer_source_ranges(self, load_balancer_source_ranges):
335    """
336        Sets the load_balancer_source_ranges of this V1ServiceSpec.
337        If specified and supported by the platform, this will restrict traffic
338        through the cloud-provider load-balancer will be restricted to the
339        specified client IPs. This field will be ignored if the cloud-provider
340        does not support the feature.\" More info:
341        https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/
342
343        :param load_balancer_source_ranges: The load_balancer_source_ranges of
344        this V1ServiceSpec.
345        :type: list[str]
346        """
347
348    self._load_balancer_source_ranges = load_balancer_source_ranges
349
350  @property
351  def ports(self):
352    """
353        Gets the ports of this V1ServiceSpec.
354        The list of ports that are exposed by this service. More info:
355        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
356
357        :return: The ports of this V1ServiceSpec.
358        :rtype: list[V1ServicePort]
359        """
360    return self._ports
361
362  @ports.setter
363  def ports(self, ports):
364    """
365        Sets the ports of this V1ServiceSpec.
366        The list of ports that are exposed by this service. More info:
367        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
368
369        :param ports: The ports of this V1ServiceSpec.
370        :type: list[V1ServicePort]
371        """
372
373    self._ports = ports
374
375  @property
376  def publish_not_ready_addresses(self):
377    """
378        Gets the publish_not_ready_addresses of this V1ServiceSpec.
379        publishNotReadyAddresses, when set to true, indicates that DNS
380        implementations must publish the notReadyAddresses of subsets for the
381        Endpoints associated with the Service. The default value is false. The
382        primary use case for setting this field is to use a StatefulSet's
383        Headless Service to propagate SRV records for its Pods without respect
384        to their readiness for purpose of peer discovery.
385
386        :return: The publish_not_ready_addresses of this V1ServiceSpec.
387        :rtype: bool
388        """
389    return self._publish_not_ready_addresses
390
391  @publish_not_ready_addresses.setter
392  def publish_not_ready_addresses(self, publish_not_ready_addresses):
393    """
394        Sets the publish_not_ready_addresses of this V1ServiceSpec.
395        publishNotReadyAddresses, when set to true, indicates that DNS
396        implementations must publish the notReadyAddresses of subsets for the
397        Endpoints associated with the Service. The default value is false. The
398        primary use case for setting this field is to use a StatefulSet's
399        Headless Service to propagate SRV records for its Pods without respect
400        to their readiness for purpose of peer discovery.
401
402        :param publish_not_ready_addresses: The publish_not_ready_addresses of
403        this V1ServiceSpec.
404        :type: bool
405        """
406
407    self._publish_not_ready_addresses = publish_not_ready_addresses
408
409  @property
410  def selector(self):
411    """
412        Gets the selector of this V1ServiceSpec.
413        Route service traffic to pods with label keys and values matching this
414        selector. If empty or not present, the service is assumed to have an
415        external process managing its endpoints, which Kubernetes will not
416        modify. Only applies to types ClusterIP, NodePort, and LoadBalancer.
417        Ignored if type is ExternalName. More info:
418        https://kubernetes.io/docs/concepts/services-networking/service/
419
420        :return: The selector of this V1ServiceSpec.
421        :rtype: dict(str, str)
422        """
423    return self._selector
424
425  @selector.setter
426  def selector(self, selector):
427    """
428        Sets the selector of this V1ServiceSpec.
429        Route service traffic to pods with label keys and values matching this
430        selector. If empty or not present, the service is assumed to have an
431        external process managing its endpoints, which Kubernetes will not
432        modify. Only applies to types ClusterIP, NodePort, and LoadBalancer.
433        Ignored if type is ExternalName. More info:
434        https://kubernetes.io/docs/concepts/services-networking/service/
435
436        :param selector: The selector of this V1ServiceSpec.
437        :type: dict(str, str)
438        """
439
440    self._selector = selector
441
442  @property
443  def session_affinity(self):
444    """
445        Gets the session_affinity of this V1ServiceSpec.
446        Supports \"ClientIP\" and \"None\". Used to maintain session affinity.
447        Enable client IP based session affinity. Must be ClientIP or None.
448        Defaults to None. More info:
449        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
450
451        :return: The session_affinity of this V1ServiceSpec.
452        :rtype: str
453        """
454    return self._session_affinity
455
456  @session_affinity.setter
457  def session_affinity(self, session_affinity):
458    """
459        Sets the session_affinity of this V1ServiceSpec.
460        Supports \"ClientIP\" and \"None\". Used to maintain session affinity.
461        Enable client IP based session affinity. Must be ClientIP or None.
462        Defaults to None. More info:
463        https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
464
465        :param session_affinity: The session_affinity of this V1ServiceSpec.
466        :type: str
467        """
468
469    self._session_affinity = session_affinity
470
471  @property
472  def session_affinity_config(self):
473    """
474        Gets the session_affinity_config of this V1ServiceSpec.
475        sessionAffinityConfig contains the configurations of session affinity.
476
477        :return: The session_affinity_config of this V1ServiceSpec.
478        :rtype: V1SessionAffinityConfig
479        """
480    return self._session_affinity_config
481
482  @session_affinity_config.setter
483  def session_affinity_config(self, session_affinity_config):
484    """
485        Sets the session_affinity_config of this V1ServiceSpec.
486        sessionAffinityConfig contains the configurations of session affinity.
487
488        :param session_affinity_config: The session_affinity_config of this
489        V1ServiceSpec.
490        :type: V1SessionAffinityConfig
491        """
492
493    self._session_affinity_config = session_affinity_config
494
495  @property
496  def type(self):
497    """
498        Gets the type of this V1ServiceSpec.
499        type determines how the Service is exposed. Defaults to ClusterIP. Valid
500        options are ExternalName, ClusterIP, NodePort, and LoadBalancer.
501        \"ExternalName\" maps to the specified externalName. \"ClusterIP\"
502        allocates a cluster-internal IP address for load-balancing to endpoints.
503        Endpoints are determined by the selector or if that is not specified, by
504        manual construction of an Endpoints object. If clusterIP is \"None\", no
505        virtual IP is allocated and the endpoints are published as a set of
506        endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and
507        allocates a port on every node which routes to the clusterIP.
508        \"LoadBalancer\" builds on NodePort and creates an external
509        load-balancer (if supported in the current cloud) which routes to the
510        clusterIP. More info:
511        https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
512
513        :return: The type of this V1ServiceSpec.
514        :rtype: str
515        """
516    return self._type
517
518  @type.setter
519  def type(self, type):
520    """
521        Sets the type of this V1ServiceSpec.
522        type determines how the Service is exposed. Defaults to ClusterIP. Valid
523        options are ExternalName, ClusterIP, NodePort, and LoadBalancer.
524        \"ExternalName\" maps to the specified externalName. \"ClusterIP\"
525        allocates a cluster-internal IP address for load-balancing to endpoints.
526        Endpoints are determined by the selector or if that is not specified, by
527        manual construction of an Endpoints object. If clusterIP is \"None\", no
528        virtual IP is allocated and the endpoints are published as a set of
529        endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and
530        allocates a port on every node which routes to the clusterIP.
531        \"LoadBalancer\" builds on NodePort and creates an external
532        load-balancer (if supported in the current cloud) which routes to the
533        clusterIP. More info:
534        https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
535
536        :param type: The type of this V1ServiceSpec.
537        :type: str
538        """
539
540    self._type = type
541
542  def to_dict(self):
543    """
544        Returns the model properties as a dict
545        """
546    result = {}
547
548    for attr, _ in iteritems(self.swagger_types):
549      value = getattr(self, attr)
550      if isinstance(value, list):
551        result[attr] = list(
552            map(lambda x: x.to_dict() if hasattr(x, 'to_dict') else x, value))
553      elif hasattr(value, 'to_dict'):
554        result[attr] = value.to_dict()
555      elif isinstance(value, dict):
556        result[attr] = dict(
557            map(
558                lambda item: (item[0], item[1].to_dict())
559                if hasattr(item[1], 'to_dict') else item, value.items()))
560      else:
561        result[attr] = value
562
563    return result
564
565  def to_str(self):
566    """
567        Returns the string representation of the model
568        """
569    return pformat(self.to_dict())
570
571  def __repr__(self):
572    """
573        For `print` and `pprint`
574        """
575    return self.to_str()
576
577  def __eq__(self, other):
578    """
579        Returns true if both objects are equal
580        """
581    if not isinstance(other, V1ServiceSpec):
582      return False
583
584    return self.__dict__ == other.__dict__
585
586  def __ne__(self, other):
587    """
588        Returns true if both objects are not equal
589        """
590    return not self == other
591