Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
},
"require": {
"php": "~7.0",
"guzzlehttp/guzzle": "~6.1",
"justinrainbow/json-schema": "~5.2"
"guzzlehttp/guzzle": "^6.1",
"justinrainbow/json-schema": "^5.2"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"psr/log": "^1.0",
"satooshi/php-coveralls": "^2.0",
"php-coveralls/php-coveralls": "^2.0",
"jakub-onderka/php-parallel-lint": "^1.0",
"friendsofphp/php-cs-fixer": "^2.9"
"friendsofphp/php-cs-fixer": "^2.13"
},
"extra": {
"branch-alias": {
Expand Down
60 changes: 51 additions & 9 deletions src/BlockStorage/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function postVolumes(): array
'imageId' => $this->params->imageRef(),
'volumeType' => $this->params->volumeType(),
'metadata' => $this->params->metadata(),
'projectId' => $this->params->projectId(),
],
];
}
Expand Down Expand Up @@ -191,21 +192,21 @@ public function getSnapshots(): array
'method' => 'GET',
'path' => 'snapshots',
'params' => [
'marker' => $this->params->marker(),
'limit' => $this->params->limit(),
'sortDir' => $this->params->sortDir(),
'sortKey' => $this->params->sortKey(),
'marker' => $this->params->marker(),
'limit' => $this->params->limit(),
'sortDir' => $this->params->sortDir(),
'sortKey' => $this->params->sortKey(),
'allTenants' => $this->params->allTenants(),
],
];
}

public function getSnapshotsDetail(): array
{
return [
'method' => 'GET',
'path' => 'snapshots/detail',
'params' => [],
];
$api = $this->getSnapshots();
$api['path'] .= '/detail';

return $api;
}

public function getSnapshot(): array
Expand Down Expand Up @@ -304,4 +305,45 @@ public function putQuotaSet(): array
],
];
}

public function postVolumeBootable(): array
{
return [
'method' => 'POST',
'path' => 'volumes/{id}/action',
'jsonKey' => 'os-set_bootable',
'params' => [
'id' => $this->params->idPath(),
'bootable' => $this->params->bootable(),
],
];
}

public function postImageMetadata(): array
{
return [
'method' => 'POST',
'path' => 'volumes/{id}/action',
'jsonKey' => 'os-set_image_metadata',
'params' => [
'id' => $this->params->idPath(),
'metadata' => $this->params->metadata(),
],
];
}

public function postResetStatus(): array
{
return [
'method' => 'POST',
'path' => 'volumes/{id}/action',
'jsonKey' => 'os-reset_status',
'params' => [
'id' => $this->params->idPath(),
'status' => $this->params->volumeStatus(),
'migrationStatus' => $this->params->volumeMigrationStatus(),
'attachStatus' => $this->params->volumeAttachStatus(),
],
];
}
}
6 changes: 5 additions & 1 deletion src/BlockStorage/v2/Models/Snapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ class Snapshot extends OperatorResource implements Listable, Creatable, Updateab
/** @var int */
public $size;

/** @var string */
public $projectId;

protected $resourceKey = 'snapshot';
protected $resourcesKey = 'snapshots';
protected $markerKey = 'id';

protected $aliases = [
'volume_id' => 'volumeId',
'volume_id' => 'volumeId',
'os-extended-snapshot-attributes:project_id' => 'projectId',
];

/**
Expand Down
40 changes: 40 additions & 0 deletions src/BlockStorage/v2/Models/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Volume extends OperatorResource implements Creatable, Listable, Updateable
/** @var string */
public $host;

/** @var string */
public $bootable;

/** @var array */
public $metadata = [];

Expand Down Expand Up @@ -156,4 +159,41 @@ public function parseMetadata(ResponseInterface $response): array

return isset($json['metadata']) ? $json['metadata'] : [];
}

/**
* Update the bootable status for a volume, mark it as a bootable volume.
*
* @param bool $bootable
*/
public function setBootable(bool $bootable = true)
{
$this->execute($this->api->postVolumeBootable(), ['id' => $this->id, 'bootable' => $bootable]);
}

/**
* Sets the image metadata for a volume.
*
* @param array $metadata
*/
public function setImageMetadata(array $metadata)
{
$this->execute($this->api->postImageMetadata(), ['id' => $this->id, 'metadata' => $metadata]);
}

/**
* Administrator only. Resets the status, attach status, and migration status for a volume. Specify the os-reset_status action in the request body.
*
* @param array $options
*
* $options['status'] = (string) The volume status.
* $options['migrationStatus'] = (string) The volume migration status.
* $options['attachStatus'] = (string) The volume attach status. [OPTIONAL]
*
* @see https://developer.openstack.org/api-ref/block-storage/v2/index.html#volume-actions-volumes-action
*/
public function resetStatus(array $options)
{
$options = array_merge($options, ['id' => $this->id]);
$this->execute($this->api->postResetStatus(), $options);
}
}
51 changes: 51 additions & 0 deletions src/BlockStorage/v2/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,47 @@ public function volumeType(): array
];
}

public function bootable(): array
{
return [
'type' => self::BOOL_TYPE,
'location' => self::JSON,
'description' => 'Enables or disables the bootable attribute. You can boot an instance from a bootable volume.',
];
}

public function volumeStatus(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'required' => true,
'description' => 'The volume status.',
];
}

public function volumeMigrationStatus(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'required' => false,
'description' => 'The volume migration status.',
'sentAs' => 'migration_status',
];
}

