Projections
About
API projections are basically predefined query options for the API. They can be used to simplify the queried data or to add more extra data to the result.
Usage
Projections are predefined, so first of all, you need to know which one you want to use, not all API endpoint has the same projections. You can check the projections at the API representation documentation pages:
- Image - API representation
- Firewall - API representation
- Access Token - API representation
- Cloud - API representation
- Super Backup - API representation
- Job - API representation
- Ping - API representation
- Billing - API representation
- Super Backup log - API representation
In usage, they work as an URL query parameter, you need to add to the API request URL as comma separated string, or use SDK.
Example
Example cloud GET HTTP request with info
projection:
GET https://api.shardimage.com/cloud/v1/<cloudId>?projection=info HTTP/1.1
Host: api.shardimage.com
Accept-Encoding: gzip
Content-ID: <contentId>
Content-Type: application/json; charset=utf-8
X-Shardimage-Auth-Key: <apiKey>
X-Shardimage-Auth-Signature: <signature>
X-Shardimage-Mode: sync/parallel
User-Agent: GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.24-0ubuntu0.18.04.2 ShardimagePhpOfficial/1.0.0
Referrer: 5230.1579248549.1839.1184145725
With the official Shardimage PHP SDK:
use shardimage\shardimagephp\auth\Client;
use shardimage\shardimagephp\models\cloud\IndexParams;
$client = new Client([
'apiKey' => '<apiKey>',
'apiSecret' => '<apiSecret>',
'imageSecret' => '<imageSecret>',
'cloudId' => '<cloudId>',
]);
$cloud = $client->getCloudService()->view('<cloudId>', ['projection' => IndexParams::PROJECTION_WITH_INFO]);