Skip to content

Commit ea68123

Browse files
authored
ADB-600: PCloud Accounts, Safes and Platforms support (#25)
* PCloud Accounts, Safes and Platforms support * Minor fix
1 parent e5bcd49 commit ea68123

File tree

77 files changed

+2743
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2743
-4
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ CyberArk's Official SDK and CLI for different services operations
4141
- [x] Identity Roles Service
4242
- [x] Identity Policies Service
4343
- [x] Identity Directories Service
44+
- [x] PCloud Accounts Service
45+
- [x] PCloud Safes Service
46+
- [x] PCloud Platforms Service
4447
- [x] All services contains CRUD and Statistics per respective service
4548
- [x] Ready to use SDK in Python
4649
- [x] CLI and SDK Examples
@@ -221,6 +224,10 @@ The following services and commands are supported:
221224
- <b>roles</b> - Identity Roles Management
222225
- <b>policies</b> - Identity Policies Management
223226
- <b>directories</b> - Identity Directories Reading
227+
- <b>pcloud</b> - PCloud Service
228+
- <b>accounts</b> - PCloud Accounts Management
229+
- <b>safes</b> - PCloud Safes Management
230+
- <b>platforms</b> - PCloud Platforms Management
224231
225232
Any command has its own subcommands, with respective arguments
226233
@@ -298,6 +305,21 @@ Generate kubectl config file and save on specific path
298305
ark exec dpa k8s generate-kubeconfig --folder=/Users/My.User/.kube
299306
```
300307
308+
Create a PCloud Safe
309+
```shell
310+
ark exec pcloud safes add-safe --safe-name=safe
311+
```
312+
313+
Create a PCloud Account
314+
```shell
315+
ark exec pcloud accounts add-account --name account --safe-name safe --platform-id='UnixSSH' --username root --address 1.2.3.4 --secret-type=password --secret mypass
316+
```
317+
318+
List available platforms
319+
```shell
320+
ark exec pcloud platforms list-platforms
321+
```
322+
301323
You can view all of the commands via the --help for each respective exec action
302324
303325
Notes:

ark_sdk_python/ark_api.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,39 @@ def sm(self) -> "ArkSMService":
235235
from ark_sdk_python.services.sm import ArkSMService
236236

237237
return cast(ArkSMService, self.service(ArkSMService))
238+
239+
@property
240+
def pcloud_accounts(self) -> "ArkPCloudAccountsService":
241+
"""
242+
Returns the PCloud Accounts service if the appropriate authenticators were given
243+
244+
Returns:
245+
ArkPCloudAccountsService: _description_
246+
"""
247+
from ark_sdk_python.services.pcloud.accounts import ArkPCloudAccountsService
248+
249+
return cast(ArkPCloudAccountsService, self.service(ArkPCloudAccountsService))
250+
251+
@property
252+
def pcloud_safes(self) -> "ArkPCloudSafesService":
253+
"""
254+
Returns the PCloud Safes service if the appropriate authenticators were given
255+
256+
Returns:
257+
ArkPCloudSafesService: _description_
258+
"""
259+
from ark_sdk_python.services.pcloud.safes import ArkPCloudSafesService
260+
261+
return cast(ArkPCloudSafesService, self.service(ArkPCloudSafesService))
262+
263+
@property
264+
def pcloud_platforms(self) -> "ArkPCloudPlatformsService":
265+
"""
266+
Returns the PCloud Platforms service if the appropriate authenticators were given
267+
268+
Returns:
269+
ArkPCloudPlatformsService: _description_
270+
"""
271+
from ark_sdk_python.services.pcloud.platforms import ArkPCloudPlatformsService
272+
273+
return cast(ArkPCloudPlatformsService, self.service(ArkPCloudPlatformsService))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pprint
2+
3+
from ark_sdk_python.auth import ArkISPAuth
4+
from ark_sdk_python.models.auth import ArkAuthMethod, ArkAuthProfile, ArkSecret, IdentityArkAuthMethodSettings
5+
from ark_sdk_python.services.pcloud.accounts import ArkPCloudAccountsService
6+
7+
if __name__ == '__main__':
8+
isp_auth = ArkISPAuth(cache_authentication=False)
9+
isp_auth.authenticate(
10+
auth_profile=ArkAuthProfile(
11+
username='[email protected]',
12+
auth_method=ArkAuthMethod.Identity,
13+
auth_method_settings=IdentityArkAuthMethodSettings(),
14+
),
15+
secret=ArkSecret(secret="CoolPassword"),
16+
)
17+
accounts_service = ArkPCloudAccountsService(isp_auth=isp_auth)
18+
for page in accounts_service.list_accounts():
19+
for item in page:
20+
pprint.pprint(item.dict())

ark_sdk_python/models/actions/services/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
from ark_sdk_python.models.actions.services.ark_dpa_exec_action_consts import DPA_ACTIONS
44
from ark_sdk_python.models.actions.services.ark_identity_exec_action_consts import IDENTITY_ACTIONS
5+
from ark_sdk_python.models.actions.services.ark_pcloud_exec_action_consts import PCLOUD_ACTIONS
56
from ark_sdk_python.models.actions.services.ark_sm_exec_action_consts import SM_ACTIONS
67

78
SUPPORTED_SERVICE_ACTIONS: List[Any] = [
89
IDENTITY_ACTIONS,
910
DPA_ACTIONS,
1011
SM_ACTIONS,
12+
PCLOUD_ACTIONS,
1113
]
1214

1315
__all__ = [
1416
'IDENTITY_ACTIONS',
1517
'DPA_ACTIONS',
1618
'SM_ACTIONS',
19+
'PCLOUD_ACTIONS',
1720
'SUPPORTED_SERVICE_ACTIONS',
1821
]
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
from typing import Dict, Final, Optional, Type
2+
3+
from ark_sdk_python.models import ArkModel
4+
from ark_sdk_python.models.actions.ark_service_action_definition import ArkServiceActionDefinition
5+
from ark_sdk_python.models.services.pcloud.accounts import (
6+
ArkPCloudAccountsFilter,
7+
ArkPCloudAddAccount,
8+
ArkPCloudChangeAccountCredentials,
9+
ArkPCloudDeleteAccount,
10+
ArkPCloudGenerateAccountCredentials,
11+
ArkPCloudGetAccount,
12+
ArkPCloudGetAccountCredentials,
13+
ArkPCloudLinkAccount,
14+
ArkPCloudListAccountSecretVersions,
15+
ArkPCloudReconcileAccountCredentials,
16+
ArkPCloudSetAccountNextCredentials,
17+
ArkPCloudUnlinkAccount,
18+
ArkPCloudUpdateAccount,
19+
ArkPCloudUpdateAccountCredentialsInVault,
20+
ArkPCloudVerifyAccountCredentials,
21+
)
22+
from ark_sdk_python.models.services.pcloud.platforms import (
23+
ArkPCloudActivateTargetPlatform,
24+
ArkPCloudDeactivateTargetPlatform,
25+
ArkPCloudDeleteTargetPlatform,
26+
ArkPCloudDuplicateTargetPlatform,
27+
ArkPCloudExportPlatform,
28+
ArkPCloudExportTargetPlatform,
29+
ArkPCloudGetPlatform,
30+
ArkPCloudGetTargetPlatform,
31+
ArkPCloudImportPlatform,
32+
ArkPCloudImportTargetPlatform,
33+
ArkPCloudPlatformsFilter,
34+
ArkPCloudTargetPlatformsFilter,
35+
)
36+
from ark_sdk_python.models.services.pcloud.safes import (
37+
ArkPCloudAddSafe,
38+
ArkPCloudAddSafeMember,
39+
ArkPCloudDeleteSafe,
40+
ArkPCloudDeleteSafeMember,
41+
ArkPCloudGetSafe,
42+
ArkPCloudGetSafeMember,
43+
ArkPCloudGetSafeMembersStats,
44+
ArkPCloudListSafeMembers,
45+
ArkPCloudSafeMembersFilters,
46+
ArkPCloudSafesFilters,
47+
ArkPCloudUpdateSafe,
48+
ArkPCloudUpdateSafeMember,
49+
)
50+
51+
# PCloud Accounts Definitions
52+
PCLOUD_ACCOUNTS_ACTION_TO_SCHEMA_MAP: Final[Dict[str, Optional[Type[ArkModel]]]] = {
53+
'add-account': ArkPCloudAddAccount,
54+
'update-account': ArkPCloudUpdateAccount,
55+
'delete-account': ArkPCloudDeleteAccount,
56+
'account': ArkPCloudGetAccount,
57+
'account-credentials': ArkPCloudGetAccountCredentials,
58+
'list-accounts': None,
59+
'list-accounts-by': ArkPCloudAccountsFilter,
60+
'list-account-secret-versions': ArkPCloudListAccountSecretVersions,
61+
'generate-account-credentials': ArkPCloudGenerateAccountCredentials,
62+
'verify-account-credentials': ArkPCloudVerifyAccountCredentials,
63+
'change-account-credentials': ArkPCloudChangeAccountCredentials,
64+
'set-account-next-credentials': ArkPCloudSetAccountNextCredentials,
65+
'update-account-credentials-in-vault': ArkPCloudUpdateAccountCredentialsInVault,
66+
'reconcile-account-credentials': ArkPCloudReconcileAccountCredentials,
67+
'accounts-stats': None,
68+
'link-account': ArkPCloudLinkAccount,
69+
'unlink-account': ArkPCloudUnlinkAccount,
70+
}
71+
PCLOUD_ACCOUNTS_ACTION: Final[ArkServiceActionDefinition] = ArkServiceActionDefinition(
72+
action_name='accounts',
73+
schemas=PCLOUD_ACCOUNTS_ACTION_TO_SCHEMA_MAP,
74+
)
75+
76+
# PCloud Safes Definitions
77+
PCLOUD_SAFES_ACTION_TO_SCHEMA_MAP: Final[Dict[str, Optional[Type[ArkModel]]]] = {
78+
'add-safe': ArkPCloudAddSafe,
79+
'update-safe': ArkPCloudUpdateSafe,
80+
'delete-safe': ArkPCloudDeleteSafe,
81+
'safe': ArkPCloudGetSafe,
82+
'list-safes': None,
83+
'list-safes-by': ArkPCloudSafesFilters,
84+
'safes-stats': None,
85+
'add-safe-member': ArkPCloudAddSafeMember,
86+
'update-safe-member': ArkPCloudUpdateSafeMember,
87+
'delete-safe-member': ArkPCloudDeleteSafeMember,
88+
'safe-member': ArkPCloudGetSafeMember,
89+
'list-safe-members': ArkPCloudListSafeMembers,
90+
'list-safe-members-by': ArkPCloudSafeMembersFilters,
91+
'safe-members-stats': ArkPCloudGetSafeMembersStats,
92+
'safes-members-stats': None,
93+
}
94+
PCLOUD_SAFES_ACTION: Final[ArkServiceActionDefinition] = ArkServiceActionDefinition(
95+
action_name='safes',
96+
schemas=PCLOUD_SAFES_ACTION_TO_SCHEMA_MAP,
97+
)
98+
99+
# PCloud Platforms Definitions
100+
PCLOUD_PLATFORMS_ACTION_TO_SCHEMA_MAP: Final[Dict[str, Optional[Type[ArkModel]]]] = {
101+
'list-platforms': None,
102+
'list-platforms-by': ArkPCloudPlatformsFilter,
103+
'import-platform': ArkPCloudImportPlatform,
104+
'import-target-platform': ArkPCloudImportTargetPlatform,
105+
'export-platform': ArkPCloudExportPlatform,
106+
'export-target-platform': ArkPCloudExportTargetPlatform,
107+
'platform': ArkPCloudGetPlatform,
108+
'platforms-stats': None,
109+
'activate-target-platform': ArkPCloudActivateTargetPlatform,
110+
'deactivate-target-platform': ArkPCloudDeactivateTargetPlatform,
111+
'list-target-platforms': None,
112+
'list-target-platforms-by': ArkPCloudTargetPlatformsFilter,
113+
'target-platform': ArkPCloudGetTargetPlatform,
114+
'delete-target-platform': ArkPCloudDeleteTargetPlatform,
115+
'duplicate-target-platform': ArkPCloudDuplicateTargetPlatform,
116+
'target-platforms-stats': None,
117+
}
118+
PCLOUD_PLATFORMS_ACTION: Final[ArkServiceActionDefinition] = ArkServiceActionDefinition(
119+
action_name='platforms',
120+
schemas=PCLOUD_PLATFORMS_ACTION_TO_SCHEMA_MAP,
121+
)
122+
123+
# Service Actions Definition
124+
PCLOUD_ACTIONS: Final[ArkServiceActionDefinition] = ArkServiceActionDefinition(
125+
action_name='pcloud',
126+
subactions=[
127+
PCLOUD_ACCOUNTS_ACTION,
128+
PCLOUD_PLATFORMS_ACTION,
129+
PCLOUD_SAFES_ACTION,
130+
],
131+
)

ark_sdk_python/models/services/dpa/workspaces/db/ark_dpa_db_auth_method.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ArkDPADBAuthMethodType(str, Enum):
1313
ADEphemeralUser = 'ad_ephemeral_user'
1414
LocalEphemeralUser = 'local_ephemeral_user'
1515
RDSIAMAuthentication = 'rds_iam_authentication'
16+
AtlasEphemeralUser = 'atlas_ephemeral_user'
1617

1718

1819
class ArkDPADBAuthMethod(ArkCamelizedModel):

ark_sdk_python/models/services/pcloud/__init__.py

Whitespace-only changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_account import (
2+
ArkPCloudAccount,
3+
ArkPCloudAccountRemoteMachinesAccess,
4+
ArkPCloudAccountSecretManagement,
5+
ArkPCloudAccountSecretType,
6+
ArkPCloudBaseAccount,
7+
)
8+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_account_credentials import ArkPCloudAccountCredentials
9+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_account_secret_version import ArkPCloudAccountSecretVersion
10+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_accounts_filter import ArkPCloudAccountsFilter
11+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_accounts_stats import ArkPCloudAccountsStats
12+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_add_account import ArkPCloudAddAccount
13+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_change_account_credentials import ArkPCloudChangeAccountCredentials
14+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_delete_account import ArkPCloudDeleteAccount
15+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_generate_account_credentials import ArkPCloudGenerateAccountCredentials
16+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_get_account import ArkPCloudGetAccount
17+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_get_account_credentials import ArkPCloudGetAccountCredentials
18+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_link_account import ArkPCloudLinkAccount
19+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_list_account_secret_versions import ArkPCloudListAccountSecretVersions
20+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_reconcile_account_credentials import ArkPCloudReconcileAccountCredentials
21+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_set_account_next_credentials import ArkPCloudSetAccountNextCredentials
22+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_unlink_account import ArkPCloudUnlinkAccount
23+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_update_account import ArkPCloudUpdateAccount
24+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_update_account_credentials_in_vault import (
25+
ArkPCloudUpdateAccountCredentialsInVault,
26+
)
27+
from ark_sdk_python.models.services.pcloud.accounts.ark_pcloud_verify_account_credentias import ArkPCloudVerifyAccountCredentials
28+
29+
__all__ = [
30+
'ArkPCloudBaseAccount',
31+
'ArkPCloudAccount',
32+
'ArkPCloudAccountRemoteMachinesAccess',
33+
'ArkPCloudAccountSecretManagement',
34+
'ArkPCloudAccountSecretType',
35+
'ArkPCloudAccountsFilter',
36+
'ArkPCloudAccountsStats',
37+
'ArkPCloudAddAccount',
38+
'ArkPCloudDeleteAccount',
39+
'ArkPCloudGetAccount',
40+
'ArkPCloudUpdateAccount',
41+
'ArkPCloudAccountSecretVersion',
42+
'ArkPCloudListAccountSecretVersions',
43+
'ArkPCloudAccountCredentials',
44+
'ArkPCloudGenerateAccountCredentials',
45+
'ArkPCloudVerifyAccountCredentials',
46+
'ArkPCloudChangeAccountCredentials',
47+
'ArkPCloudSetAccountNextCredentials',
48+
'ArkPCloudUpdateAccountCredentialsInVault',
49+
'ArkPCloudReconcileAccountCredentials',
50+
'ArkPCloudGetAccountCredentials',
51+
'ArkPCloudLinkAccount',
52+
'ArkPCloudUnlinkAccount',
53+
]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from enum import Enum
2+
from typing import Any, Dict, List, Optional, Union
3+
4+
from pydantic import Field, validator
5+
6+
from ark_sdk_python.models import ArkCamelizedModel
7+
8+
9+
class ArkPCloudAccountSecretType(str, Enum):
10+
Password = "password"
11+
Key = "key"
12+
13+
14+
class ArkPCloudAccountSecretManagement(ArkCamelizedModel):
15+
automatic_management_enabled: Optional[bool] = Field(description='Whether automatic management of the account is enabled or not')
16+
manual_management_reason: Optional[str] = Field(description='The reason for disabling automatic management')
17+
last_modified_time: Optional[int] = Field(description='Last time the management properties were modified')
18+
19+
20+
class ArkPCloudAccountRemoteMachinesAccess(ArkCamelizedModel):
21+
remote_machines: Optional[Union[List[str], str]] = Field(description='Remote machines the access of this account is allowed')
22+
access_restricted_to_remote_machines: Optional[bool] = Field(
23+
description='Whether the access is only restricted to those remote machines'
24+
)
25+
26+
# pylint: disable=no-self-use,no-self-argument
27+
@validator('remote_machines')
28+
def _validate_remote_machines(remote_machines):
29+
# backward compatibility for when remote_machines was a comma separated string
30+
if isinstance(remote_machines, str):
31+
return remote_machines.split(',')
32+
return remote_machines
33+
34+
35+
class ArkPCloudBaseAccount(ArkCamelizedModel):
36+
name: str = Field(description='Name of the account')
37+
safe_name: str = Field(description='Safe name to store the account in')
38+
platform_id: Optional[str] = Field(description='Platform id to relate the account to')
39+
user_name: Optional[str] = Field(description='Username of the account')
40+
address: Optional[str] = Field(description='Address of the account')
41+
secret_type: Optional[ArkPCloudAccountSecretType] = Field(description='Type of the secret of the account')
42+
platform_account_properties: Optional[Dict[str, Any]] = Field(
43+
description='Different properties related to the platform the account is related to'
44+
)
45+
secret_management: Optional[ArkPCloudAccountSecretManagement] = Field(description='Secret mgmt related properties')
46+
remote_machines_access: Optional[ArkPCloudAccountRemoteMachinesAccess] = Field(description='Remote machines access related properties')
47+
48+
49+
class ArkPCloudAccount(ArkPCloudBaseAccount):
50+
id: str = Field(description='ID of the account')
51+
status: Optional[str] = Field(description='Status of the account')
52+
created_time: Optional[int] = Field(description='Creation time of the account')
53+
category_modification_time: Optional[int] = Field(description='Category modification time of the account')
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pydantic import Field, SecretStr
2+
3+
from ark_sdk_python.models import ArkModel
4+
5+
6+
class ArkPCloudAccountCredentials(ArkModel):
7+
account_id: str = Field(description='The id of the account')
8+
password: SecretStr = Field(description='The credentials')
9+
10+
class Config:
11+
json_encoders = {SecretStr: lambda v: v.get_secret_value()}

0 commit comments

Comments
 (0)