public function volumeAttachStatus(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'required' => false,
'description' => 'The volume attach status.',
'sentAs' => 'attach_status',
];
}

public function metadata(): array
{
return [
Expand Down Expand Up @@ -226,4 +267,14 @@ public function quotaSetVolumesIscsi(): array
{
return $this->quotaSetLimit('volumes_iscsi', 'The number of allowed volumes iscsi');
}

public function projectId(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::URL,
'sentAs' => 'project_id',
'description' => 'The UUID of the project in a multi-tenancy cloud.',
];
}
}
2 changes: 2 additions & 0 deletions src/Compute/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ public function postKeypair(): array
'params' => [
'name' => $this->isRequired($this->params->name('keypair')),
'publicKey' => $this->params->keypairPublicKey(),
'type' => $this->params->keypairType(),
'userId' => $this->params->keypairUserId(),
],
];
}
Expand Down
4 changes: 4 additions & 0 deletions src/Compute/v2/Models/Keypair.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class Keypair extends OperatorResource implements Listable, Retrievable, Deletab
/** @var string */
public $userId;

/** @var string */
public $type;

/** @var string */
public $id;

Expand All @@ -47,6 +50,7 @@ class Keypair extends OperatorResource implements Listable, Retrievable, Deletab
'public_key' => 'publicKey',
'private_key' => 'privateKey',
'user_id' => 'userId',
'type' => 'type',
];

protected $resourceKey = 'keypair';
Expand Down
19 changes: 19 additions & 0 deletions src/Compute/v2/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,25 @@ public function userId(): array
];
}

public function keypairUserId(): array
{
return [
'type' => self::STRING_TYPE,
'sentAs' => 'user_id',
'location' => self::JSON,
'description' => 'This allows administrative users to upload keys for other users than themselves. Requires micro version 2.10.',
];
}

public function keypairType(): array
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'description' => 'The type of the keypair. Allowed values are ssh or x509. Require micro version 2.2.',
];
}

public function flavorRam(): array
{
return [
Expand Down
10 changes: 6 additions & 4 deletions src/Networking/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public function getNetworks(): array
'method' => 'GET',
'path' => $this->pathPrefix.'/networks',
'params' => [
'name' => $this->params->queryName(),
'tenantId' => $this->params->queryTenantId(),
'status' => $this->params->queryStatus(),
'name' => $this->params->queryName(),
'tenantId' => $this->params->queryTenantId(),
'status' => $this->params->queryStatus(),
'routerExternal' => $this->params->queryRouterExternal(),
],
];
}
Expand Down Expand Up @@ -201,7 +202,7 @@ public function getPorts(): array
'displayName' => $this->params->displayNameQuery(),
'adminState' => $this->params->adminStateQuery(),
'networkId' => $this->notRequired($this->params->networkId()),
'tenantId' => $this->params->tenantId(),
'tenantId' => $this->params->tenantIdQuery(),
'deviceOwner' => $this->params->deviceOwnerQuery(),
'macAddress' => $this->params->macAddrQuery(),
'portId' => $this->params->portIdQuery(),
Expand Down Expand Up @@ -230,6 +231,7 @@ public function postSinglePort(): array
'allowedAddressPairs' => $this->params->allowedAddrPairs(),
'deviceOwner' => $this->params->deviceOwner(),
'deviceId' => $this->params->deviceId(),
'portSecurityEnabled' => $this->params->portSecurityEnabled(),
],
];
}
Expand Down
3 changes: 2 additions & 1 deletion src/Networking/v2/Extensions/Layer3/Models/FixedIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FixedIp extends AbstractResource
public $ip;

protected $aliases = [
'subnet_id' => 'subnetId',
'subnet_id' => 'subnetId',
'ip_address' => 'ip',
];
}
5 changes: 5 additions & 0 deletions src/Networking/v2/Extensions/Layer3/Models/FloatingIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ public function retrieve()
$response = $this->executeWithState($this->api->getFloatingIp());
$this->populateFromResponse($response);
}

public function associatePort(string $portId)
{
$this->execute($this->api->putFloatingIp(), ['id' => $this->id, 'portId' => $portId]);
}
}
4 changes: 2 additions & 2 deletions src/Networking/v2/Extensions/Layer3/Models/GatewayInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GatewayInfo extends AbstractResource
/** @var string */
public $enableSnat;

/** @var []FixedIp */
/** @var FixedIp[] */
public $fixedIps;

protected $aliases = [
Expand All @@ -27,7 +27,7 @@ class GatewayInfo extends AbstractResource
protected function getAliases(): array
{
return parent::getAliases() + [
'fixed_ips' => new Alias('fixedIps', FixedIp::class, true),
'external_fixed_ips' => new Alias('fixedIps', FixedIp::class, true),
];
}
}
5 changes: 4 additions & 1 deletion src/Networking/v2/Extensions/SecurityGroups/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public function getSecurityGroups()
return [
'method' => 'GET',
'path' => $this->pathPrefix.'/security-groups',
'params' => [],
'params' => [
'tenantId' => $this->params->queryTenantId(),
'name' => $this->params->filterName(),
],
];
}

Expand Down
9 changes: 9 additions & 0 deletions src/Networking/v2/Extensions/SecurityGroups/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,13 @@ public function tenantIdJson()
'description' => 'The UUID of the tenant who owns the security group rule. Only administrative users can specify a tenant UUID other than their own.',
];
}

public function filterName(): array
{
return [
'description' => sprintf('Filter the list result by the human-readable name of the resource'),
'type' => self::STRING_TYPE,
'location' => self::QUERY,
];
}
}
Loading