Shellbox
Library and server for containerized shell execution
Loading...
Searching...
No Matches
Shellbox\Client Class Reference

A generic client which executes actions on the Shellbox server. More...

+ Inheritance diagram for Shellbox\Client:

Public Member Functions

 __construct (ClientInterface $httpClient, UriInterface $uri, string $key, array $options=[])
 
 setLogger (LoggerInterface $logger)
 
 call ( $routeName, $functionName, $params=[], $options=[])
 
 sendRequest ( $path, $parts, $outputFiles=[], $outputGlobs=[])
 Send an arbitrary request to the server.
 
 areUrlFilesAllowed ()
 Whether the client can download input files and upload output files specified with BoxedCommand::inputFileFromUrl and the like.
 

Detailed Description

A generic client which executes actions on the Shellbox server.

Constructor & Destructor Documentation

◆ __construct()

Shellbox\Client::__construct ( ClientInterface $httpClient,
UriInterface $uri,
string $key,
array $options = [] )
Parameters
ClientInterface$httpClientAn object which requests an HTTP resource. It is permissible to throw an exception for propagation back to the caller. However, a successfully received response with a status code of >=400 should ideally be returned to Shellbox as a ResponseInterface, so that Shellbox can parse and rethrow its own error messages. With Guzzle this could be achieved by passing setting RequestOptions::HTTP_ERROR option to false when creating the client.
UriInterface$uriThe base URI of the server
string$keyThe key for HMAC authentication
array$optionsAn associative array of options, which may contain:
  • allowUrlFiles: Set this to true to allow input files to be downloaded, and output files to be uploaded, on the server side. If this is set, the server configuration variable allowUrlFiles must also be set to true.

Member Function Documentation

◆ areUrlFilesAllowed()

Shellbox\Client::areUrlFilesAllowed ( )

Whether the client can download input files and upload output files specified with BoxedCommand::inputFileFromUrl and the like.

Since
4.1.0
Returns
bool

◆ sendRequest()

Shellbox\Client::sendRequest ( $path,
$parts,
$outputFiles = [],
$outputGlobs = [] )

Send an arbitrary request to the server.

Parameters
string$pathThe URL path relative to the server's base URL
array$partsAn array of multipart parts to send, in the format specified by MultipartStream. Each part is an associative array which for our purposes may contain:
  • "name": The part name. Required but ignored when there is a Content-Disposition header.
  • "contents": Here always a StreamInterface or string
  • "headers": An associative array of part headers.
OutputFile[]$outputFilesOutput files. The objects will have their contents populated with data received from the server.
OutputGlob[]$outputGlobsOutput globs. The objects will be populated with data received from the server.
Returns
array An associative array of output data
Exceptions
ShellboxError

◆ setLogger()

Shellbox\Client::setLogger ( LoggerInterface $logger)
Parameters
LoggerInterface$logger

The documentation for this class was generated from the following file: