| 1 | =begin comment | ||
| 2 | |||
| 3 | Aspose.Diagram Cloud API Reference | ||
| 4 | |||
| 5 | No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| 6 | |||
| 7 | OpenAPI spec version: 3.0 | ||
| 8 | |||
| 9 | Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
| 10 | |||
| 11 | =end comment | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | # | ||
| 16 | # NOTE: This class is auto generated by the swagger code generator program. | ||
| 17 | # Do not edit the class manually. | ||
| 18 | # Ref: https://github.com/swagger-api/swagger-codegen | ||
| 19 | # | ||
| 20 | package AsposeDiagramCloud::Configuration; | ||
| 21 | |||
| 22 | use strict; | ||
| 23 | use warnings; | ||
| 24 | use utf8; | ||
| 25 | |||
| 26 | use Log::Any qw($log); | ||
| 27 | use Carp; | ||
| 28 | |||
| 29 | use constant VERSION => '20.3'; | ||
| 30 | |||
| 31 | =head1 Name | ||
| 32 | |||
| 33 | AsposeDiagramCloud::Configuration - holds the configuration for all AsposeDiagramCloud Modules | ||
| 34 | |||
| 35 | =head1 new(%parameters) | ||
| 36 | |||
| 37 | =over 4 | ||
| 38 | |||
| 39 | =item http_timeout: (optional) | ||
| 40 | |||
| 41 | Integer. timeout for HTTP requests in seconds | ||
| 42 | |||
| 43 | default: 180 | ||
| 44 | |||
| 45 | =item http_user_agent: (optional) | ||
| 46 | |||
| 47 | String. custom UserAgent header | ||
| 48 | |||
| 49 | default: Swagger-Codegen/20.3/perl | ||
| 50 | |||
| 51 | =item api_key: (optional) | ||
| 52 | |||
| 53 | Hashref. Keyed on the name of each key (there can be multiple tokens). | ||
| 54 | |||
| 55 | api_key => { | ||
| 56 | secretKey => 'aaaabbbbccccdddd', | ||
| 57 | anotherKey => '1111222233334444', | ||
| 58 | }; | ||
| 59 | |||
| 60 | =item api_key_prefix: (optional) | ||
| 61 | |||
| 62 | Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. | ||
| 63 | |||
| 64 | api_key_prefix => { | ||
| 65 | secretKey => 'string', | ||
| 66 | anotherKey => 'same or some other string', | ||
| 67 | }; | ||
| 68 | |||
| 69 | =item api_key_in: (optional) | ||
| 70 | |||
| 71 | =item username: (optional) | ||
| 72 | |||
| 73 | String. The username for basic auth. | ||
| 74 | |||
| 75 | =item password: (optional) | ||
| 76 | |||
| 77 | String. The password for basic auth. | ||
| 78 | |||
| 79 | =item access_token: (optional) | ||
| 80 | |||
| 81 | String. The OAuth access token. | ||
| 82 | |||
| 83 | =item base_url: (optional) | ||
| 84 | |||
| 85 | String. The base URL of the API | ||
| 86 | |||
| 87 | default: https://api.aspose.cloud/v3.0 | ||
| 88 | =item app_sid: (optional) | ||
| 89 | String. Application SID. | ||
| 90 | |||
| 91 | =item app_key: (optional) | ||
| 92 | String. Application Key. | ||
| 93 | |||
| 94 | =item api_version:(optional) | ||
| 95 | String. api version. | ||
| 96 | default: v3.0 | ||
| 97 | |||
| 98 | =back | ||
| 99 | |||
| 100 | =cut | ||
| 101 | |||
| 102 | sub new { | ||
| 103 | my ($self, %p) = (shift,@_); | ||
| 104 | |||
| 105 | # class/static variables | ||
| 106 | $p{http_timeout} //= 180; | ||
| 107 | $p{http_user_agent} //= 'Swagger-Codegen/20.3/perl'; | ||
| 108 | |||
| 109 | # authentication setting | ||
| 110 | $p{api_key} //= {}; | ||
| 111 | $p{api_key_prefix} //= {}; | ||
| 112 | $p{api_key_in} //= {}; | ||
| 113 | |||
| 114 | # username and password for HTTP basic authentication | ||
| 115 | $p{username} //= ''; | ||
| 116 | $p{password} //= ''; | ||
| 117 | |||
| 118 | # access token for OAuth | ||
| 119 | $p{access_token} //= ''; | ||
| 120 | |||
| 121 | # base_url | ||
| 122 | $p{base_url} //= 'https://api.aspose.cloud/v3.0'; | ||
| 123 | |||
| 124 | return bless \%p => $self; | ||
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | sub get_tokens { | ||
| 129 | my $self = shift; | ||
| 130 | |||
| 131 | my $tokens = {}; | ||
| 132 | $tokens->{username} = $self->{username} if $self->{username}; | ||
| 133 | $tokens->{password} = $self->{password} if $self->{password}; | ||
| 134 | $tokens->{app_sid} = $self->{app_sid} if $self->{app_sid}; | ||
| 135 | $tokens->{app_key} = $self->{app_key} if $self->{app_key}; | ||
| 136 | $tokens->{access_token} = $self->{access_token} if $self->{access_token}; | ||
| 137 | |||
| 138 | |||
| 139 | foreach my $token_name (keys %{ $self->{api_key} }) { | ||
| 140 | $tokens->{$token_name}->{token} = $self->{api_key}{$token_name}; | ||
| 141 | $tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name}; | ||
| 142 | $tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name}; | ||
| 143 | } | ||
| 144 | |||
| 145 | return $tokens; | ||
| 146 | } | ||
| 147 | |||
| 148 | sub clear_tokens { | ||
| 149 | my $self = shift; | ||
| 150 | my %tokens = %{$self->get_tokens}; # copy | ||
| 151 | |||
| 152 | $self->{username} = ''; | ||
| 153 | $self->{password} = ''; | ||
| 154 | $self->{app_sid} = ''; | ||
| 155 | $self->{app_key} = ''; | ||
| 156 | $self->{access_token} = ''; | ||
| 157 | |||
| 158 | $self->{api_key} = {}; | ||
| 159 | $self->{api_key_prefix} = {}; | ||
| 160 | $self->{api_key_in} = {}; | ||
| 161 | |||
| 162 | return \%tokens; | ||
| 163 | } | ||
| 164 | |||
| 165 | sub accept_tokens { | ||
| 166 | my ($self, $tokens) = @_; | ||
| 167 | |||
| 168 | foreach my $known_name (qw(username password access_token)) { | ||
| 169 | next unless $tokens->{$known_name}; | ||
| 170 | $self->{$known_name} = delete $tokens->{$known_name}; | ||
| 171 | } | ||
| 172 | |||
| 173 | foreach my $token_name (keys %$tokens) { | ||
| 174 | $self->{api_key}{$token_name} = $tokens->{$token_name}{token}; | ||
| 175 | if ($tokens->{$token_name}{prefix}) { | ||
| 176 | $self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix}; | ||
| 177 | } | ||
| 178 | my $in = $tokens->{$token_name}->{in} || 'head'; | ||
| 179 | croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/; | ||
| 180 | $self->{api_key_in}{$token_name} = $in; | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | 1; |