Skip to content

Commit

Permalink
add addAutodescription method
Browse files Browse the repository at this point in the history
  • Loading branch information
chregu committed Mar 15, 2024
1 parent 0d85982 commit f591556
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,30 @@ public function addAutolabels($hash, $organization = null): SourceImage
return SourceImage::createFromJsonResponse($content);
}

/**
* @param string[] $languages
* @param string $hash
* @param string|null $organization
* @param array $options, for example ['force' => true] to recreate
*/
public function addAutodescription($languages, $hash, $organization = null, array $options = []): SourceImage
{
$path = implode('/', [
self::SOURCEIMAGE_RESOURCE,
$this->getOrganizationName($organization),
$hash,
'autodescription',
]);
$force = isset($options['force']) && $options['force'] ? true : false;
$response = $this->call('POST', $path, ['json' => ['languages' => $languages, 'force' => $force]]);
if (!($response->getStatusCode() >= 200 && $response->getStatusCode() < 300)) {
throw new \LogicException($response->getBody()->getContents(), $response->getStatusCode());
}
$content = $response->getBody()->getContents();

return SourceImage::createFromJsonResponse($content);
}

/**
* Delete the given DynamicMetadata from a SourceImage.
* Returns the new Hash for the SourceImage, it could be the same as the input one if the operation
Expand Down

0 comments on commit f591556

Please sign in to comment.