From 03ec5809fe73944768f1e69bad8a6db7ecb6874a Mon Sep 17 00:00:00 2001 From: yangpeng Date: Wed, 23 Apr 2025 09:46:01 +0800 Subject: [PATCH] add access point for object process api --- sample/CreateAccessPointForObjectProcess.php | 71 ++ sample/DeleteAccessPointForObjectProcess.php | 50 ++ ...eleteAccessPointPolicyForObjectProcess.php | 48 ++ .../GetAccessPointConfigForObjectProcess.php | 51 ++ sample/GetAccessPointForObjectProcess.php | 51 ++ .../GetAccessPointPolicyForObjectProcess.php | 49 ++ sample/ListAccessPointForObjectProcess.php | 50 ++ .../PutAccessPointConfigForObjectProcess.php | 74 ++ .../PutAccessPointPolicyForObjectProcess.php | 52 ++ sample/WriteGetObjectResponse.php | 57 ++ src/Client.php | 20 + src/Models/AccessPointActions.php | 35 + src/Models/AccessPointForObjectProcess.php | 71 ++ src/Models/AccessPointsForObjectProcess.php | 35 + src/Models/AdditionalFeatures.php | 34 + src/Models/AllowedFeatures.php | 35 + src/Models/ContentTransformation.php | 43 ++ ...cessPointForObjectProcessConfiguration.php | 55 ++ ...eateAccessPointForObjectProcessRequest.php | 60 ++ ...reateAccessPointForObjectProcessResult.php | 44 ++ src/Models/CustomForwardHeaders.php | 34 + ...leteAccessPointForObjectProcessRequest.php | 49 ++ ...eleteAccessPointForObjectProcessResult.php | 15 + ...cessPointPolicyForObjectProcessRequest.php | 49 ++ ...ccessPointPolicyForObjectProcessResult.php | 15 + src/Models/FunctionCompute.php | 44 ++ src/Models/GetAccessPoint.php | 4 +- ...cessPointConfigForObjectProcessRequest.php | 49 ++ ...ccessPointConfigForObjectProcessResult.php | 53 ++ .../GetAccessPointForObjectProcessRequest.php | 49 ++ .../GetAccessPointForObjectProcessResult.php | 123 ++++ ...cessPointPolicyForObjectProcessRequest.php | 49 ++ ...ccessPointPolicyForObjectProcessResult.php | 30 + ...istAccessPointsForObjectProcessRequest.php | 48 ++ ...ListAccessPointsForObjectProcessResult.php | 63 ++ src/Models/ObjectProcessConfiguration.php | 45 ++ ...intConfigForObjectProcessConfiguration.php | 55 ++ ...cessPointConfigForObjectProcessRequest.php | 60 ++ ...ccessPointConfigForObjectProcessResult.php | 15 + ...cessPointPolicyForObjectProcessRequest.php | 60 ++ ...ccessPointPolicyForObjectProcessResult.php | 15 + src/Models/TransformationConfiguration.php | 45 ++ src/Models/TransformationConfigurations.php | 35 + src/Models/WriteGetObjectResponseRequest.php | 164 +++++ src/Models/WriteGetObjectResponseResult.php | 15 + src/Transform/BucketObjectFcAccesspoint.php | 357 ++++++++++ src/Transform/Functions.php | 11 + .../ClientAccessPointForObjectProcessTest.php | 432 +++++++++++ .../BucketObjectFcAccessPointTest.php | 674 ++++++++++++++++++ .../Transform/BucketPublicAccessBlockTest.php | 6 +- 50 files changed, 3643 insertions(+), 5 deletions(-) create mode 100644 sample/CreateAccessPointForObjectProcess.php create mode 100644 sample/DeleteAccessPointForObjectProcess.php create mode 100644 sample/DeleteAccessPointPolicyForObjectProcess.php create mode 100644 sample/GetAccessPointConfigForObjectProcess.php create mode 100644 sample/GetAccessPointForObjectProcess.php create mode 100644 sample/GetAccessPointPolicyForObjectProcess.php create mode 100644 sample/ListAccessPointForObjectProcess.php create mode 100644 sample/PutAccessPointConfigForObjectProcess.php create mode 100644 sample/PutAccessPointPolicyForObjectProcess.php create mode 100644 sample/WriteGetObjectResponse.php create mode 100644 src/Models/AccessPointActions.php create mode 100644 src/Models/AccessPointForObjectProcess.php create mode 100644 src/Models/AccessPointsForObjectProcess.php create mode 100644 src/Models/AdditionalFeatures.php create mode 100644 src/Models/AllowedFeatures.php create mode 100644 src/Models/ContentTransformation.php create mode 100644 src/Models/CreateAccessPointForObjectProcessConfiguration.php create mode 100644 src/Models/CreateAccessPointForObjectProcessRequest.php create mode 100644 src/Models/CreateAccessPointForObjectProcessResult.php create mode 100644 src/Models/CustomForwardHeaders.php create mode 100644 src/Models/DeleteAccessPointForObjectProcessRequest.php create mode 100644 src/Models/DeleteAccessPointForObjectProcessResult.php create mode 100644 src/Models/DeleteAccessPointPolicyForObjectProcessRequest.php create mode 100644 src/Models/DeleteAccessPointPolicyForObjectProcessResult.php create mode 100644 src/Models/FunctionCompute.php create mode 100644 src/Models/GetAccessPointConfigForObjectProcessRequest.php create mode 100644 src/Models/GetAccessPointConfigForObjectProcessResult.php create mode 100644 src/Models/GetAccessPointForObjectProcessRequest.php create mode 100644 src/Models/GetAccessPointForObjectProcessResult.php create mode 100644 src/Models/GetAccessPointPolicyForObjectProcessRequest.php create mode 100644 src/Models/GetAccessPointPolicyForObjectProcessResult.php create mode 100644 src/Models/ListAccessPointsForObjectProcessRequest.php create mode 100644 src/Models/ListAccessPointsForObjectProcessResult.php create mode 100644 src/Models/ObjectProcessConfiguration.php create mode 100644 src/Models/PutAccessPointConfigForObjectProcessConfiguration.php create mode 100644 src/Models/PutAccessPointConfigForObjectProcessRequest.php create mode 100644 src/Models/PutAccessPointConfigForObjectProcessResult.php create mode 100644 src/Models/PutAccessPointPolicyForObjectProcessRequest.php create mode 100644 src/Models/PutAccessPointPolicyForObjectProcessResult.php create mode 100644 src/Models/TransformationConfiguration.php create mode 100644 src/Models/TransformationConfigurations.php create mode 100644 src/Models/WriteGetObjectResponseRequest.php create mode 100644 src/Models/WriteGetObjectResponseResult.php create mode 100644 src/Transform/BucketObjectFcAccesspoint.php create mode 100644 tests/IntegrationTests/ClientAccessPointForObjectProcessTest.php create mode 100644 tests/UnitTests/Transform/BucketObjectFcAccessPointTest.php diff --git a/sample/CreateAccessPointForObjectProcess.php b/sample/CreateAccessPointForObjectProcess.php new file mode 100644 index 0000000..8f299f5 --- /dev/null +++ b/sample/CreateAccessPointForObjectProcess.php @@ -0,0 +1,71 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$accessPointName = "access point name"; +$accountId = "your account id"; +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$arn = "acs:fc:" . $region . ":" . $accountId . ":services/test-oss-fc.LATEST/functions/" . $objectProcessName; +$roleArn = "acs:ram::" . $accountId . ":role/aliyunfcdefaultrole"; +$request = new Oss\Models\CreateAccessPointForObjectProcessRequest($bucket, $objectProcessName); +$request->createAccessPointForObjectProcessConfiguration = new Oss\Models\CreateAccessPointForObjectProcessConfiguration( + accessPointName: $accessPointName, + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn, + ) + ) + )] + ) + ) +); +$result = $client->createAccessPointForObjectProcess($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/sample/DeleteAccessPointForObjectProcess.php b/sample/DeleteAccessPointForObjectProcess.php new file mode 100644 index 0000000..0af2194 --- /dev/null +++ b/sample/DeleteAccessPointForObjectProcess.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DeleteAccessPointForObjectProcessRequest($bucket, $objectProcessName); + +$result = $client->deleteAccessPointForObjectProcess($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/sample/DeleteAccessPointPolicyForObjectProcess.php b/sample/DeleteAccessPointPolicyForObjectProcess.php new file mode 100644 index 0000000..5ca7055 --- /dev/null +++ b/sample/DeleteAccessPointPolicyForObjectProcess.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DeleteAccessPointPolicyForObjectProcessRequest($bucket, $objectProcessName); +$result = $client->deleteAccessPointForObjectProcess($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/sample/GetAccessPointConfigForObjectProcess.php b/sample/GetAccessPointConfigForObjectProcess.php new file mode 100644 index 0000000..b0d31a6 --- /dev/null +++ b/sample/GetAccessPointConfigForObjectProcess.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$result = $client->getAccessPointConfigForObjectProcess(new Oss\Models\GetAccessPointConfigForObjectProcessRequest( + bucket: $bucket, + accessPointForObjectProcessName: $objectProcessName, +)); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/sample/GetAccessPointForObjectProcess.php b/sample/GetAccessPointForObjectProcess.php new file mode 100644 index 0000000..712834e --- /dev/null +++ b/sample/GetAccessPointForObjectProcess.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetAccessPointForObjectProcessRequest($bucket, $objectProcessName); + +$result = $client->getAccessPointForObjectProcess($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/sample/GetAccessPointPolicyForObjectProcess.php b/sample/GetAccessPointPolicyForObjectProcess.php new file mode 100644 index 0000000..1eb54e4 --- /dev/null +++ b/sample/GetAccessPointPolicyForObjectProcess.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetAccessPointPolicyForObjectProcessRequest($bucket, $objectProcessName); +$result = $client->getAccessPointPolicyForObjectProcess($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'policy:' . $result->body +); \ No newline at end of file diff --git a/sample/ListAccessPointForObjectProcess.php b/sample/ListAccessPointForObjectProcess.php new file mode 100644 index 0000000..c2ebee1 --- /dev/null +++ b/sample/ListAccessPointForObjectProcess.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$accessPointName = "access point name"; +$accountId = "your account id"; +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\ListAccessPointsForObjectProcessRequest(); +$result = $client->listAccessPointsForObjectProcess($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/sample/PutAccessPointConfigForObjectProcess.php b/sample/PutAccessPointConfigForObjectProcess.php new file mode 100644 index 0000000..c4cd3a5 --- /dev/null +++ b/sample/PutAccessPointConfigForObjectProcess.php @@ -0,0 +1,74 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$accountId = "your account id"; +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$arn = "acs:fc:" . $region . ":" . $accountId . ":services/test-oss-fc.LATEST/functions/" . $objectProcessName; +$roleArn = "acs:ram::" . $accountId . ":role/aliyunfcdefaultrole"; +$result = $client->putAccessPointConfigForObjectProcess(new Oss\Models\PutAccessPointConfigForObjectProcessRequest( + bucket: $bucket, + accessPointForObjectProcessName: $objectProcessName, + putAccessPointConfigForObjectProcessConfiguration: new Oss\Models\PutAccessPointConfigForObjectProcessConfiguration( + publicAccessBlockConfiguration: new Oss\Models\PublicAccessBlockConfiguration( + blockPublicAccess: true + ), + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [ + new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn + ) + ) + ) + ] + ) + ) + ) +)); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/sample/PutAccessPointPolicyForObjectProcess.php b/sample/PutAccessPointPolicyForObjectProcess.php new file mode 100644 index 0000000..fcb8c08 --- /dev/null +++ b/sample/PutAccessPointPolicyForObjectProcess.php @@ -0,0 +1,52 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$accountId = "your account id"; +$objectProcessName = "access point for object process name"; + +$client = new Oss\Client($cfg); + +$arn = "acs:fc:" . $region . ":" . $accountId . ":services/test-oss-fc.LATEST/functions/" . $objectProcessName; +$policy = '{"Version":"1","Statement":[{"Action":["oss:GetObject"],"Effect":"Allow","Principal":[' . $accountId . '],"Resource":["acs:oss:' . $region . ':' . $accountId . ' :accesspointforobjectprocess/' . $objectProcessName . '/object/*"]}]}'; +$request = new Oss\Models\PutAccessPointPolicyForObjectProcessRequest($bucket, $objectProcessName); +$request->body = $policy; +$result = $client->putAccessPointPolicyForObjectProcess($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/sample/WriteGetObjectResponse.php b/sample/WriteGetObjectResponse.php new file mode 100644 index 0000000..73232e4 --- /dev/null +++ b/sample/WriteGetObjectResponse.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$route = "fc output route"; +$token = "fc output token"; + +$client = new Oss\Client($cfg); + +$img = imagecreatetruecolor(200, 200); +$red = imagecolorallocate($img, 255, 0, 0); +imagefill($img, 0, 0, $red); +ob_start(); +imagepng($img); +$imageData = ob_get_clean(); +imagedestroy($img); + +$request = new Oss\Models\WriteGetObjectResponseRequest($bucket, $route, $token, '200'); +$result = $client->writeGetObjectResponse($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/src/Client.php b/src/Client.php index b1e5e4f..4cf10e4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -274,6 +274,26 @@ * @method \GuzzleHttp\Promise\Promise listBucketInventoryAsync(Models\ListBucketInventoryRequest $request, array $args = []) Queries all inventories in a bucket at a time. * @method Models\DeleteBucketInventoryResult deleteBucketInventory(Models\DeleteBucketInventoryRequest $request, array $args = []) Deletes an inventory for a bucket. * @method \GuzzleHttp\Promise\Promise deleteBucketInventoryAsync(Models\DeleteBucketInventoryRequest $request, array $args = []) Deletes an inventory for a bucket. + * @method Models\CreateAccessPointForObjectProcessResult createAccessPointForObjectProcess(Models\CreateAccessPointForObjectProcessRequest $request, array $args = []) Creates an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise createAccessPointForObjectProcessAsync(Models\CreateAccessPointForObjectProcessRequest $request, array $args = []) Creates an Object FC Access Point. + * @method Models\GetAccessPointForObjectProcessResult getAccessPointForObjectProcess(Models\GetAccessPointForObjectProcessRequest $request, array $args = []) Queries basic information about an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise getAccessPointForObjectProcessAsync(Models\GetAccessPointForObjectProcessRequest $request, array $args = []) Queries basic information about an Object FC Access Point. + * @method Models\ListAccessPointsForObjectProcessResult listAccessPointsForObjectProcess(Models\ListAccessPointsForObjectProcessRequest $request, array $args = []) Lists information about Object FC Access Points in an Alibaba Cloud account. + * @method \GuzzleHttp\Promise\Promise listAccessPointsForObjectProcessAsync(Models\ListAccessPointsForObjectProcessRequest $request, array $args = []) Lists information about Object FC Access Points in an Alibaba Cloud account. + * @method Models\DeleteAccessPointForObjectProcessResult deleteAccessPointForObjectProcess(Models\DeleteAccessPointForObjectProcessRequest $request, array $args = []) Deletes an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise deleteAccessPointForObjectProcessAsync(Models\DeleteAccessPointForObjectProcessRequest $request, array $args = []) Deletes an Object FC Access Point. + * @method Models\GetAccessPointConfigForObjectProcessResult getAccessPointConfigForObjectProcess(Models\GetAccessPointConfigForObjectProcessRequest $request, array $args = []) Queries the configurations of an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise getAccessPointConfigForObjectProcessAsync(Models\GetAccessPointConfigForObjectProcessRequest $request, array $args = []) Queries the configurations of an Object FC Access Point. + * @method Models\PutAccessPointConfigForObjectProcessResult putAccessPointConfigForObjectProcess(Models\PutAccessPointConfigForObjectProcessRequest $request, array $args = []) Changes the configurations of an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise putAccessPointConfigForObjectProcessAsync(Models\PutAccessPointConfigForObjectProcessRequest $request, array $args = []) Changes the configurations of an Object FC Access Point. + * @method Models\PutAccessPointPolicyForObjectProcessResult putAccessPointPolicyForObjectProcess(Models\PutAccessPointPolicyForObjectProcessRequest $request, array $args = []) Configures policies for an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyForObjectProcessAsync(Models\PutAccessPointPolicyForObjectProcessRequest $request, array $args = []) Configures policies for an Object FC Access Point. + * @method Models\GetAccessPointPolicyForObjectProcessResult getAccessPointPolicyForObjectProcess(Models\GetAccessPointPolicyForObjectProcessRequest $request, array $args = []) Queries the policies of an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyForObjectProcessAsync(Models\GetAccessPointPolicyForObjectProcessRequest $request, array $args = []) Queries the policies of an Object FC Access Point. + * @method Models\DeleteAccessPointPolicyForObjectProcessResult deleteAccessPointPolicyForObjectProcess(Models\DeleteAccessPointPolicyForObjectProcessRequest $request, array $args = []) Deletes the policies of an Object FC Access Point. + * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyForObjectProcessAsync(Models\DeleteAccessPointPolicyForObjectProcessRequest $request, array $args = []) Deletes the policies of an Object FC Access Point. + * @method Models\WriteGetObjectResponseResult writeGetObjectResponse(Models\WriteGetObjectResponseRequest $request, array $args = []) WriteGetObjectResponse Customize return data and response headers + * @method \GuzzleHttp\Promise\Promise writeGetObjectResponseAsync(Models\WriteGetObjectResponseRequest $request, array $args = []) WriteGetObjectResponse Customize return data and response headers */ final class Client { diff --git a/src/Models/AccessPointActions.php b/src/Models/AccessPointActions.php new file mode 100644 index 0000000..d15d795 --- /dev/null +++ b/src/Models/AccessPointActions.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Action', type: 'string')] + public ?array $actions; + + /** + * AccessPointActions constructor. + * @param array|null $actions The supported OSS API operations. + */ + public function __construct( + ?array $actions = null + ) + { + $this->actions = $actions; + } +} \ No newline at end of file diff --git a/src/Models/AccessPointForObjectProcess.php b/src/Models/AccessPointForObjectProcess.php new file mode 100644 index 0000000..b5b0b78 --- /dev/null +++ b/src/Models/AccessPointForObjectProcess.php @@ -0,0 +1,71 @@ +accessPointNameForObjectProcess = $accessPointNameForObjectProcess; + $this->accessPointForObjectProcessAlias = $accessPointForObjectProcessAlias; + $this->accessPointName = $accessPointName; + $this->status = $status; + $this->allowAnonymousAccessForObjectProcess = $allowAnonymousAccessForObjectProcess; + } +} \ No newline at end of file diff --git a/src/Models/AccessPointsForObjectProcess.php b/src/Models/AccessPointsForObjectProcess.php new file mode 100644 index 0000000..b9bd24f --- /dev/null +++ b/src/Models/AccessPointsForObjectProcess.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'AccessPointForObjectProcess', type: AccessPointForObjectProcess::class)] + public ?array $accessPointForObjectProcesss; + + /** + * AccessPointsForObjectProcess constructor. + * @param array|null $accessPointForObjectProcesss The container that stores information about a single Object FC Access Point. + */ + public function __construct( + ?array $accessPointForObjectProcesss = null + ) + { + $this->accessPointForObjectProcesss = $accessPointForObjectProcesss; + } +} \ No newline at end of file diff --git a/src/Models/AdditionalFeatures.php b/src/Models/AdditionalFeatures.php new file mode 100644 index 0000000..506da6c --- /dev/null +++ b/src/Models/AdditionalFeatures.php @@ -0,0 +1,34 @@ +customForwardHeaders = $customForwardHeaders; + } +} \ No newline at end of file diff --git a/src/Models/AllowedFeatures.php b/src/Models/AllowedFeatures.php new file mode 100644 index 0000000..00d8cfc --- /dev/null +++ b/src/Models/AllowedFeatures.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'AllowedFeature', type: 'string')] + public ?array $allowedFeatures; + + /** + * AllowedFeatures constructor. + * @param array|null $allowedFeatures Specifies that Function Compute supports Range GetObject requests. + */ + public function __construct( + ?array $allowedFeatures = null + ) + { + $this->allowedFeatures = $allowedFeatures; + } +} \ No newline at end of file diff --git a/src/Models/ContentTransformation.php b/src/Models/ContentTransformation.php new file mode 100644 index 0000000..20bfe8f --- /dev/null +++ b/src/Models/ContentTransformation.php @@ -0,0 +1,43 @@ +functionCompute = $functionCompute; + $this->additionalFeatures = $additionalFeatures; + } +} \ No newline at end of file diff --git a/src/Models/CreateAccessPointForObjectProcessConfiguration.php b/src/Models/CreateAccessPointForObjectProcessConfiguration.php new file mode 100644 index 0000000..e7732be --- /dev/null +++ b/src/Models/CreateAccessPointForObjectProcessConfiguration.php @@ -0,0 +1,55 @@ +allowAnonymousAccessForObjectProcess = $allowAnonymousAccessForObjectProcess; + $this->accessPointName = $accessPointName; + $this->objectProcessConfiguration = $objectProcessConfiguration; + } +} \ No newline at end of file diff --git a/src/Models/CreateAccessPointForObjectProcessRequest.php b/src/Models/CreateAccessPointForObjectProcessRequest.php new file mode 100644 index 0000000..6f675f6 --- /dev/null +++ b/src/Models/CreateAccessPointForObjectProcessRequest.php @@ -0,0 +1,60 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + $this->createAccessPointForObjectProcessConfiguration = $createAccessPointForObjectProcessConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/CreateAccessPointForObjectProcessResult.php b/src/Models/CreateAccessPointForObjectProcessResult.php new file mode 100644 index 0000000..4d73326 --- /dev/null +++ b/src/Models/CreateAccessPointForObjectProcessResult.php @@ -0,0 +1,44 @@ +accessPointForObjectProcessArn = $accessPointForObjectProcessArn; + $this->accessPointForObjectProcessAlias = $accessPointForObjectProcessAlias; + } +} \ No newline at end of file diff --git a/src/Models/CustomForwardHeaders.php b/src/Models/CustomForwardHeaders.php new file mode 100644 index 0000000..4f51118 --- /dev/null +++ b/src/Models/CustomForwardHeaders.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'CustomForwardHeader', type: 'string')] + public ?array $customForwardHeaders; + + /** + * CustomForwardHeaders constructor. + * @param array|null $customForwardHeaders + */ + public function __construct( + ?array $customForwardHeaders = null + ) + { + $this->customForwardHeaders = $customForwardHeaders; + } +} \ No newline at end of file diff --git a/src/Models/DeleteAccessPointForObjectProcessRequest.php b/src/Models/DeleteAccessPointForObjectProcessRequest.php new file mode 100644 index 0000000..db1461c --- /dev/null +++ b/src/Models/DeleteAccessPointForObjectProcessRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/DeleteAccessPointForObjectProcessResult.php b/src/Models/DeleteAccessPointForObjectProcessResult.php new file mode 100644 index 0000000..e23620f --- /dev/null +++ b/src/Models/DeleteAccessPointForObjectProcessResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/DeleteAccessPointPolicyForObjectProcessResult.php b/src/Models/DeleteAccessPointPolicyForObjectProcessResult.php new file mode 100644 index 0000000..d7287fb --- /dev/null +++ b/src/Models/DeleteAccessPointPolicyForObjectProcessResult.php @@ -0,0 +1,15 @@ +functionAssumeRoleArn = $functionAssumeRoleArn; + $this->functionArn = $functionArn; + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPoint.php b/src/Models/GetAccessPoint.php index b6264da..e141ced 100644 --- a/src/Models/GetAccessPoint.php +++ b/src/Models/GetAccessPoint.php @@ -100,7 +100,7 @@ final class GetAccessPoint extends Model * @param string|null $status The status of the access point. * @param string|null $bucket The name of the bucket for which the access point is configured. * @param string|null $accountId The ID of the Alibaba Cloud account for which the access point is configured. - * @param Endpoints|null $endpoints The container that stores the network origin information about the access point. + * @param AccessPointEndpoints|null $endpoints The container that stores the network origin information about the access point. * @param PublicAccessBlockConfiguration|null $publicAccessBlockConfiguration The container that stores the Block Public Access configurations. * @param string|null $creationDate The time when the access point was created. * @param string|null $accessPointName The name of the access point. @@ -113,7 +113,7 @@ public function __construct( ?string $status = null, ?string $bucket = null, ?string $accountId = null, - ?Endpoints $endpoints = null, + ?AccessPointEndpoints $endpoints = null, ?PublicAccessBlockConfiguration $publicAccessBlockConfiguration = null, ?string $creationDate = null, ?string $accessPointName = null, diff --git a/src/Models/GetAccessPointConfigForObjectProcessRequest.php b/src/Models/GetAccessPointConfigForObjectProcessRequest.php new file mode 100644 index 0000000..da67c9b --- /dev/null +++ b/src/Models/GetAccessPointConfigForObjectProcessRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPointConfigForObjectProcessResult.php b/src/Models/GetAccessPointConfigForObjectProcessResult.php new file mode 100644 index 0000000..a07aeff --- /dev/null +++ b/src/Models/GetAccessPointConfigForObjectProcessResult.php @@ -0,0 +1,53 @@ +objectProcessConfiguration = $objectProcessConfiguration; + $this->allowAnonymousAccessForObjectProcess = $allowAnonymousAccessForObjectProcess; + $this->publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPointForObjectProcessRequest.php b/src/Models/GetAccessPointForObjectProcessRequest.php new file mode 100644 index 0000000..0918504 --- /dev/null +++ b/src/Models/GetAccessPointForObjectProcessRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPointForObjectProcessResult.php b/src/Models/GetAccessPointForObjectProcessResult.php new file mode 100644 index 0000000..83fe67b --- /dev/null +++ b/src/Models/GetAccessPointForObjectProcessResult.php @@ -0,0 +1,123 @@ +accessPointName = $accessPointName; + $this->accountId = $accountId; + $this->accessPointForObjectProcessArn = $accessPointForObjectProcessArn; + $this->creationDate = $creationDate; + $this->accessPointForObjectProcessStatus = $accessPointForObjectProcessStatus; + $this->accessPointNameForObjectProcess = $accessPointNameForObjectProcess; + $this->accessPointForObjectProcessAlias = $accessPointForObjectProcessAlias; + $this->endpoints = $endpoints; + $this->allowAnonymousAccessForObjectProcess = $allowAnonymousAccessForObjectProcess; + $this->publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPointPolicyForObjectProcessRequest.php b/src/Models/GetAccessPointPolicyForObjectProcessRequest.php new file mode 100644 index 0000000..b880594 --- /dev/null +++ b/src/Models/GetAccessPointPolicyForObjectProcessRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/GetAccessPointPolicyForObjectProcessResult.php b/src/Models/GetAccessPointPolicyForObjectProcessResult.php new file mode 100644 index 0000000..1ca22bc --- /dev/null +++ b/src/Models/GetAccessPointPolicyForObjectProcessResult.php @@ -0,0 +1,30 @@ +body = $body; + } +} \ No newline at end of file diff --git a/src/Models/ListAccessPointsForObjectProcessRequest.php b/src/Models/ListAccessPointsForObjectProcessRequest.php new file mode 100644 index 0000000..cc4f5fc --- /dev/null +++ b/src/Models/ListAccessPointsForObjectProcessRequest.php @@ -0,0 +1,48 @@ +maxKeys = $maxKeys; + $this->continuationToken = $continuationToken; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/ListAccessPointsForObjectProcessResult.php b/src/Models/ListAccessPointsForObjectProcessResult.php new file mode 100644 index 0000000..7738600 --- /dev/null +++ b/src/Models/ListAccessPointsForObjectProcessResult.php @@ -0,0 +1,63 @@ +isTruncated = $isTruncated; + $this->nextContinuationToken = $nextContinuationToken; + $this->accountId = $accountId; + $this->accessPointsForObjectProcess = $accessPointsForObjectProcess; + } +} \ No newline at end of file diff --git a/src/Models/ObjectProcessConfiguration.php b/src/Models/ObjectProcessConfiguration.php new file mode 100644 index 0000000..c2fd42d --- /dev/null +++ b/src/Models/ObjectProcessConfiguration.php @@ -0,0 +1,45 @@ +allowedFeatures = $allowedFeatures; + $this->transformationConfigurations = $transformationConfigurations; + } +} \ No newline at end of file diff --git a/src/Models/PutAccessPointConfigForObjectProcessConfiguration.php b/src/Models/PutAccessPointConfigForObjectProcessConfiguration.php new file mode 100644 index 0000000..2654a30 --- /dev/null +++ b/src/Models/PutAccessPointConfigForObjectProcessConfiguration.php @@ -0,0 +1,55 @@ +allowAnonymousAccessForObjectProcess = $allowAnonymousAccessForObjectProcess; + $this->publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + $this->objectProcessConfiguration = $objectProcessConfiguration; + } +} \ No newline at end of file diff --git a/src/Models/PutAccessPointConfigForObjectProcessRequest.php b/src/Models/PutAccessPointConfigForObjectProcessRequest.php new file mode 100644 index 0000000..f95e915 --- /dev/null +++ b/src/Models/PutAccessPointConfigForObjectProcessRequest.php @@ -0,0 +1,60 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + $this->putAccessPointConfigForObjectProcessConfiguration = $putAccessPointConfigForObjectProcessConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/PutAccessPointConfigForObjectProcessResult.php b/src/Models/PutAccessPointConfigForObjectProcessResult.php new file mode 100644 index 0000000..bcda268 --- /dev/null +++ b/src/Models/PutAccessPointConfigForObjectProcessResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->accessPointForObjectProcessName = $accessPointForObjectProcessName; + $this->body = $body; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/PutAccessPointPolicyForObjectProcessResult.php b/src/Models/PutAccessPointPolicyForObjectProcessResult.php new file mode 100644 index 0000000..71cc9d2 --- /dev/null +++ b/src/Models/PutAccessPointPolicyForObjectProcessResult.php @@ -0,0 +1,15 @@ +actions = $actions; + $this->contentTransformation = $contentTransformation; + } +} \ No newline at end of file diff --git a/src/Models/TransformationConfigurations.php b/src/Models/TransformationConfigurations.php new file mode 100644 index 0000000..92409d8 --- /dev/null +++ b/src/Models/TransformationConfigurations.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'TransformationConfiguration', type: TransformationConfiguration::class)] + public ?array $transformationConfigurations; + + /** + * TransformationConfigurations constructor. + * @param array|null $transformationConfigurations The container that stores the transformation configurations. + */ + public function __construct( + ?array $transformationConfigurations = null + ) + { + $this->transformationConfigurations = $transformationConfigurations; + } +} \ No newline at end of file diff --git a/src/Models/WriteGetObjectResponseRequest.php b/src/Models/WriteGetObjectResponseRequest.php new file mode 100644 index 0000000..a874c19 --- /dev/null +++ b/src/Models/WriteGetObjectResponseRequest.php @@ -0,0 +1,164 @@ +requestRoute = $requestRoute; + $this->requestToken = $requestToken; + $this->fwdStatus = $fwdStatus; + $this->fwdHeaderAcceptRanges = $fwdHeaderAcceptRanges; + $this->fwdHeaderCacheControl = $fwdHeaderCacheControl; + $this->fwdHeaderContentDisposition = $fwdHeaderContentDisposition; + $this->fwdHeaderContentEncoding = $fwdHeaderContentEncoding; + $this->fwdHeaderContentLanguage = $fwdHeaderContentLanguage; + $this->fwdHeaderContentRange = $fwdHeaderContentRange; + $this->fwdHeaderContentType = $fwdHeaderContentType; + $this->fwdHeaderEtag = $fwdHeaderEtag; + $this->fwdHeaderExpires = $fwdHeaderExpires; + $this->fwdHeaderLastModified = $fwdHeaderLastModified; + $this->body = $body; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/src/Models/WriteGetObjectResponseResult.php b/src/Models/WriteGetObjectResponseResult.php new file mode 100644 index 0000000..7c8afa0 --- /dev/null +++ b/src/Models/WriteGetObjectResponseResult.php @@ -0,0 +1,15 @@ + 'application/xml'] + ); + $input->setParameter('accessPointForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CreateAccessPointForObjectProcessResult + */ + public static function toCreateAccessPointForObjectProcess(OperationOutput $output): Models\CreateAccessPointForObjectProcessResult + { + $result = new Models\CreateAccessPointForObjectProcessResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetAccessPointForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromGetAccessPointForObjectProcess(Models\GetAccessPointForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'GetAccessPointForObjectProcess', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPointForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetAccessPointForObjectProcessResult + */ + public static function toGetAccessPointForObjectProcess(OperationOutput $output): Models\GetAccessPointForObjectProcessResult + { + $result = new Models\GetAccessPointForObjectProcessResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListAccessPointsForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromListAccessPointsForObjectProcess(Models\ListAccessPointsForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'ListAccessPointsForObjectProcess', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPointForObjectProcess', ''); + $input->setOpMetadata('sub-resource', ['accessPointForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListAccessPointsForObjectProcessResult + */ + public static function toListAccessPointsForObjectProcess(OperationOutput $output): Models\ListAccessPointsForObjectProcessResult + { + $result = new Models\ListAccessPointsForObjectProcessResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteAccessPointForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromDeleteAccessPointForObjectProcess(Models\DeleteAccessPointForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteAccessPointForObjectProcess', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPointForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteAccessPointForObjectProcessResult + */ + public static function toDeleteAccessPointForObjectProcess(OperationOutput $output): Models\DeleteAccessPointForObjectProcessResult + { + $result = new Models\DeleteAccessPointForObjectProcessResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetAccessPointConfigForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromGetAccessPointConfigForObjectProcess(Models\GetAccessPointConfigForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'GetAccessPointConfigForObjectProcess', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPointConfigForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointConfigForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetAccessPointConfigForObjectProcessResult + */ + public static function toGetAccessPointConfigForObjectProcess(OperationOutput $output): Models\GetAccessPointConfigForObjectProcessResult + { + $result = new Models\GetAccessPointConfigForObjectProcessResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutAccessPointConfigForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromPutAccessPointConfigForObjectProcess(Models\PutAccessPointConfigForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'PutAccessPointConfigForObjectProcess', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPointConfigForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointConfigForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutAccessPointConfigForObjectProcessResult + */ + public static function toPutAccessPointConfigForObjectProcess(OperationOutput $output): Models\PutAccessPointConfigForObjectProcessResult + { + $result = new Models\PutAccessPointConfigForObjectProcessResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\PutAccessPointPolicyForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromPutAccessPointPolicyForObjectProcess(Models\PutAccessPointPolicyForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'PutAccessPointPolicyForObjectProcess', + 'PUT', + ); + $input->setParameter('accessPointPolicyForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicyForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutAccessPointPolicyForObjectProcessResult + */ + public static function toPutAccessPointPolicyForObjectProcess(OperationOutput $output): Models\PutAccessPointPolicyForObjectProcessResult + { + $result = new Models\PutAccessPointPolicyForObjectProcessResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetAccessPointPolicyForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromGetAccessPointPolicyForObjectProcess(Models\GetAccessPointPolicyForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'GetAccessPointPolicyForObjectProcess', + 'GET', + ); + $input->setParameter('accessPointPolicyForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicyForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetAccessPointPolicyForObjectProcessResult + */ + public static function toGetAccessPointPolicyForObjectProcess(OperationOutput $output): Models\GetAccessPointPolicyForObjectProcessResult + { + $result = new Models\GetAccessPointPolicyForObjectProcessResult(); + if ($output->getBody() !== null) { + $result->body = $output->getBody()->getContents(); + } + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteAccessPointPolicyForObjectProcessRequest $request + * @return OperationInput + */ + public static function fromDeleteAccessPointPolicyForObjectProcess(Models\DeleteAccessPointPolicyForObjectProcessRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteAccessPointPolicyForObjectProcess', + 'DELETE', + ); + $input->setParameter('accessPointPolicyForObjectProcess', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicyForObjectProcess',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteAccessPointPolicyForObjectProcessResult + */ + public static function toDeleteAccessPointPolicyForObjectProcess(OperationOutput $output): Models\DeleteAccessPointPolicyForObjectProcessResult + { + $result = new Models\DeleteAccessPointPolicyForObjectProcessResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\WriteGetObjectResponseRequest $request + * @return OperationInput + */ + public static function fromWriteGetObjectResponse(Models\WriteGetObjectResponseRequest $request): OperationInput + { + $input = new OperationInput( + 'WriteGetObjectResponse', + 'POST', + ); + $input->setParameter('x-oss-write-get-object-response', ''); + $input->setOpMetadata('sub-resource', ['x-oss-write-get-object-response',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\WriteGetObjectResponseResult + */ + public static function toDeleteWriteGetObjectResponse(OperationOutput $output): Models\WriteGetObjectResponseResult + { + $result = new Models\WriteGetObjectResponseResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/src/Transform/Functions.php b/src/Transform/Functions.php index a488847..fdfc4c2 100644 --- a/src/Transform/Functions.php +++ b/src/Transform/Functions.php @@ -176,6 +176,17 @@ final class Functions 'GetBucketInventory' => 'BucketInventory', 'ListBucketInventory' => 'BucketInventory', 'DeleteBucketInventory' => 'BucketInventory', + // bucket object fc access point + 'CreateAccessPointForObjectProcess' => 'BucketObjectFcAccessPoint', + 'GetAccessPointForObjectProcess' => 'BucketObjectFcAccessPoint', + 'ListAccessPointsForObjectProcess' => 'BucketObjectFcAccessPoint', + 'DeleteAccessPointForObjectProcess' => 'BucketObjectFcAccessPoint', + 'GetAccessPointConfigForObjectProcess' => 'BucketObjectFcAccessPoint', + 'PutAccessPointConfigForObjectProcess' => 'BucketObjectFcAccessPoint', + 'PutAccessPointPolicyForObjectProcess' => 'BucketObjectFcAccessPoint', + 'GetAccessPointPolicyForObjectProcess' => 'BucketObjectFcAccessPoint', + 'DeleteAccessPointPolicyForObjectProcess' => 'BucketObjectFcAccessPoint', + 'WriteGetObjectResponse' => 'BucketObjectFcAccessPoint', ]; public static function getTransformClass(string $apiName) diff --git a/tests/IntegrationTests/ClientAccessPointForObjectProcessTest.php b/tests/IntegrationTests/ClientAccessPointForObjectProcessTest.php new file mode 100644 index 0000000..1e06903 --- /dev/null +++ b/tests/IntegrationTests/ClientAccessPointForObjectProcessTest.php @@ -0,0 +1,432 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + $accessPointName = 'ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $createResult = $client->createAccessPoint(new Oss\Models\CreateAccessPointRequest( + $bucketName, + new Oss\Models\CreateAccessPointConfiguration( + accessPointName: $accessPointName, + networkOrigin: 'internet', + ))); + $this->assertEquals(200, $createResult->statusCode); + $this->assertEquals('OK', $createResult->status); + $this->assertEquals(True, count($createResult->headers) > 0); + $this->assertEquals(24, strlen($createResult->requestId)); + + $objectProcessName = 'fc-ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $arn = "acs:fc:" . self::$REGION . ":" . self::$USER_ID . ":services/test-oss-fc.LATEST/functions/" . $objectProcessName; + $roleArn = "acs:ram::" . self::$USER_ID . ":role/aliyunfcdefaultrole"; + + // CreateAccessPointForObjectProcess + $createResult = $client->createAccessPointForObjectProcess(new Oss\Models\CreateAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + createAccessPointForObjectProcessConfiguration: new Oss\Models\CreateAccessPointForObjectProcessConfiguration( + accessPointName: $accessPointName, + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn, + ) + ) + )] + ) + ) + ) + )); + $this->assertEquals(200, $createResult->statusCode); + $this->assertEquals('OK', $createResult->status); + $this->assertEquals(True, count($createResult->headers) > 0); + $this->assertEquals(24, strlen($createResult->requestId)); + + // GetAccessPointForObjectProcess + $getResult = $client->getAccessPointForObjectProcess(new Oss\Models\GetAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListAccessPointsForObjectProcess + $listResult = $client->listAccessPointsForObjectProcess(new Oss\Models\ListAccessPointsForObjectProcessRequest()); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // PutAccessPointPolicyForObjectProcess + $policy = '{"Version":"1","Statement":[{"Action":["oss:GetObject"],"Effect":"Allow","Principal":["' . self::$USER_ID . '"],"Resource":["acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspointforobjectprocess/' . $objectProcessName . '/object/*"]}]}'; + $putPolicyResult = $client->putAccessPointPolicyForObjectProcess(new Oss\Models\PutAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + body: Oss\Utils::streamFor($policy) + )); + $this->assertEquals(200, $putPolicyResult->statusCode); + $this->assertEquals('OK', $putPolicyResult->status); + $this->assertEquals(True, count($putPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($putPolicyResult->requestId)); + + // GetAccessPointPolicyForObjectProcess + $getPolicyResult = $client->getAccessPointPolicyForObjectProcess(new Oss\Models\GetAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertEquals(200, $getPolicyResult->statusCode); + $this->assertEquals('OK', $getPolicyResult->status); + $this->assertEquals(True, count($getPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($getPolicyResult->requestId)); + $this->assertEquals($policy, $getPolicyResult->body); + + // DeleteAccessPointPolicyForObjectProcess + $delPolicyResult = $client->deleteAccessPointPolicyForObjectProcess(new Oss\Models\DeleteAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertEquals(204, $delPolicyResult->statusCode); + $this->assertEquals('No Content', $delPolicyResult->status); + $this->assertEquals(True, count($delPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($delPolicyResult->requestId)); + + // PutAccessPointConfigForObjectProcess + $putConfigResult = $client->putAccessPointConfigForObjectProcess(new Oss\Models\PutAccessPointConfigForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + putAccessPointConfigForObjectProcessConfiguration: new Oss\Models\PutAccessPointConfigForObjectProcessConfiguration( + publicAccessBlockConfiguration: new Oss\Models\PublicAccessBlockConfiguration( + blockPublicAccess: true + ), + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [ + new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn + ) + ) + ) + ] + ) + ) + ) + )); + $this->assertEquals(200, $putConfigResult->statusCode); + $this->assertEquals('OK', $putConfigResult->status); + $this->assertEquals(True, count($putConfigResult->headers) > 0); + $this->assertEquals(24, strlen($putConfigResult->requestId)); + + // GetAccessPointConfigForObjectProcess + $getConfigResult = $client->getAccessPointConfigForObjectProcess(new Oss\Models\GetAccessPointConfigForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertEquals(200, $getConfigResult->statusCode); + $this->assertEquals('OK', $getConfigResult->status); + $this->assertEquals(True, count($getConfigResult->headers) > 0); + $this->assertEquals(24, strlen($getConfigResult->requestId)); + + while (true) { + $getResult = $client->getAccessPointForObjectProcess(new Oss\Models\GetAccessPointForObjectProcessRequest( + $bucketName, $objectProcessName + )); + if ($getResult->accessPointForObjectProcessStatus != 'creating') { + break; + } else { + sleep(3); + } + } + + $delFcResult = $client->deleteAccessPointForObjectProcess(new Oss\Models\DeleteAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertEquals(204, $delFcResult->statusCode); + $this->assertEquals('No Content', $delFcResult->status); + $this->assertEquals(True, count($delFcResult->headers) > 0); + $this->assertEquals(24, strlen($delFcResult->requestId)); + + while (true) { + try { + $client->getAccessPointForObjectProcess(new Oss\Models\GetAccessPointForObjectProcessRequest( + $bucketName, $objectProcessName + )); + } catch (Oss\Exception\OperationException $e) { + $se = $e->getPrevious(); + if ($se instanceof Oss\Exception\ServiceException) { + if ($se->getErrorCode() == 'NoSuchAccessPointForObjectProcess' && $se->getStatusCode() == 404) { + break; + } + } + } + sleep(3); + } + + while (true) { + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPointName + )); + if ($getResult->getAccessPoint->status != 'creating') { + break; + } else { + sleep(3); + } + } + $delResult = $client->deleteAccessPoint(new Oss\Models\DeleteAccessPointRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testAccessPointForObjectProcessFail() + { + $client = $this->getDefaultClient(); + $accessPointName = 'ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $bucketName = self::$bucketName . "-not-exist"; + $objectProcessName = 'fc-ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $arn = "acs:fc:" . self::$REGION . ":" . self::$USER_ID . ":services/test-oss-fc.LATEST/functions/" . $objectProcessName; + $roleArn = "acs:ram::" . self::$USER_ID . ":role/aliyunfcdefaultrole"; + // CreateAccessPointForObjectProcess + try { + $client->createAccessPointForObjectProcess(new Oss\Models\CreateAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + createAccessPointForObjectProcessConfiguration: new Oss\Models\CreateAccessPointForObjectProcessConfiguration( + accessPointName: $accessPointName, + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn, + ) + ) + )] + ) + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CreateAccessPoint', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPointForObjectProcess + try { + $client->getAccessPointForObjectProcess(new Oss\Models\GetAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPointForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ListAccessPointsForObjectProcess + try { + $invalidClient = $this->getInvalidAkClient(); + $listResult = $invalidClient->listAccessPointsForObjectProcess(new Oss\Models\ListAccessPointsForObjectProcessRequest()); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListAccessPointsForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // PutAccessPointPolicyForObjectProcess + try { + $policy = '{"Version":"1","Statement":[{"Action":["oss:GetObject"],"Effect":"Allow","Principal":["' . self::$USER_ID . '"],"Resource":["acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspointforobjectprocess/' . $objectProcessName . '/object/*"]}]}'; + $putPolicyResult = $client->putAccessPointPolicyForObjectProcess(new Oss\Models\PutAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + body: Oss\Utils::streamFor($policy) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutAccessPointPolicyForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPointPolicy + try { + $getPolicyResult = $client->getAccessPointPolicyForObjectProcess(new Oss\Models\GetAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPointPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteAccessPointPolicyForObjectProcess + try { + $delPolicyResult = $client->deleteAccessPointPolicyForObjectProcess(new Oss\Models\DeleteAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteAccessPointPolicyForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // PutAccessPointConfigForObjectProcess + try { + $putConfigResult = $client->putAccessPointConfigForObjectProcess(new Oss\Models\PutAccessPointConfigForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + putAccessPointConfigForObjectProcessConfiguration: new Oss\Models\PutAccessPointConfigForObjectProcessConfiguration( + publicAccessBlockConfiguration: new Oss\Models\PublicAccessBlockConfiguration( + blockPublicAccess: true + ), + objectProcessConfiguration: new Oss\Models\ObjectProcessConfiguration( + allowedFeatures: new Oss\Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Oss\Models\TransformationConfigurations( + [ + new Oss\Models\TransformationConfiguration( + actions: new Oss\Models\AccessPointActions(['GetObject']), + contentTransformation: new Oss\Models\ContentTransformation( + functionCompute: new Oss\Models\FunctionCompute( + functionAssumeRoleArn: $roleArn, + functionArn: $arn + ) + ) + ) + ] + ) + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutAccessPointConfigForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPointConfigForObjectProcess + try { + $getConfigResult = $client->getAccessPointConfigForObjectProcess(new Oss\Models\GetAccessPointConfigForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPointConfigForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteAccessPointPolicyForObjectProcess + try { + $client->deleteAccessPointPolicyForObjectProcess(new Oss\Models\DeleteAccessPointPolicyForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteAccessPointPolicyForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteAccessPointForObjectProcess + try { + $client->deleteAccessPointForObjectProcess(new Oss\Models\DeleteAccessPointForObjectProcessRequest( + bucket: $bucketName, + accessPointForObjectProcessName: $objectProcessName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteAccessPointForObjectProcess', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/tests/UnitTests/Transform/BucketObjectFcAccessPointTest.php b/tests/UnitTests/Transform/BucketObjectFcAccessPointTest.php new file mode 100644 index 0000000..6445dca --- /dev/null +++ b/tests/UnitTests/Transform/BucketObjectFcAccessPointTest.php @@ -0,0 +1,674 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CreateAccessPointForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromCreateAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + try { + $request = new Models\CreateAccessPointForObjectProcessRequest('bucket-123', 'fc-ap-01'); + $input = BucketObjectFcAccessPoint::fromCreateAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, createAccessPointForObjectProcessConfiguration", (string)$e); + } + + $request = new Models\CreateAccessPointForObjectProcessRequest('bucket-123', 'fc-ap-01', + new Models\CreateAccessPointForObjectProcessConfiguration( + accessPointName: 'ap-01', + objectProcessConfiguration: new Models\ObjectProcessConfiguration( + allowedFeatures: new Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Models\TransformationConfigurations( + [new Models\TransformationConfiguration( + actions: new Models\AccessPointActions(['GetObject']), + contentTransformation: new Models\ContentTransformation( + functionCompute: new Models\FunctionCompute( + functionAssumeRoleArn: 'acs:ram::111933544165****:role/aliyunfcdefaultrole', + functionArn: 'acs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01' + ) + ) + )] + ) + ) + )); + $input = BucketObjectFcAccessPoint::fromCreateAccessPointForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('fc-ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + $xml = <<ap-01GetObject-RangeGetObjectacs:ram::111933544165****:role/aliyunfcdefaultroleacs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToCreateAccessPointForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toCreateAccessPointForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + acs:oss:cn-qingdao:119335441657143:accesspointforobjectprocess/fc-ap-01 + fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketObjectFcAccessPoint::toCreateAccessPointForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('acs:oss:cn-qingdao:119335441657143:accesspointforobjectprocess/fc-ap-01', $result->accessPointForObjectProcessArn); + $this->assertEquals('fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias', $result->accessPointForObjectProcessAlias); + } + + public function testFromGetAccessPointForObjectProcess() + { + // miss required field + try { + $request = new Models\GetAccessPointForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromGetAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetAccessPointForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + $request = new Models\GetAccessPointForObjectProcessRequest('bucket-123', 'fc-ap-01'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('fc-ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + } + + public function testToGetAccessPointForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toGetAccessPointForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + fc-ap-01 + fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias + ap-01 + 111933544165**** + acs:oss:cn-qingdao:11933544165****:accesspointforobjectprocess/fc-ap-01 + 1626769503 + enable + + fc-ap-01-111933544165****.oss-cn-qingdao.oss-object-process.aliyuncs.com + fc-ap-01-111933544165****.oss-cn-qingdao-internal.oss-object-process.aliyuncs.com + + + true + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketObjectFcAccessPoint::toGetAccessPointForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('fc-ap-01', $result->accessPointNameForObjectProcess); + $this->assertEquals('fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias', $result->accessPointForObjectProcessAlias); + $this->assertEquals('ap-01', $result->accessPointName); + $this->assertEquals('111933544165****', $result->accountId); + $this->assertEquals('acs:oss:cn-qingdao:11933544165****:accesspointforobjectprocess/fc-ap-01', $result->accessPointForObjectProcessArn); + $this->assertEquals('1626769503', $result->creationDate); + $this->assertEquals('enable', $result->accessPointForObjectProcessStatus); + $this->assertEquals('fc-ap-01-111933544165****.oss-cn-qingdao.oss-object-process.aliyuncs.com', $result->endpoints->publicEndpoint); + $this->assertEquals('fc-ap-01-111933544165****.oss-cn-qingdao-internal.oss-object-process.aliyuncs.com', $result->endpoints->internalEndpoint); + $this->assertTrue($result->publicAccessBlockConfiguration->blockPublicAccess); + } + + public function testFromDeleteAccessPointForObjectProcess() + { + // miss required field + try { + $request = new Models\DeleteAccessPointForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteAccessPointForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + $request = new Models\DeleteAccessPointForObjectProcessRequest('bucket-123', 'fc-ap-01'); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('fc-ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + } + + public function testToDeleteAccessPointForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toDeleteAccessPointForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'], + ); + $result = BucketObjectFcAccessPoint::toDeleteAccessPointForObjectProcess($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromListAccessPointForObjectProcess() + { + $request = new Models\ListAccessPointsForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromListAccessPointsForObjectProcess($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + $request = new Models\ListAccessPointsForObjectProcessRequest(10, 'token'); + $input = BucketObjectFcAccessPoint::fromListAccessPointsForObjectProcess($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + $this->assertEquals('token', $input->getParameters()['continuation-token']); + } + + public function testToListAccessPointForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toListAccessPointsForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true + abc + 111933544165**** + + + fc-ap-01 + fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias + fc-01 + enable + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketObjectFcAccessPoint::toListAccessPointsForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(1, count($result->accessPointsForObjectProcess->accessPointForObjectProcesss)); + $this->assertEquals('fc-ap-01', $result->accessPointsForObjectProcess->accessPointForObjectProcesss[0]->accessPointNameForObjectProcess); + $this->assertEquals('fc-ap-01-3b00521f653d2b3223680ec39dbbe2****-opapalias', $result->accessPointsForObjectProcess->accessPointForObjectProcesss[0]->accessPointForObjectProcessAlias); + $this->assertEquals('fc-01', $result->accessPointsForObjectProcess->accessPointForObjectProcesss[0]->accessPointName); + $this->assertEquals('enable', $result->accessPointsForObjectProcess->accessPointForObjectProcesss[0]->status); + } + + public function testFromPutAccessPointPolicyForObjectProcess() + { + // miss required field + try { + $request = new Models\PutAccessPointPolicyForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromPutAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutAccessPointPolicyForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromPutAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + try { + $request = new Models\PutAccessPointPolicyForObjectProcessRequest('bucket-123', 'ap-01'); + $input = BucketObjectFcAccessPoint::fromPutAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, body", (string)$e); + } + + $request = new Models\PutAccessPointPolicyForObjectProcessRequest('bucket-123', 'ap-01', '{"Version":"1","Statement":[{"Effect":"Allow","Action":["oss:GetObject"],"Principal":["23721626365841xxxx"],"Resource":["acs:oss:cn-qingdao:111933544165xxxx:accesspointforobjectprocess/fc-ap-01/object/*"]}]}'); + $input = BucketObjectFcAccessPoint::fromPutAccessPointPolicyForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('{"Version":"1","Statement":[{"Effect":"Allow","Action":["oss:GetObject"],"Principal":["23721626365841xxxx"],"Resource":["acs:oss:cn-qingdao:111933544165xxxx:accesspointforobjectprocess/fc-ap-01/object/*"]}]}', $input->getBody()->getContents()); + } + + public function testToPutAccessPointPolicyForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toPutAccessPointPolicyForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = BucketObjectFcAccessPoint::toPutAccessPointPolicyForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetAccessPointPolicyForObjectProcess() + { + // miss required field + try { + $request = new Models\GetAccessPointPolicyForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromGetAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetAccessPointPolicyForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + $request = new Models\GetAccessPointPolicyForObjectProcessRequest('bucket-123', 'ap-01'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointPolicyForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + } + + public function testToGetAccessPointPolicyForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toGetAccessPointPolicyForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = '{ + "Version":"1", + "Statement":[ + { + "Action":[ + "oss:PutObject", + "oss:GetObject" + ], + "Effect":"Deny", + "Principal":["27737962156157xxxx"], + "Resource":[ + "acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/$ap-01", + "acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/$ap-01/object/*" + ] + } + ] + }'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/json'], + body: Utils::streamFor($body) + ); + $result = BucketObjectFcAccessPoint::toGetAccessPointPolicyForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/json', $result->headers['content-type']); + $this->assertEquals($body, $result->body); + } + + public function testFromDeleteAccessPointPolicyForObjectProcess() + { + // miss required field + try { + $request = new Models\DeleteAccessPointPolicyForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteAccessPointPolicyForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointPolicyForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + $request = new Models\DeleteAccessPointPolicyForObjectProcessRequest('bucket-123', 'ap-01'); + $input = BucketObjectFcAccessPoint::fromDeleteAccessPointPolicyForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + } + + public function testToDeleteAccessPointPolicyForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toDeleteAccessPointPolicyForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'], + ); + $result = BucketObjectFcAccessPoint::toDeleteAccessPointPolicyForObjectProcess($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromPutAccessPointConfigForObjectProcess() + { + // miss required field + try { + $request = new Models\PutAccessPointConfigForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromPutAccessPointConfigForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutAccessPointConfigForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromPutAccessPointConfigForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + try { + $request = new Models\PutAccessPointConfigForObjectProcessRequest('bucket-123', 'ap-01'); + $input = BucketObjectFcAccessPoint::fromPutAccessPointConfigForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, putAccessPointConfigForObjectProcessConfiguration", (string)$e); + } + + $request = new Models\PutAccessPointConfigForObjectProcessRequest('bucket-123', 'ap-01', putAccessPointConfigForObjectProcessConfiguration: new Models\PutAccessPointConfigForObjectProcessConfiguration( + publicAccessBlockConfiguration: new Models\PublicAccessBlockConfiguration( + blockPublicAccess: true, + ), objectProcessConfiguration: new Models\ObjectProcessConfiguration( + allowedFeatures: new Models\AllowedFeatures(['GetObject-Range']), + transformationConfigurations: new Models\TransformationConfigurations( + [new Models\TransformationConfiguration( + actions: new Models\AccessPointActions(['GetObject']), + contentTransformation: new Models\ContentTransformation( + functionCompute: new Models\FunctionCompute( + functionAssumeRoleArn: 'acs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01', + functionArn: 'acs:ram::111933544165****:role/aliyunfcdefaultrole' + ) + ) + )] + ) + ) + )); + $xml = <<trueGetObject-RangeGetObjectacs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01acs:ram::111933544165****:role/aliyunfcdefaultrole +BBB; + + $input = BucketObjectFcAccessPoint::fromPutAccessPointConfigForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutAccessPointConfigForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toPutAccessPointConfigForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + ); + $result = BucketObjectFcAccessPoint::toPutAccessPointConfigForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + } + + public function testFromGetAccessPointConfigForObjectProcess() + { + // miss required field + try { + $request = new Models\GetAccessPointConfigForObjectProcessRequest(); + $input = BucketObjectFcAccessPoint::fromGetAccessPointConfigForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetAccessPointConfigForObjectProcessRequest('bucket-123'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointConfigForObjectProcess($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointForObjectProcessName", (string)$e); + } + + $request = new Models\GetAccessPointConfigForObjectProcessRequest('bucket-123', 'ap-01'); + $input = BucketObjectFcAccessPoint::fromGetAccessPointConfigForObjectProcess($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-for-object-process-name']); + } + + public function testToGetAccessPointConfigForObjectProcess() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toGetAccessPointConfigForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + + + + + getobject + + + + acs:ram::111933544165****:role/aliyunfcdefaultrole + acs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01 + + + + + + + true + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketObjectFcAccessPoint::toGetAccessPointConfigForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertTrue($result->publicAccessBlockConfiguration->blockPublicAccess); + $this->assertEquals('getobject', $result->objectProcessConfiguration->transformationConfigurations->transformationConfigurations[0]->actions->actions[0]); + $this->assertEquals('acs:ram::111933544165****:role/aliyunfcdefaultrole', $result->objectProcessConfiguration->transformationConfigurations->transformationConfigurations[0]->contentTransformation->functionCompute->functionAssumeRoleArn); + $this->assertEquals('acs:fc:cn-qingdao:111933544165****:services/test-oss-fc.LATEST/functions/fc-01', $result->objectProcessConfiguration->transformationConfigurations->transformationConfigurations[0]->contentTransformation->functionCompute->functionArn); + } + + public function testFromWriteGetObjectResponse() + { + // miss required field + try { + $request = new Models\WriteGetObjectResponseRequest(); + $input = BucketObjectFcAccessPoint::fromWriteGetObjectResponse($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, requestRoute", (string)$e); + } + + try { + $request = new Models\WriteGetObjectResponseRequest('fc-ap-01-176022554508***-opap.oss-cn-hangzhou.oss-object-process.aliyuncs.com'); + $input = BucketObjectFcAccessPoint::fromWriteGetObjectResponse($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, requestToken", (string)$e); + } + + try { + $request = new Models\WriteGetObjectResponseRequest('fc-ap-01-176022554508***-opap.oss-cn-hangzhou.oss-object-process.aliyuncs.com', 'token'); + $input = BucketObjectFcAccessPoint::fromWriteGetObjectResponse($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, fwdStatus", (string)$e); + } + + + $request = new Models\WriteGetObjectResponseRequest('fc-ap-01-176022554508***-opap.oss-cn-hangzhou.oss-object-process.aliyuncs.com', 'token', '200'); + $input = BucketObjectFcAccessPoint::fromWriteGetObjectResponse($request); + $this->assertEquals('fc-ap-01-176022554508***-opap.oss-cn-hangzhou.oss-object-process.aliyuncs.com', $input->getHeaders()['x-oss-request-route']); + $this->assertEquals('token', $input->getHeaders()['x-oss-request-token']); + $this->assertEquals('200', $input->getHeaders()['x-oss-fwd-status']); + } + + public function testToWriteGetObjectResponse() + { + // empty output + $output = new OperationOutput(); + $result = BucketObjectFcAccessPoint::toGetAccessPointConfigForObjectProcess($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + ); + $result = BucketObjectFcAccessPoint::toGetAccessPointConfigForObjectProcess($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php b/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php index 755c99c..a2aa736 100644 --- a/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php +++ b/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php @@ -34,7 +34,7 @@ public function testFromPutBucketPublicAccessBlock() true )); $input = BucketPublicAccessBlock::fromPutBucketPublicAccessBlock($request); - $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('bucket-123', $this->cleanXml($input->getBucket())); $xml = <<true BBB; @@ -76,7 +76,7 @@ public function testFromGetBucketPublicAccessBlock() $request = new Models\GetBucketPublicAccessBlockRequest('bucket-123'); $input = BucketPublicAccessBlock::fromGetBucketPublicAccessBlock($request); - $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('bucket-123', $this->cleanXml($input->getBucket())); $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); } @@ -121,7 +121,7 @@ public function testFromDeleteBucketPublicAccessBlock() $request = new Models\DeleteBucketPublicAccessBlockRequest('bucket-123'); $input = BucketPublicAccessBlock::fromDeleteBucketPublicAccessBlock($request); - $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('bucket-123', $this->cleanXml($input->getBucket())); $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); }