Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 5dfc40d

Browse files
authored
Merge pull request #5 from illegalstudio/rbac-policies
Rbac policies
2 parents e4df74e + d32e4cf commit 5dfc40d

File tree

5 files changed

+277
-26
lines changed

5 files changed

+277
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v3.2.1.11
2+
3+
- Introduced Rbac policies
4+
15
# v3.2.1.10
26

37
- Introduced BlockStorage v3 as a replica of v2

src/Networking/v2/Api.php

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public function getLoadBalancerMembers(): array
550550
'method' => 'GET',
551551
'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members',
552552
'params' => [
553-
'poolId' => $this->params->poolId(),
553+
'poolId' => $this->params->poolId(),
554554
],
555555
];
556556
}
@@ -561,8 +561,8 @@ public function getLoadBalancerMember(): array
561561
'method' => 'GET',
562562
'path' => $this->pathPrefix.'/lbaas/pools/{poolId}/members/{id}',
563563
'params' => [
564-
'id' => $this->params->idPath('member'),
565-
'poolId' => $this->params->poolId(),
564+
'id' => $this->params->idPath('member'),
565+
'poolId' => $this->params->poolId(),
566566
],
567567
];
568568
}
@@ -617,7 +617,7 @@ public function getLoadBalancerStats(): array
617617
'method' => 'GET',
618618
'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/stats',
619619
'params' => [
620-
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
620+
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
621621
],
622622
];
623623
}
@@ -628,7 +628,7 @@ public function getLoadBalancerStatuses(): array
628628
'method' => 'GET',
629629
'path' => $this->pathPrefix.'/lbaas/loadbalancers/{loadbalancerId}/statuses',
630630
'params' => [
631-
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
631+
'loadbalancerId' => $this->params->loadBalancerIdUrl(),
632632
],
633633
];
634634
}
@@ -699,8 +699,55 @@ public function deleteLoadBalancerHealthMonitor(): array
699699
'method' => 'DELETE',
700700
'path' => $this->pathPrefix.'/lbaas/healthmonitors/{id}',
701701
'params' => [
702-
'id' => $this->params->idPath(),
702+
'id' => $this->params->idPath(),
703+
],
704+
];
705+
}
706+
707+
public function getRbacPolicies(): array
708+
{
709+
return [
710+
'method' => 'GET',
711+
'path' => $this->pathPrefix.'/rbac-policies',
712+
'params' => []
713+
];
714+
}
715+
716+
public function postRbacPolicy(): array
717+
{
718+
return [
719+
'method' => 'POST',
720+
'path' => $this->pathPrefix.'/rbac-policies',
721+
'jsonKey' => 'rbac_policy',
722+
'params' => [
723+
'target_tenant' => $this->params->targetTenant(),
724+
'object_type' => $this->params->objectType(),
725+
'object_id' => $this->params->objectId(),
726+
'action' => $this->params->action(),
727+
'project_id' => $this->params->projectIdJson(),
728+
]
729+
];
730+
}
731+
732+
public function getRbacPolicy(): array
733+
{
734+
return [
735+
'method' => 'GET',
736+
'path' => $this->pathPrefix.'/rbac-policies/{id}',
737+
'params' => [
738+
'id' => $this->params->idPath(),
703739
],
704740
];
705741
}
742+
743+
public function deleteRbacPolicy(): array
744+
{
745+
return [
746+
'method' => 'DELETE',
747+
'path' => $this->pathPrefix.'/rbac-policies/{id}',
748+
'params' => [
749+
'id' => $this->params->idPath()
750+
]
751+
];
752+
}
706753
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OpenStack\Networking\v2\Models;
6+
7+
use OpenStack\Common\Resource\Creatable;
8+
use OpenStack\Common\Resource\Deletable;
9+
use OpenStack\Common\Resource\HasWaiterTrait;
10+
use OpenStack\Common\Resource\Listable;
11+
use OpenStack\Common\Resource\OperatorResource;
12+
use OpenStack\Common\Resource\Retrievable;
13+
use OpenStack\Networking\v2\Api;
14+
15+
/**
16+
* @property Api $api
17+
*/
18+
class RbacPolicy extends OperatorResource implements Creatable, Deletable, Listable, Retrievable
19+
{
20+
use HasWaiterTrait;
21+
22+
/**
23+
* The ID of the tenant to which the RBAC policy will be enforced
24+
*
25+
* @var string
26+
*/
27+
public $targetTenant;
28+
29+
/**
30+
* The ID of the project that owns the resource
31+
*
32+
* @var string
33+
*/
34+
public $tenantId;
35+
36+
/**
37+
* The type of the object that the RBAC policy affects. Types include qos-policy, network, security-group,
38+
* address-scope, subnetpool or address-group
39+
*
40+
* @var string
41+
*/
42+
public $objectType;
43+
44+
/**
45+
* The ID of the object_type resource. An object_type of network returns a network ID, an object_type of qos-policy
46+
* returns a QoS policy ID, an object_type of security-group returns a security group ID, an object_type of
47+
* address-scope returns a address scope ID, an object_type of subnetpool returns a subnetpool ID and an
48+
* object_type of address-group returns an address group ID
49+
*
50+
* @var string
51+
*/
52+
public $objectId;
53+
54+
/**
55+
* Action for the RBAC policy which is access_as_external or access_as_shared
56+
*
57+
* @var string
58+
*/
59+
public $action;
60+
61+
/**
62+
* The ID of the project.
63+
*
64+
* @var string
65+
*/
66+
public $projectId;
67+
68+
/**
69+
* The ID of the RBAC policy
70+
*
71+
* @var string
72+
*/
73+
public $id;
74+
75+
protected $aliases = [
76+
'target_tenant' => 'targetTenant',
77+
'tenant_id' => 'tenantId',
78+
'object_type' => 'objectType',
79+
'object_id' => 'objectId',
80+
'project_id' => 'projectId',
81+
];
82+
83+
protected $resourceKey = 'rbac_policy';
84+
protected $resourcesKey = 'rbac_policies';
85+
86+
/**
87+
* {@inheritDoc}
88+
*/
89+
public function create(array $userOptions): Creatable
90+
{
91+
$response = $this->execute($this->api->postRbacPolicy(), $userOptions);
92+
93+
return $this->populateFromResponse($response);
94+
}
95+
96+
/**
97+
* {@inheritDoc}
98+
*/
99+
public function retrieve()
100+
{
101+
$reponse = $this->execute($this->api->getRbacPolicy(), ['id' => (string) $this->id]);
102+
$this->populateFromResponse($reponse);
103+
}
104+
105+
/**
106+
* {@inheritDoc}
107+
*/
108+
public function delete()
109+
{
110+
$this->executeWithState($this->api->deleteRbacPolicy());
111+
}
112+
}

0 commit comments

Comments
 (0)