Hide Show 12 lines of Pod
require
5.6.0;
use
base (
"Class::Accessor"
,
"Class::Data::Inheritable"
);
Hide Show 13 lines of Pod
__PACKAGE__->mk_classdata(
'attribute_map'
=> {});
__PACKAGE__->mk_classdata(
'openapi_types'
=> {});
__PACKAGE__->mk_classdata(
'method_documentation'
=> {});
__PACKAGE__->mk_classdata(
'class_documentation'
=> {});
__PACKAGE__->mk_classdata(
'openapi_nullable'
=> {});
sub
new {
my
(
$class
,
%args
) =
@_
;
my
$self
=
bless
{},
$class
;
$self
->init(
%args
);
return
$self
;
}
sub
init
{
my
(
$self
,
%args
) =
@_
;
foreach
my
$attribute
(
keys
%{
$self
->attribute_map}) {
my
$args_key
=
$self
->attribute_map->{
$attribute
};
$self
->
$attribute
(
$args
{
$args_key
} );
}
}
sub
to_hash {
my
$self
=
shift
;
my
$_hash
= decode_json(JSON()->new->allow_blessed->convert_blessed->encode(
$self
));
return
$_hash
;
}
sub
TO_JSON {
my
$self
=
shift
;
my
$_data
= {};
foreach
my
$_key
(
keys
%{
$self
->attribute_map}) {
$_data
->{
$self
->attribute_map->{
$_key
}} =
$self
->{
$_key
};
}
return
$_data
;
}
sub
from_hash {
my
(
$self
,
$hash
) =
@_
;
while
(
my
(
$_key
,
$_type
) =
each
%{
$self
->openapi_types} ) {
my
$_json_attribute
=
$self
->attribute_map->{
$_key
};
my
$_is_nullable
= (
$self
->openapi_nullable->{
$_key
} ||
'false'
) eq
'true'
;
if
(
$_type
=~ /^array\[(.+)\]$/i) {
my
$_subclass
= $1;
my
@_array
= ();
foreach
my
$_element
(@{
$hash
->{
$_json_attribute
}}) {
push
@_array
,
$self
->_deserialize(
$_subclass
,
$_element
,
$_is_nullable
);
}
$self
->{
$_key
} = \
@_array
;
}
elsif
(
$_type
=~ /^hash\[string,(.+)\]$/i) {
my
$_subclass
= $1;
my
%_hash
= ();
while
(
my
(
$_key
,
$_element
) =
each
%{
$hash
->{
$_json_attribute
}}) {
$_hash
{
$_key
} =
$self
->_deserialize(
$_subclass
,
$_element
,
$_is_nullable
);
}
$self
->{
$_key
} = \
%_hash
;
}
elsif
(
exists
$hash
->{
$_json_attribute
}) {
$self
->{
$_key
} =
$self
->_deserialize(
$_type
,
$hash
->{
$_json_attribute
},
$_is_nullable
);
}
else
{
$log
->debugf(
"Warning: %s (%s) does not exist in input hash\n"
,
$_key
,
$_json_attribute
);
}
}
return
$self
;
}
sub
_deserialize {
my
(
$self
,
$type
,
$data
,
$is_nullable
) =
@_
;
$log
->debugf(
"deserializing %s with %s"
,Dumper(
$data
),
$type
);
if
(!(
defined
$data
) &&
$is_nullable
) {
return
undef
;
}
if
(
$type
eq
'DateTime'
) {
return
DateTime->from_epoch(
epoch
=> str2time(
$data
));
}
elsif
(
grep
( /^
$type
$/, (
'int'
,
'double'
,
'string'
,
'boolean'
))) {
return
$data
;
}
else
{
my
$_instance
=
eval
"WebService::Fastly::Object::$type->new()"
;
return
$_instance
->from_hash(
$data
);
}
}
__PACKAGE__->class_documentation({
description
=>
''
,
class
=>
'SnippetResponse'
,
required
=> [],
} );
__PACKAGE__->method_documentation({
'name'
=> {
datatype
=>
'string'
,
base_name
=>
'name'
,
description
=>
'The name for the snippet.'
,
format
=>
''
,
read_only
=>
'false'
,
},
'type'
=> {
datatype
=>
'string'
,
base_name
=>
'type'
,
description
=>
'The location in generated VCL where the snippet should be placed.'
,
format
=>
''
,
read_only
=>
'false'
,
},
'content'
=> {
datatype
=>
'string'
,
base_name
=>
'content'
,
description
=>
'The VCL code that specifies exactly what the snippet does.'
,
format
=>
''
,
read_only
=>
'false'
,
},
'priority'
=> {
datatype
=>
'string'
,
base_name
=>
'priority'
,
description
=>
'Priority determines execution order. Lower numbers execute first.'
,
format
=>
''
,
read_only
=>
'false'
,
},
'dynamic'
=> {
datatype
=>
'string'
,
base_name
=>
'dynamic'
,
description
=>
'Sets the snippet version.'
,
format
=>
''
,
read_only
=>
'false'
,
},
'created_at'
=> {
datatype
=>
'DateTime'
,
base_name
=>
'created_at'
,
description
=>
'Date and time in ISO 8601 format.'
,
format
=>
'date-time'
,
read_only
=>
'true'
,
},
'deleted_at'
=> {
datatype
=>
'DateTime'
,
base_name
=>
'deleted_at'
,
description
=>
'Date and time in ISO 8601 format.'
,
format
=>
'date-time'
,
read_only
=>
'true'
,
},
'updated_at'
=> {
datatype
=>
'DateTime'
,
base_name
=>
'updated_at'
,
description
=>
'Date and time in ISO 8601 format.'
,
format
=>
'date-time'
,
read_only
=>
'true'
,
},
'service_id'
=> {
datatype
=>
'string'
,
base_name
=>
'service_id'
,
description
=>
''
,
format
=>
''
,
read_only
=>
'true'
,
},
'version'
=> {
datatype
=>
'string'
,
base_name
=>
'version'
,
description
=>
'String representing the number identifying a version of the service.'
,
format
=>
''
,
read_only
=>
'true'
,
},
'id'
=> {
datatype
=>
'string'
,
base_name
=>
'id'
,
description
=>
''
,
format
=>
''
,
read_only
=>
'true'
,
},
});
__PACKAGE__->openapi_types( {
'name'
=>
'string'
,
'type'
=>
'string'
,
'content'
=>
'string'
,
'priority'
=>
'string'
,
'dynamic'
=>
'string'
,
'created_at'
=>
'DateTime'
,
'deleted_at'
=>
'DateTime'
,
'updated_at'
=>
'DateTime'
,
'service_id'
=>
'string'
,
'version'
=>
'string'
,
'id'
=>
'string'
} );
__PACKAGE__->attribute_map( {
'name'
=>
'name'
,
'type'
=>
'type'
,
'content'
=>
'content'
,
'priority'
=>
'priority'
,
'dynamic'
=>
'dynamic'
,
'created_at'
=>
'created_at'
,
'deleted_at'
=>
'deleted_at'
,
'updated_at'
=>
'updated_at'
,
'service_id'
=>
'service_id'
,
'version'
=>
'version'
,
'id'
=>
'id'
} );
__PACKAGE__->mk_accessors(
keys
%{__PACKAGE__->attribute_map});
__PACKAGE__->openapi_nullable( {
'created_at'
=>
'true'
,
'deleted_at'
=>
'true'
,
'updated_at'
=>
'true'
,
} );
1;