Debian Codegraph @

lib/3rdParty/composer/aws/aws-crt-php/src/AWS/CRT/CRT.php

raw symbols SCIP
1 <?php
2 /**
3 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 * SPDX-License-Identifier: Apache-2.0.
5 */
6 namespace AWS\CRT;
7
8 use AWS\CRT\Internal\Extension;
9
10 use \RuntimeException;
11
12 /**
13 * Wrapper for the interface to the CRT. There only ever needs to be one of these, but
14 * additional instances won't cost anything other than their memory.
15 * Creating an instance of any NativeResource will activate the CRT binding. User code
16 * should only need to create one of these if they are only accessing CRT:: static functions.
17 */
18 final class CRT {
19
20 private static $impl = null;
21 private static $refcount = 0;
22
23 function __construct() {
24 if (is_null(self::$impl)) {
25 try {
26 self::$impl = new Extension();
27 } catch (RuntimeException $rex) {
28 throw new RuntimeException("Unable to initialize AWS CRT via awscrt extension: \n$rex", -1);
29 }
30 }
31 ++self::$refcount;
32 }
33
34 function __destruct() {
35 if (--self::$refcount == 0) {
36 self::$impl = null;
37 }
38 }
39
40 /**
41 * @return bool whether or not the CRT is currently loaded
42 */
43 public static function isLoaded() {
44 return !is_null(self::$impl);
45 }
46
47 /**
48 * @return bool whether or not the CRT is available via one of the possible backends
49 */
50 public static function isAvailable() {
51 try {
52 new CRT();
53 return true;
54 } catch (RuntimeException $ex) {
55 return false;
56 }
57 }
58
59 /**
60 * @return integer last error code reported within the CRT
61 */
62 public static function last_error() {
63 return self::$impl->aws_crt_last_error();
64 }
65
66 /**
67 * @param integer $error Error code from the CRT, usually delivered via callback or {@see last_error}
68 * @return string Human-readable description of the provided error code
69 */
70 public static function error_str($error) {
71 return self::$impl->aws_crt_error_str((int) $error);
72 }
73
74 /**
75 * @param integer $error Error code from the CRT, usually delivered via callback or {@see last_error}
76 * @return string Name/enum identifier for the provided error code
77 */
78 public static function error_name($error) {
79 return self::$impl->aws_crt_error_name((int) $error);
80 }
81
82 public static function log_to_stdout() {
83 return self::$impl->aws_crt_log_to_stdout();
84 }
85
86 public static function log_to_stderr() {
87 return self::$impl->aws_crt_log_to_stderr();
88 }
89
90 public static function log_to_file($filename) {
91 return self::$impl->aws_crt_log_to_file($filename);
92 }
93
94 public static function log_to_stream($stream) {
95 return self::$impl->aws_crt_log_to_stream($stream);
96 }
97
98 public static function log_set_level($level) {
99 return self::$impl->aws_crt_log_set_level($level);
100 }
101
102 public static function log_stop() {
103 return self::$impl->aws_crt_log_stop();
104 }
105
106 public static function log_message($level, $message) {
107 return self::$impl->aws_crt_log_message($level, $message);
108 }
109
110 /**
111 * @return object Pointer to native event_loop_group_options
112 */
113 function event_loop_group_options_new() {
114 return self::$impl->aws_crt_event_loop_group_options_new();
115 }
116
117 /**
118 * @param object $elg_options Pointer to native event_loop_group_options
119 */
120 function event_loop_group_options_release($elg_options) {
121 self::$impl->aws_crt_event_loop_group_options_release($elg_options);
122 }
123
124 /**
125 * @param object $elg_options Pointer to native event_loop_group_options
126 * @param integer $max_threads Maximum number of threads to allow the event loop group to use, default: 0/1 per CPU core
127 */
128 function event_loop_group_options_set_max_threads($elg_options, $max_threads) {
129 self::$impl->aws_crt_event_loop_group_options_set_max_threads($elg_options, (int)$max_threads);
130 }
131
132 /**
133 * @param object Pointer to event_loop_group_options, {@see event_loop_group_options_new}
134 * @return object Pointer to the new event loop group
135 */
136 function event_loop_group_new($options) {
137 return self::$impl->aws_crt_event_loop_group_new($options);
138 }
139
140 /**
141 * @param object $elg Pointer to the event loop group to release
142 */
143 function event_loop_group_release($elg) {
144 self::$impl->aws_crt_event_loop_group_release($elg);
145 }
146
147 /**
148 * return object Pointer to native AWS credentials options
149 */
150 function aws_credentials_options_new() {
151 return self::$impl->aws_crt_credentials_options_new();
152 }
153
154 function aws_credentials_options_release($options) {
155 self::$impl->aws_crt_credentials_options_release($options);
156 }
157
158 function aws_credentials_options_set_access_key_id($options, $access_key_id) {
159 self::$impl->aws_crt_credentials_options_set_access_key_id($options, $access_key_id);
160 }
161
162 function aws_credentials_options_set_secret_access_key($options, $secret_access_key) {
163 self::$impl->aws_crt_credentials_options_set_secret_access_key($options, $secret_access_key);
164 }
165
166 function aws_credentials_options_set_session_token($options, $session_token) {
167 self::$impl->aws_crt_credentials_options_set_session_token($options, $session_token);
168 }
169
170 function aws_credentials_options_set_expiration_timepoint_seconds($options, $expiration_timepoint_seconds) {
171 self::$impl->aws_crt_credentials_options_set_expiration_timepoint_seconds($options, $expiration_timepoint_seconds);
172 }
173
174 function aws_credentials_new($options) {
175 return self::$impl->aws_crt_credentials_new($options);
176 }
177
178 function aws_credentials_release($credentials) {
179 self::$impl->aws_crt_credentials_release($credentials);
180 }
181
182 function credentials_provider_release($provider) {
183 self::$impl->aws_crt_credentials_provider_release($provider);
184 }
185
186 function credentials_provider_static_options_new() {
187 return self::$impl->aws_crt_credentials_provider_static_options_new();
188 }
189
190 function credentials_provider_static_options_release($options) {
191 self::$impl->aws_crt_credentials_provider_static_options_release($options);
192 }
193
194 function credentials_provider_static_options_set_access_key_id($options, $access_key_id) {
195 self::$impl->aws_crt_credentials_provider_static_options_set_access_key_id($options, $access_key_id);
196 }
197
198 function credentials_provider_static_options_set_secret_access_key($options, $secret_access_key) {
199 self::$impl->aws_crt_credentials_provider_static_options_set_secret_access_key($options, $secret_access_key);
200 }
201
202 function credentials_provider_static_options_set_session_token($options, $session_token) {
203 self::$impl->aws_crt_credentials_provider_static_options_set_session_token($options, $session_token);
204 }
205
206 function credentials_provider_static_new($options) {
207 return self::$impl->aws_crt_credentials_provider_static_new($options);
208 }
209
210 function input_stream_options_new() {
211 return self::$impl->aws_crt_input_stream_options_new();
212 }
213
214 function input_stream_options_release($options) {
215 self::$impl->aws_crt_input_stream_options_release($options);
216 }
217
218 function input_stream_options_set_user_data($options, $user_data) {
219 self::$impl->aws_crt_input_stream_options_set_user_data($options, $user_data);
220 }
221
222 function input_stream_new($options) {
223 return self::$impl->aws_crt_input_stream_new($options);
224 }
225
226 function input_stream_release($stream) {
227 self::$impl->aws_crt_input_stream_release($stream);
228 }
229
230 function input_stream_seek($stream, $offset, $basis) {
231 return self::$impl->aws_crt_input_stream_seek($stream, $offset, $basis);
232 }
233
234 function input_stream_read($stream, $length) {
235 return self::$impl->aws_crt_input_stream_read($stream, $length);
236 }
237
238 function input_stream_eof($stream) {
239 return self::$impl->aws_crt_input_stream_eof($stream);
240 }
241
242 function input_stream_get_length($stream) {
243 return self::$impl->aws_crt_input_stream_get_length($stream);
244 }
245
246 function http_message_new_from_blob($blob) {
247 return self::$impl->aws_crt_http_message_new_from_blob($blob);
248 }
249
250 function http_message_to_blob($message) {
251 return self::$impl->aws_crt_http_message_to_blob($message);
252 }
253
254 function http_message_release($message) {
255 self::$impl->aws_crt_http_message_release($message);
256 }
257
258 function signing_config_aws_new() {
259 return self::$impl->aws_crt_signing_config_aws_new();
260 }
261
262 function signing_config_aws_release($signing_config) {
263 return self::$impl->aws_crt_signing_config_aws_release($signing_config);
264 }
265
266 function signing_config_aws_set_algorithm($signing_config, $algorithm) {
267 self::$impl->aws_crt_signing_config_aws_set_algorithm($signing_config, (int)$algorithm);
268 }
269
270 function signing_config_aws_set_signature_type($signing_config, $signature_type) {
271 self::$impl->aws_crt_signing_config_aws_set_signature_type($signing_config, (int)$signature_type);
272 }
273
274 function signing_config_aws_set_credentials_provider($signing_config, $credentials_provider) {
275 self::$impl->aws_crt_signing_config_aws_set_credentials_provider($signing_config, $credentials_provider);
276 }
277
278 function signing_config_aws_set_region($signing_config, $region) {
279 self::$impl->aws_crt_signing_config_aws_set_region($signing_config, $region);
280 }
281
282 function signing_config_aws_set_service($signing_config, $service) {
283 self::$impl->aws_crt_signing_config_aws_set_service($signing_config, $service);
284 }
285
286 function signing_config_aws_set_use_double_uri_encode($signing_config, $use_double_uri_encode) {
287 self::$impl->aws_crt_signing_config_aws_set_use_double_uri_encode($signing_config, $use_double_uri_encode);
288 }
289
290 function signing_config_aws_set_should_normalize_uri_path($signing_config, $should_normalize_uri_path) {
291 self::$impl->aws_crt_signing_config_aws_set_should_normalize_uri_path($signing_config, $should_normalize_uri_path);
292 }
293
294 function signing_config_aws_set_omit_session_token($signing_config, $omit_session_token) {
295 self::$impl->aws_crt_signing_config_aws_set_omit_session_token($signing_config, $omit_session_token);
296 }
297
298 function signing_config_aws_set_signed_body_value($signing_config, $signed_body_value) {
299 self::$impl->aws_crt_signing_config_aws_set_signed_body_value($signing_config, $signed_body_value);
300 }
301
302 function signing_config_aws_set_signed_body_header_type($signing_config, $signed_body_header_type) {
303 self::$impl->aws_crt_signing_config_aws_set_signed_body_header_type($signing_config, $signed_body_header_type);
304 }
305
306 function signing_config_aws_set_expiration_in_seconds($signing_config, $expiration_in_seconds) {
307 self::$impl->aws_crt_signing_config_aws_set_expiration_in_seconds($signing_config, $expiration_in_seconds);
308 }
309
310 function signing_config_aws_set_date($signing_config, $timestamp) {
311 self::$impl->aws_crt_signing_config_aws_set_date($signing_config, $timestamp);
312 }
313
314 function signing_config_aws_set_should_sign_header_fn($signing_config, $should_sign_header_fn) {
315 self::$impl->aws_crt_signing_config_aws_set_should_sign_header_fn($signing_config, $should_sign_header_fn);
316 }
317
318 function signable_new_from_http_request($http_message) {
319 return self::$impl->aws_crt_signable_new_from_http_request($http_message);
320 }
321
322 function signable_new_from_chunk($chunk_stream, $previous_signature) {
323 return self::$impl->aws_crt_signable_new_from_chunk($chunk_stream, $previous_signature);
324 }
325
326 function signable_new_from_canonical_request($canonical_request) {
327 return self::$impl->aws_crt_signable_new_from_canonical_request($canonical_request);
328 }
329
330 function signable_release($signable) {
331 self::$impl->aws_crt_signable_release($signable);
332 }
333
334 function signing_result_release($signing_result) {
335 self::$impl->aws_crt_signing_result_release($signing_result);
336 }
337
338 function signing_result_apply_to_http_request($signing_result, $http_message) {
339 return self::$impl->aws_crt_signing_result_apply_to_http_request(
340 $signing_result, $http_message);
341 }
342
343 function sign_request_aws($signable, $signing_config, $on_complete, $user_data) {
344 return self::$impl->aws_crt_sign_request_aws($signable, $signing_config, $on_complete, $user_data);
345 }
346
347 function test_verify_sigv4a_signing($signable, $signing_config, $expected_canonical_request, $signature, $ecc_key_pub_x, $ecc_key_pub_y) {
348 return self::$impl->aws_crt_test_verify_sigv4a_signing($signable, $signing_config, $expected_canonical_request, $signature, $ecc_key_pub_x, $ecc_key_pub_y);
349 }
350
351 public static function crc32($input, $previous = 0) {
352 return self::$impl->aws_crt_crc32($input, $previous);
353 }
354
355 public static function crc32c($input, $previous = 0) {
356 return self::$impl->aws_crt_crc32c($input, $previous);
357 }
358 }