PHP 7.4.33
Preview: JsonRpcSerializer.php Size: 1.82 KB
/home/godevadmin/www/admin/vendor/aws/Aws/Api/Serializer/JsonRpcSerializer.php

<?php
namespace Aws\Api\Serializer;

use Aws\Api\Service;
use Aws\CommandInterface;
use GuzzleHttp\Psr7\Request;
use Psr\Http\Message\RequestInterface;

/**
 * Prepares a JSON-RPC request for transfer.
 * @internal
 */
class JsonRpcSerializer
{
    /** @var JsonBody */
    private $jsonFormatter;

    /** @var string */
    private $endpoint;

    /** @var Service */
    private $api;

    /** @var string */
    private $contentType;

    /**
     * @param Service  $api           Service description
     * @param string   $endpoint      Endpoint to connect to
     * @param JsonBody $jsonFormatter Optional JSON formatter to use
     */
    public function __construct(
        Service $api,
        $endpoint,
        JsonBody $jsonFormatter = null
    ) {
        $this->endpoint = $endpoint;
        $this->api = $api;
        $this->jsonFormatter = $jsonFormatter ?: new JsonBody($this->api);
        $this->contentType = JsonBody::getContentType($api);
    }

    /**
     * When invoked with an AWS command, returns a serialization array
     * containing "method", "uri", "headers", and "body" key value pairs.
     *
     * @param CommandInterface $command
     *
     * @return RequestInterface
     */
    public function __invoke(CommandInterface $command)
    {
        $name = $command->getName();
        $operation = $this->api->getOperation($name);

        return new Request(
            $operation['http']['method'],
            $this->endpoint,
            [
                'X-Amz-Target' => $this->api->getMetadata('targetPrefix') . '.' . $name,
                'Content-Type' => $this->contentType
            ],
            $this->jsonFormatter->build(
                $operation->getInput(),
                $command->toArray()
            )
        );
    }
}

Directory Contents

Dirs: 0 × Files: 9

Name Size Perms Modified Actions
906 B lrwxrwxr-x 2024-06-18 20:09:54
Edit Download
2.80 KB lrwxrwxr-x 2024-06-18 20:09:54
Edit Download
1.82 KB lrwxrwxr-x 2024-06-18 20:09:54
Edit Download
4.08 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download
1.75 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download
1.14 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download
8.33 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download
1.30 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download
5.99 KB lrwxrwxr-x 2024-06-18 20:09:56
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).