=begin comment

Kubernetes

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

OpenAPI spec version: v1.13.5

Generated by: https://openapi-generator.tech

=end comment

=cut

#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package Kubernetes::Object::V1ServiceSpec;

require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::Parse;
use DateTime;

use Kubernetes::Object::V1ServicePort;
use Kubernetes::Object::V1SessionAffinityConfig;

use base ("Class::Accessor", "Class::Data::Inheritable");


#
#ServiceSpec describes the attributes that a user creates on a service.
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually.
# REF: https://openapi-generator.tech
#

=begin comment

Kubernetes

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

OpenAPI spec version: v1.13.5

Generated by: https://openapi-generator.tech

=end comment

=cut

#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
__PACKAGE__->mk_classdata('attribute_map' => {});
__PACKAGE__->mk_classdata('openapi_types' => {});
__PACKAGE__->mk_classdata('method_documentation' => {}); 
__PACKAGE__->mk_classdata('class_documentation' => {});

# new object
sub new { 
    my ($class, %args) = @_; 

	my $self = bless {}, $class;
	
	foreach my $attribute (keys %{$class->attribute_map}) {
		my $args_key = $class->attribute_map->{$attribute};
		$self->$attribute( $args{ $args_key } );
	}
	
	return $self;
}  

# return perl hash
sub to_hash {
    return decode_json(JSON->new->convert_blessed->encode( shift ));
}

# used by JSON for serialization
sub TO_JSON { 
    my $self = shift;
    my $_data = {};
    foreach my $_key (keys %{$self->attribute_map}) {
        if (defined $self->{$_key}) {
            $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
        }
    }
    return $_data;
}

# from Perl hashref
sub from_hash {
    my ($self, $hash) = @_;

    # loop through attributes and use openapi_types to deserialize the data
    while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
    	my $_json_attribute = $self->attribute_map->{$_key}; 
        if ($_type =~ /^array\[/i) { # array
            my $_subclass = substr($_type, 6, -1);
            my @_array = ();
            foreach my $_element (@{$hash->{$_json_attribute}}) {
                push @_array, $self->_deserialize($_subclass, $_element);
            }
            $self->{$_key} = \@_array;
        } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
            $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
        } else {
        	$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
        }
    }
  
    return $self;
}

# deserialize non-array data
sub _deserialize {
    my ($self, $type, $data) = @_;
    $log->debugf("deserializing %s with %s",Dumper($data), $type);
        
    if ($type eq 'DateTime') {
        return DateTime->from_epoch(epoch => str2time($data));
    } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
        return $data;
    } else { # hash(model)
        my $_instance = eval "Kubernetes::Object::$type->new()";
        return $_instance->from_hash($data);
    }
}



__PACKAGE__->class_documentation({description => 'ServiceSpec describes the attributes that a user creates on a service.',
                                  class => 'V1ServiceSpec',
                                  required => [], # TODO
}                                 );

__PACKAGE__->method_documentation({
    'cluster_ip' => {
    	datatype => 'string',
    	base_name => 'clusterIP',
    	description => 'clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \&quot;None\&quot;, empty string (\&quot;\&quot;), or a valid IP address. \&quot;None\&quot; can be specified for headless services when proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies',
    	format => '',
    	read_only => '',
    		},
    'external_i_ps' => {
    	datatype => 'ARRAY[string]',
    	base_name => 'externalIPs',
    	description => 'externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service.  These IPs are not managed by Kubernetes.  The user is responsible for ensuring that traffic arrives at a node with this IP.  A common example is external load-balancers that are not part of the Kubernetes system.',
    	format => '',
    	read_only => '',
    		},
    'external_name' => {
    	datatype => 'string',
    	base_name => 'externalName',
    	description => 'externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) and requires Type to be ExternalName.',
    	format => '',
    	read_only => '',
    		},
    'external_traffic_policy' => {
    	datatype => 'string',
    	base_name => 'externalTrafficPolicy',
    	description => 'externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. \&quot;Local\&quot; preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. \&quot;Cluster\&quot; obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading.',
    	format => '',
    	read_only => '',
    		},
    'health_check_node_port' => {
    	datatype => 'int',
    	base_name => 'healthCheckNodePort',
    	description => 'healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.',
    	format => '',
    	read_only => '',
    		},
    'load_balancer_ip' => {
    	datatype => 'string',
    	base_name => 'loadBalancerIP',
    	description => 'Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.',
    	format => '',
    	read_only => '',
    		},
    'load_balancer_source_ranges' => {
    	datatype => 'ARRAY[string]',
    	base_name => 'loadBalancerSourceRanges',
    	description => 'If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\&quot; More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/',
    	format => '',
    	read_only => '',
    		},
    'ports' => {
    	datatype => 'ARRAY[V1ServicePort]',
    	base_name => 'ports',
    	description => 'The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies',
    	format => '',
    	read_only => '',
    		},
    'publish_not_ready_addresses' => {
    	datatype => 'boolean',
    	base_name => 'publishNotReadyAddresses',
    	description => 'publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet&#39;s Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery.',
    	format => '',
    	read_only => '',
    		},
    'selector' => {
    	datatype => 'HASH[string,string]',
    	base_name => 'selector',
    	description => 'Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/',
    	format => '',
    	read_only => '',
    		},
    'session_affinity' => {
    	datatype => 'string',
    	base_name => 'sessionAffinity',
    	description => 'Supports \&quot;ClientIP\&quot; and \&quot;None\&quot;. Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies',
    	format => '',
    	read_only => '',
    		},
    'session_affinity_config' => {
    	datatype => 'V1SessionAffinityConfig',
    	base_name => 'sessionAffinityConfig',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'type' => {
    	datatype => 'string',
    	base_name => 'type',
    	description => 'type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \&quot;ExternalName\&quot; maps to the specified externalName. \&quot;ClusterIP\&quot; allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is \&quot;None\&quot;, no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. \&quot;NodePort\&quot; builds on ClusterIP and allocates a port on every node which routes to the clusterIP. \&quot;LoadBalancer\&quot; builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types',
    	format => '',
    	read_only => '',
    		},
});

__PACKAGE__->openapi_types( {
    'cluster_ip' => 'string',
    'external_i_ps' => 'ARRAY[string]',
    'external_name' => 'string',
    'external_traffic_policy' => 'string',
    'health_check_node_port' => 'int',
    'load_balancer_ip' => 'string',
    'load_balancer_source_ranges' => 'ARRAY[string]',
    'ports' => 'ARRAY[V1ServicePort]',
    'publish_not_ready_addresses' => 'boolean',
    'selector' => 'HASH[string,string]',
    'session_affinity' => 'string',
    'session_affinity_config' => 'V1SessionAffinityConfig',
    'type' => 'string'
} );

__PACKAGE__->attribute_map( {
    'cluster_ip' => 'clusterIP',
    'external_i_ps' => 'externalIPs',
    'external_name' => 'externalName',
    'external_traffic_policy' => 'externalTrafficPolicy',
    'health_check_node_port' => 'healthCheckNodePort',
    'load_balancer_ip' => 'loadBalancerIP',
    'load_balancer_source_ranges' => 'loadBalancerSourceRanges',
    'ports' => 'ports',
    'publish_not_ready_addresses' => 'publishNotReadyAddresses',
    'selector' => 'selector',
    'session_affinity' => 'sessionAffinity',
    'session_affinity_config' => 'sessionAffinityConfig',
    'type' => 'type'
} );

__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});


1;
