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

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::V1beta1CustomResourceColumnDefinition;
use Kubernetes::Object::V1beta1CustomResourceConversion;
use Kubernetes::Object::V1beta1CustomResourceDefinitionNames;
use Kubernetes::Object::V1beta1CustomResourceDefinitionVersion;
use Kubernetes::Object::V1beta1CustomResourceSubresources;
use Kubernetes::Object::V1beta1CustomResourceValidation;

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


#
#CustomResourceDefinitionSpec describes how a user wants their resource to appear
#
# 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 => 'CustomResourceDefinitionSpec describes how a user wants their resource to appear',
                                  class => 'V1beta1CustomResourceDefinitionSpec',
                                  required => [], # TODO
}                                 );

__PACKAGE__->method_documentation({
    'additional_printer_columns' => {
    	datatype => 'ARRAY[V1beta1CustomResourceColumnDefinition]',
    	base_name => 'additionalPrinterColumns',
    	description => 'AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column. Optional, the global columns for all versions. Top-level and per-version columns are mutually exclusive.',
    	format => '',
    	read_only => '',
    		},
    'conversion' => {
    	datatype => 'V1beta1CustomResourceConversion',
    	base_name => 'conversion',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'group' => {
    	datatype => 'string',
    	base_name => 'group',
    	description => 'Group is the group this resource belongs in',
    	format => '',
    	read_only => '',
    		},
    'names' => {
    	datatype => 'V1beta1CustomResourceDefinitionNames',
    	base_name => 'names',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'scope' => {
    	datatype => 'string',
    	base_name => 'scope',
    	description => 'Scope indicates whether this resource is cluster or namespace scoped.  Default is namespaced',
    	format => '',
    	read_only => '',
    		},
    'subresources' => {
    	datatype => 'V1beta1CustomResourceSubresources',
    	base_name => 'subresources',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'validation' => {
    	datatype => 'V1beta1CustomResourceValidation',
    	base_name => 'validation',
    	description => '',
    	format => '',
    	read_only => '',
    		},
    'version' => {
    	datatype => 'string',
    	base_name => 'version',
    	description => 'Version is the version this resource belongs in Should be always first item in Versions field if provided. Optional, but at least one of Version or Versions must be set. Deprecated: Please use &#x60;Versions&#x60;.',
    	format => '',
    	read_only => '',
    		},
    'versions' => {
    	datatype => 'ARRAY[V1beta1CustomResourceDefinitionVersion]',
    	base_name => 'versions',
    	description => 'Versions is the list of all supported versions for this resource. If Version field is provided, this field is optional. Validation: All versions must use the same validation schema for now. i.e., top level Validation field is applied to all of these versions. Order: The version name will be used to compute the order. If the version string is \&quot;kube-like\&quot;, it will sort above non \&quot;kube-like\&quot; version strings, which are ordered lexicographically. \&quot;Kube-like\&quot; versions start with a \&quot;v\&quot;, then are followed by a number (the major version), then optionally the string \&quot;alpha\&quot; or \&quot;beta\&quot; and another number (the minor version). These are sorted first by GA &gt; beta &gt; alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major version, then minor version. An example sorted list of versions: v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10.',
    	format => '',
    	read_only => '',
    		},
});

__PACKAGE__->openapi_types( {
    'additional_printer_columns' => 'ARRAY[V1beta1CustomResourceColumnDefinition]',
    'conversion' => 'V1beta1CustomResourceConversion',
    'group' => 'string',
    'names' => 'V1beta1CustomResourceDefinitionNames',
    'scope' => 'string',
    'subresources' => 'V1beta1CustomResourceSubresources',
    'validation' => 'V1beta1CustomResourceValidation',
    'version' => 'string',
    'versions' => 'ARRAY[V1beta1CustomResourceDefinitionVersion]'
} );

__PACKAGE__->attribute_map( {
    'additional_printer_columns' => 'additionalPrinterColumns',
    'conversion' => 'conversion',
    'group' => 'group',
    'names' => 'names',
    'scope' => 'scope',
    'subresources' => 'subresources',
    'validation' => 'validation',
    'version' => 'version',
    'versions' => 'versions'
} );

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


1;
