=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::V1JobSpec;

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::V1LabelSelector;
use Kubernetes::Object::V1PodTemplateSpec;

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


#
#JobSpec describes how the job execution will look like.
#
# 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 => 'JobSpec describes how the job execution will look like.',
                                  class => 'V1JobSpec',
                                  required => [], # TODO
}                                 );

__PACKAGE__->method_documentation({
    'active_deadline_seconds' => {
    	datatype => 'int',
    	base_name => 'activeDeadlineSeconds',
    	description => 'Specifies the duration in seconds relative to the startTime that the job may be active before the system tries to terminate it; value must be positive integer',
    	format => '',
    	read_only => '',
    		},
    'backoff_limit' => {
    	datatype => 'int',
    	base_name => 'backoffLimit',
    	description => 'Specifies the number of retries before marking this job failed. Defaults to 6',
    	format => '',
    	read_only => '',
    		},
    'completions' => {
    	datatype => 'int',
    	base_name => 'completions',
    	description => 'Specifies the desired number of successfully finished pods the job should be run with.  Setting to nil means that the success of any pod signals the success of all pods, and allows parallelism to have any positive value.  Setting to 1 means that parallelism is limited to 1 and the success of that pod signals the success of the job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/',
    	format => '',
    	read_only => '',
    		},
    'manual_selector' => {
    	datatype => 'boolean',
    	base_name => 'manualSelector',
    	description => 'manualSelector controls generation of pod labels and pod selectors. Leave &#x60;manualSelector&#x60; unset unless you are certain what you are doing. When false or unset, the system pick labels unique to this job and appends those labels to the pod template.  When true, the user is responsible for picking unique labels and specifying the selector.  Failure to pick a unique label may cause this and other jobs to not function correctly.  However, You may see &#x60;manualSelector&#x3D;true&#x60; in jobs that were created with the old &#x60;extensions/v1beta1&#x60; API. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector',
    	format => '',
    	read_only => '',
    		},
    'parallelism' => {
    	datatype => 'int',
    	base_name => 'parallelism',
    	description => 'Specifies the maximum desired number of pods the job should run at any given time. The actual number of pods running in steady state will be less than this number when ((.spec.completions - .status.successful) &lt; .spec.parallelism), i.e. when the work left to do is less than max parallelism. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/',
    	format => '',
    	read_only => '',
    		},
    'selector' => {
    	datatype => 'V1LabelSelector',
    	base_name => 'selector',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'template' => {
    	datatype => 'V1PodTemplateSpec',
    	base_name => 'template',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'ttl_seconds_after_finished' => {
    	datatype => 'int',
    	base_name => 'ttlSecondsAfterFinished',
    	description => 'ttlSecondsAfterFinished limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the Job won&#39;t be automatically deleted. If this field is set to zero, the Job becomes eligible to be deleted immediately after it finishes. This field is alpha-level and is only honored by servers that enable the TTLAfterFinished feature.',
    	format => '',
    	read_only => '',
    		},
});

__PACKAGE__->openapi_types( {
    'active_deadline_seconds' => 'int',
    'backoff_limit' => 'int',
    'completions' => 'int',
    'manual_selector' => 'boolean',
    'parallelism' => 'int',
    'selector' => 'V1LabelSelector',
    'template' => 'V1PodTemplateSpec',
    'ttl_seconds_after_finished' => 'int'
} );

__PACKAGE__->attribute_map( {
    'active_deadline_seconds' => 'activeDeadlineSeconds',
    'backoff_limit' => 'backoffLimit',
    'completions' => 'completions',
    'manual_selector' => 'manualSelector',
    'parallelism' => 'parallelism',
    'selector' => 'selector',
    'template' => 'template',
    'ttl_seconds_after_finished' => 'ttlSecondsAfterFinished'
} );

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


1;
