createTags() public method

Adds or overwrites one or more tags for the specified EC2 resource or resources. Each resource can have a maximum of 10 tags. Each tag consists of a key and optional value. Tag keys must be unique per resource.
public createTags ( Scalr\Service\Aws\Ec2\DataType\ResourceTagSetList | Scalr\Service\Aws\Ec2\DataType\ResourceTagSetData | array $tagList ) : boolean
$tagList Scalr\Service\Aws\Ec2\DataType\ResourceTagSetList | Scalr\Service\Aws\Ec2\DataType\ResourceTagSetData | array The key/value pair list of the Tags.
return boolean Returns true on success or throws an exception otherwise
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @see AbstractServerImport::applyTags
  */
 protected function applyTags()
 {
     if (empty($this->instance)) {
         throw new ServerImportException("Instance property is empty. Cannot add tags to server");
     }
     $dbServer = DBServer::LoadByID($this->server->serverId);
     try {
         // Invar: move applyGlobalVarsToValue to Entity\Server
         $tags = [['key' => Scalr_Governance::SCALR_META_TAG_NAME, 'value' => $dbServer->applyGlobalVarsToValue(Scalr_Governance::SCALR_META_TAG_VALUE)]];
         foreach ($this->tags as $key => $value) {
             $tags[] = ['key' => $key, 'value' => $dbServer->applyGlobalVarsToValue($value)];
         }
         $this->instance->createTags($tags);
     } catch (Exception $e) {
         throw new ServerImportException(sprintf('Scalr was unable to add tags to server %s: %s', $this->server->serverId, $e->getMessage()), $e->getCode(), $e);
     }
 }