| 1 | =begin comment | ||
| 2 | |||
| 3 | QueryBuilderApi | ||
| 4 | |||
| 5 | Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/. | ||
| 6 | |||
| 7 | OpenAPI spec version: 1.1.8 | ||
| 8 | Contact: support@activedbsoft.com | ||
| 9 | Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
| 10 | |||
| 11 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 12 | you may not use this file except in compliance with the License. | ||
| 13 | You may obtain a copy of the License at | ||
| 14 | |||
| 15 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 16 | |||
| 17 | Unless required by applicable law or agreed to in writing, software | ||
| 18 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 20 | See the License for the specific language governing permissions and | ||
| 21 | limitations under the License. | ||
| 22 | |||
| 23 | =end comment | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | # | ||
| 28 | # NOTE: This class is auto generated by the swagger code generator program. | ||
| 29 | # Do not edit the class manually. | ||
| 30 | # Ref: https://github.com/swagger-api/swagger-codegen | ||
| 31 | # | ||
| 32 | package SQL::QueryBuilder::WebApi::Object::Condition; | ||
| 33 | |||
| 34 | require 5.6.0; | ||
| 35 | use strict; | ||
| 36 | use warnings; | ||
| 37 | use utf8; | ||
| 38 | use JSON qw(decode_json); | ||
| 39 | use Data::Dumper; | ||
| 40 | use Module::Runtime qw(use_module); | ||
| 41 | use Log::Any qw($log); | ||
| 42 | use Date::Parse; | ||
| 43 | use DateTime; | ||
| 44 | |||
| 45 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 46 | |||
| 47 | |||
| 48 | # | ||
| 49 | #Defines a constraint for original query resultset values. | ||
| 50 | # | ||
| 51 | # NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. | ||
| 52 | # REF: https://github.com/swagger-api/swagger-codegen | ||
| 53 | # | ||
| 54 | |||
| 55 | =begin comment | ||
| 56 | |||
| 57 | QueryBuilderApi | ||
| 58 | |||
| 59 | Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/. | ||
| 60 | |||
| 61 | OpenAPI spec version: 1.1.8 | ||
| 62 | Contact: support@activedbsoft.com | ||
| 63 | Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
| 64 | |||
| 65 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 66 | you may not use this file except in compliance with the License. | ||
| 67 | You may obtain a copy of the License at | ||
| 68 | |||
| 69 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 70 | |||
| 71 | Unless required by applicable law or agreed to in writing, software | ||
| 72 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 73 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 74 | See the License for the specific language governing permissions and | ||
| 75 | limitations under the License. | ||
| 76 | |||
| 77 | =end comment | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | # | ||
| 82 | # NOTE: This class is auto generated by the swagger code generator program. | ||
| 83 | # Do not edit the class manually. | ||
| 84 | # Ref: https://github.com/swagger-api/swagger-codegen | ||
| 85 | # | ||
| 86 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 87 | __PACKAGE__->mk_classdata('swagger_types' => {}); | ||
| 88 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 89 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 90 | |||
| 91 | # new object | ||
| 92 | sub new { | ||
| 93 | my ($class, %args) = @_; | ||
| 94 | |||
| 95 | my $self = bless {}, $class; | ||
| 96 | |||
| 97 | foreach my $attribute (keys %{$class->attribute_map}) { | ||
| 98 | my $args_key = $class->attribute_map->{$attribute}; | ||
| 99 | $self->$attribute( $args{ $args_key } ); | ||
| 100 | } | ||
| 101 | |||
| 102 | return $self; | ||
| 103 | } | ||
| 104 | |||
| 105 | # return perl hash | ||
| 106 | sub to_hash { | ||
| 107 | return decode_json(JSON->new->convert_blessed->encode( shift )); | ||
| 108 | } | ||
| 109 | |||
| 110 | # used by JSON for serialization | ||
| 111 | sub TO_JSON { | ||
| 112 | my $self = shift; | ||
| 113 | my $_data = {}; | ||
| 114 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 115 | if (defined $self->{$_key}) { | ||
| 116 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 117 | } | ||
| 118 | } | ||
| 119 | return $_data; | ||
| 120 | } | ||
| 121 | |||
| 122 | # from Perl hashref | ||
| 123 | sub from_hash { | ||
| 124 | my ($self, $hash) = @_; | ||
| 125 | |||
| 126 | # loop through attributes and use swagger_types to deserialize the data | ||
| 127 | while ( my ($_key, $_type) = each %{$self->swagger_types} ) { | ||
| 128 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 129 | if ($_type =~ /^array\[/i) { # array | ||
| 130 | my $_subclass = substr($_type, 6, -1); | ||
| 131 | my @_array = (); | ||
| 132 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 133 | push @_array, $self->_deserialize($_subclass, $_element); | ||
| 134 | } | ||
| 135 | $self->{$_key} = \@_array; | ||
| 136 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 137 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); | ||
| 138 | } else { | ||
| 139 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | return $self; | ||
| 144 | } | ||
| 145 | |||
| 146 | # deserialize non-array data | ||
| 147 | sub _deserialize { | ||
| 148 | my ($self, $type, $data) = @_; | ||
| 149 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 150 | |||
| 151 | if ($type eq 'DateTime') { | ||
| 152 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 153 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 154 | return $data; | ||
| 155 | } else { # hash(model) | ||
| 156 | my $_instance = eval "SQL::QueryBuilder::WebApi::Object::$type->new()"; | ||
| 157 | return $_instance->from_hash($data); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | |||
| 162 | |||
| 163 | __PACKAGE__->class_documentation({description => 'Defines a constraint for original query resultset values.', | ||
| 164 | class => 'Condition', | ||
| 165 | required => [], # TODO | ||
| 166 | } ); | ||
| 167 | |||
| 168 | __PACKAGE__->method_documentation({ | ||
| 169 | 'field' => { | ||
| 170 | datatype => 'string', | ||
| 171 | base_name => 'field', | ||
| 172 | description => 'Column of original query to which a constraint will applied.', | ||
| 173 | format => '', | ||
| 174 | read_only => '', | ||
| 175 | }, | ||
| 176 | 'condition_operator' => { | ||
| 177 | datatype => 'string', | ||
| 178 | base_name => 'conditionOperator', | ||
| 179 | description => 'Condition operator.', | ||
| 180 | format => '', | ||
| 181 | read_only => '', | ||
| 182 | }, | ||
| 183 | 'values' => { | ||
| 184 | datatype => 'ARRAY[string]', | ||
| 185 | base_name => 'values', | ||
| 186 | description => 'List of values for a constraint. 'IsNull', 'IsNotNull' need no values; 'Between', 'NotBetween' require 2 values; 'In' accepts one or more values; other conditions accept single value only.', | ||
| 187 | format => '', | ||
| 188 | read_only => '', | ||
| 189 | }, | ||
| 190 | }); | ||
| 191 | |||
| 192 | __PACKAGE__->swagger_types( { | ||
| 193 | 'field' => 'string', | ||
| 194 | 'condition_operator' => 'string', | ||
| 195 | 'values' => 'ARRAY[string]' | ||
| 196 | } ); | ||
| 197 | |||
| 198 | __PACKAGE__->attribute_map( { | ||
| 199 | 'field' => 'field', | ||
| 200 | 'condition_operator' => 'conditionOperator', | ||
| 201 | 'values' => 'values' | ||
| 202 | } ); | ||
| 203 | |||
| 204 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 205 | |||
| 206 | |||
| 207 | 1; |