Skip to content

Commit

Permalink
Merge pull request #5 from illegalstudio/rbac-policies
Browse files Browse the repository at this point in the history
Rbac policies
  • Loading branch information
nahime0 authored Jul 3, 2023
2 parents e4df74e + d32e4cf commit 5dfc40d
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v3.2.1.11

- Introduced Rbac policies

# v3.2.1.10

- Introduced BlockStorage v3 as a replica of v2
Expand Down
59 changes: 53 additions & 6 deletions src/Networking/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public function getLoadBalancerMembers(): array
'method' => 'GET',
'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members',
'params' => [
'poolId' => $this->params->poolId(),
'poolId' => $this->params->poolId(),
],
];
}
Expand All @@ -561,8 +561,8 @@ public function getLoadBalancerMember(): array
'method' => 'GET',
'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members/{id}',
'params' => [
'id' => $this->params->idPath('member'),
'poolId' => $this->params->poolId(),
'id' => $this->params->idPath('member'),
'poolId' => $this->params->poolId(),
],
];
}
Expand Down Expand Up @@ -617,7 +617,7 @@ public function getLoadBalancerStats(): array
'method' => 'GET',
'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/stats',
'params' => [
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
],
];
}
Expand All @@ -628,7 +628,7 @@ public function getLoadBalancerStatuses(): array
'method' => 'GET',
'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/statuses',
'params' => [
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
],
];
}
Expand Down Expand Up @@ -699,8 +699,55 @@ public function deleteLoadBalancerHealthMonitor(): array
'method' => 'DELETE',
'path' => $this->pathPrefix.'/lbaas/healthmonitors/{id}',
'params' => [
'id' => $this->params->idPath(),
'id' => $this->params->idPath(),
],
];
}

public function getRbacPolicies(): array
{
return [
'method' => 'GET',
'path' => $this->pathPrefix.'/rbac-policies',
'params' => []
];
}

public function postRbacPolicy(): array
{
return [
'method' => 'POST',
'path' => $this->pathPrefix.'/rbac-policies',
'jsonKey' => 'rbac_policy',
'params' => [
'target_tenant' => $this->params->targetTenant(),
'object_type' => $this->params->objectType(),
'object_id' => $this->params->objectId(),
'action' => $this->params->action(),
'project_id' => $this->params->projectIdJson(),
]
];
}

public function getRbacPolicy(): array
{
return [
'method' => 'GET',
'path' => $this->pathPrefix.'/rbac-policies/{id}',
'params' => [
'id' => $this->params->idPath(),
],
];
}

public function deleteRbacPolicy(): array
{
return [
'method' => 'DELETE',
'path' => $this->pathPrefix.'/rbac-policies/{id}',
'params' => [
'id' => $this->params->idPath()
]
];
}
}
112 changes: 112 additions & 0 deletions src/Networking/v2/Models/RbacPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

declare(strict_types=1);

namespace OpenStack\Networking\v2\Models;

use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\HasWaiterTrait;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Networking\v2\Api;

/**
* @property Api $api
*/
class RbacPolicy extends OperatorResource implements Creatable, Deletable, Listable, Retrievable
{
use HasWaiterTrait;

/**
* The ID of the tenant to which the RBAC policy will be enforced
*
* @var string
*/
public $targetTenant;

/**
* The ID of the project that owns the resource
*
* @var string
*/
public $tenantId;

/**
* The type of the object that the RBAC policy affects. Types include qos-policy, network, security-group,
* address-scope, subnetpool or address-group
*
* @var string
*/
public $objectType;

/**
* The ID of the object_type resource. An object_type of network returns a network ID, an object_type of qos-policy
* returns a QoS policy ID, an object_type of security-group returns a security group ID, an object_type of
* address-scope returns a address scope ID, an object_type of subnetpool returns a subnetpool ID and an
* object_type of address-group returns an address group ID
*
* @var string
*/
public $objectId;

/**
* Action for the RBAC policy which is access_as_external or access_as_shared
*
* @var string
*/
public $action;

/**
* The ID of the project.
*
* @var string
*/
public $projectId;

/**
* The ID of the RBAC policy
*
* @var string
*/
public $id;

protected $aliases = [
'target_tenant' => 'targetTenant',
'tenant_id' => 'tenantId',
'object_type' => 'objectType',
'object_id' => 'objectId',
'project_id' => 'projectId',
];

protected $resourceKey = 'rbac_policy';
protected $resourcesKey = 'rbac_policies';

/**
* {@inheritDoc}
*/
public function create(array $userOptions): Creatable
{
$response = $this->execute($this->api->postRbacPolicy(), $userOptions);

return $this->populateFromResponse($response);
}

/**
* {@inheritDoc}
*/
public function retrieve()
{
$reponse = $this->execute($this->api->getRbacPolicy(), ['id' => (string) $this->id]);
$this->populateFromResponse($reponse);
}

/**
* {@inheritDoc}
*/
public function delete()
{
$this->executeWithState($this->api->deleteRbacPolicy());
}
}
Loading

0 comments on commit 5dfc40d

Please sign in to comment.