Skip to content

.

ArkAPI

Source code in ark_sdk_python/ark_api.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
class ArkAPI:
    def __init__(self, authenticators: List[ArkAuth], profile: Optional[ArkProfile] = None) -> None:
        self.__authenticators = authenticators
        self.__lazy_loaded_services: Dict[str, ArkService] = {}
        self.__profile = profile or ArkProfileLoader.load_default_profile()

    def __lazy_load_service(self, service_type: Type[ArkService]) -> ArkService:
        service_name = service_type.service_config().service_name
        required_auth_names = service_type.service_config().required_authenticator_names
        required_autheneticators = [auth for auth in self.__authenticators if auth.authenticator_name() in required_auth_names]
        optional_authenticators = [
            auth
            for auth in self.__authenticators
            if auth.authenticator_name() in service_type.service_config().optional_authenticator_names
        ]
        if len(required_autheneticators) == len(required_auth_names):
            authenticators = {f'{a.authenticator_name()}_auth': a for a in required_autheneticators + optional_authenticators}
            self.__lazy_loaded_services[service_name] = service_type(**authenticators)
        else:
            raise ArkServiceException(
                f'{service_name.title()} is not supported or missing fitting authenticators, please make sure you are logged in'
            )
        return self.__lazy_loaded_services[service_name]

    def authenticator(self, authenticator_name: str) -> ArkAuth:
        """
        Returns the specified authenticator.

        Args:
            authenticator_name (str): _description_

        Raises:
            ArkServiceException: _description_

        Returns:
            ArkAuth: _description_
        """
        for auth in self.__authenticators:
            if auth.authenticator_name() == authenticator_name:
                return auth
        raise ArkServiceException(f'{authenticator_name} is not supported or not found')

    def service(self, service_type: Type[ArkService]) -> ArkService:
        """
        Returns the specified service when the appropriate authenticators were provided.

        Args:
            service_type (Type[ArkService]): _description_

        Raises:
            ArkServiceException: _description_

        Returns:
            ArkService: _description_
        """
        if not issubclass(service_type, ArkService):
            raise ArkServiceException(f"Type {service_type} is invalid")
        service_name = service_type.service_config().service_name
        if service_name in self.__lazy_loaded_services:
            return self.__lazy_loaded_services[service_name]
        return self.__lazy_load_service(service_type)

    @property
    def profile(self) -> ArkProfile:
        """
        Gets the API profile

        Returns:
            ArkProfile: _description_
        """
        return self.__profile

    @property
    def identity_connectors(self) -> "ArkIdentityConnectorsService":
        """
        Returns the Identity Connectors Service if the appropriate authenticators were given

        Returns:
            ArkIdentityConnectorsService: _description_
        """
        from ark_sdk_python.services.identity.connectors import ArkIdentityConnectorsService

        return cast(ArkIdentityConnectorsService, self.service(ArkIdentityConnectorsService))

    @property
    def identity_directories(self) -> "ArkIdentityDirectoriesService":
        """
        Returns the Identity Directories Service if the appropriate authenticators were given

        Returns:
            ArkIdentityDirectoriesService: _description_
        """
        from ark_sdk_python.services.identity.directories import ArkIdentityDirectoriesService

        return cast(ArkIdentityDirectoriesService, self.service(ArkIdentityDirectoriesService))

    @property
    def identity_policies(self) -> "ArkIdentityPoliciesService":
        """
        Returns the Identity Policies Service if the appropriate authenticators were given

        Returns:
            ArkIdentityPoliciesService: _description_
        """
        from ark_sdk_python.services.identity.policies import ArkIdentityPoliciesService

        return cast(ArkIdentityPoliciesService, self.service(ArkIdentityPoliciesService))

    @property
    def identity_roles(self) -> "ArkIdentityRolesService":
        """
        Returns the Identity Roles Service if the appropriate authenticators were given

        Returns:
            ArkIdentityRolesService: _description_
        """
        from ark_sdk_python.services.identity.roles import ArkIdentityRolesService

        return cast(ArkIdentityRolesService, self.service(ArkIdentityRolesService))

    @property
    def identity_users(self) -> "ArkIdentityUsersService":
        """
        Returns the Identity Users Service if the appropriate authenticators were given

        Returns:
            ArkIdentityUsersService: _description_
        """
        from ark_sdk_python.services.identity.users import ArkIdentityUsersService

        return cast(ArkIdentityUsersService, self.service(ArkIdentityUsersService))

    @property
    def sia_access(self) -> "ArkSIAAccessService":
        """
        Returns the SIA Access service if the appropriate authenticators were given

        Returns:
            ArkSIAAccessService: _description_
        """
        from ark_sdk_python.services.sia.access import ArkSIAAccessService

        return cast(ArkSIAAccessService, self.service(ArkSIAAccessService))

    @property
    def sia_workspaces_db(self) -> "ArkSIADBWorkspaceService":
        """
        Returns the SIA DB Workspace service if the appropriate authenticators were provided.

        Returns:
            ArkSIADBWorkspaceService: _description_
        """
        from ark_sdk_python.services.sia.workspaces.db import ArkSIADBWorkspaceService

        return cast(ArkSIADBWorkspaceService, self.service(ArkSIADBWorkspaceService))

    @property
    def sia_workspaces_target_sets(self) -> "ArkSIATargetSetsWorkspaceService":
        """
        Returns the SIA Target Sets Workspace service if the appropriate authenticators were provided.

        Returns:
            ArkSIATargetSetsWorkspaceService: _description_
        """
        from ark_sdk_python.services.sia.workspaces.targetsets import ArkSIATargetSetsWorkspaceService

        return cast(ArkSIATargetSetsWorkspaceService, self.service(ArkSIATargetSetsWorkspaceService))

    @property
    def sia_policies_vm(self) -> "ArkSIAVMPoliciesService":
        """
        Returns the SIA VM Policies service if the appropriate authenticators were provided.

        Returns:
            ArkSIAVMPoliciesService: _description_
        """
        from ark_sdk_python.services.sia.policies.vm import ArkSIAVMPoliciesService

        return cast(ArkSIAVMPoliciesService, self.service(ArkSIAVMPoliciesService))

    @property
    def sia_policies_db(self) -> "ArkSIADBPoliciesService":
        """
        Returns the SIA DB Policies service if the appropriate authenticators were provided.

        Returns:
            ArkSIADBPoliciesService: _description_
        """
        from ark_sdk_python.services.sia.policies.db import ArkSIADBPoliciesService

        return cast(ArkSIADBPoliciesService, self.service(ArkSIADBPoliciesService))

    @property
    def sia_secrets_db(self) -> "ArkSIADBSecretsService":
        """
        Returns the SIA DB Secrets service if the appropriate authenticators were provided.

        Returns:
            ArkSIADBSecretsService: _description_
        """
        from ark_sdk_python.services.sia.secrets.db import ArkSIADBSecretsService

        return cast(ArkSIADBSecretsService, self.service(ArkSIADBSecretsService))

    @property
    def sia_secrets_vm(self) -> "ArkSIAVMSecretsService":
        """
        Returns the SIA VM Secrets service if the appropriate authenticators were provided.

        Returns:
            ArkSIAVMSecretsService: _description_
        """
        from ark_sdk_python.services.sia.secrets.vm import ArkSIAVMSecretsService

        return cast(ArkSIAVMSecretsService, self.service(ArkSIAVMSecretsService))

    @property
    def sia_sso(self) -> "ArkSIASSOService":
        """
        Returns the SIA sso service if the appropriate authenticators were provided.

        Returns:
            ArkSIASSOService: _description_
        """
        from ark_sdk_python.services.sia.sso import ArkSIASSOService

        return cast(ArkSIASSOService, self.service(ArkSIASSOService))

    @property
    def sia_db(self) -> "ArkSIADBService":
        """
        Returns the SIA DB service if the appropriate authenticators were provided.

        Returns:
            ArkSIADBService: _description_
        """
        from ark_sdk_python.services.sia.db import ArkSIADBService

        return cast(ArkSIADBService, self.service(ArkSIADBService))

    @property
    def sia_certificates(self) -> "ArkSIACertificatesService":
        """
        Returns SIA certificates service if the appropriate authenticators were provided.

        Returns:
            ArkSIACertificatesService: _description_
        """
        from ark_sdk_python.services.sia.certificates import ArkSIACertificatesService

        return cast(ArkSIACertificatesService, self.service(ArkSIACertificatesService))

    @property
    def sia_k8s(self) -> "ArkSIAK8SService":
        """
        Returns the SIA Policies service if the appropriate authenticators were provided.

        Returns:
            ArkSIAK8SService: _description_
        """
        from ark_sdk_python.services.sia.k8s import ArkSIAK8SService

        return cast(ArkSIAK8SService, self.service(ArkSIAK8SService))

    @property
    def sm(self) -> "ArkSMService":
        """
        Returns the SM service if the appropriate authenticators were given

        Returns:
            ArkSMService: _description_
        """
        from ark_sdk_python.services.sm import ArkSMService

        return cast(ArkSMService, self.service(ArkSMService))

    @property
    def pcloud_accounts(self) -> "ArkPCloudAccountsService":
        """
        Returns the PCloud Accounts service if the appropriate authenticators were given

        Returns:
            ArkPCloudAccountsService: _description_
        """
        from ark_sdk_python.services.pcloud.accounts import ArkPCloudAccountsService

        return cast(ArkPCloudAccountsService, self.service(ArkPCloudAccountsService))

    @property
    def pcloud_safes(self) -> "ArkPCloudSafesService":
        """
        Returns the PCloud Safes service if the appropriate authenticators were given

        Returns:
            ArkPCloudSafesService: _description_
        """
        from ark_sdk_python.services.pcloud.safes import ArkPCloudSafesService

        return cast(ArkPCloudSafesService, self.service(ArkPCloudSafesService))

    @property
    def pcloud_platforms(self) -> "ArkPCloudPlatformsService":
        """
        Returns the PCloud Platforms service if the appropriate authenticators were given

        Returns:
            ArkPCloudPlatformsService: _description_
        """
        from ark_sdk_python.services.pcloud.platforms import ArkPCloudPlatformsService

        return cast(ArkPCloudPlatformsService, self.service(ArkPCloudPlatformsService))

    @property
    def pcloud_applications(self) -> "ArkPCloudApplicationsService":
        """
        Returns the PCloud Applications service if the appropriate authenticators were given

        Returns:
            ArkPCloudApplicationsService: _description_
        """
        from ark_sdk_python.services.pcloud.applications import ArkPCloudApplicationsService

        return cast(ArkPCloudApplicationsService, self.service(ArkPCloudApplicationsService))

    @property
    def cmgr(self) -> "ArkCmgrService":
        """
        Returns the Connector Management service if the appropriate authenticators were given

        Returns:
            ArkCmgrService: _description_
        """
        from ark_sdk_python.services.cmgr import ArkCmgrService

        return cast(ArkCmgrService, self.service(ArkCmgrService))

cmgr property

Returns the Connector Management service if the appropriate authenticators were given

Returns:

Name Type Description
ArkCmgrService 'ArkCmgrService'

description

identity_connectors property

Returns the Identity Connectors Service if the appropriate authenticators were given

Returns:

Name Type Description
ArkIdentityConnectorsService 'ArkIdentityConnectorsService'

description

identity_directories property

Returns the Identity Directories Service if the appropriate authenticators were given

Returns:

Name Type Description
ArkIdentityDirectoriesService 'ArkIdentityDirectoriesService'

description

identity_policies property

Returns the Identity Policies Service if the appropriate authenticators were given

Returns:

Name Type Description
ArkIdentityPoliciesService 'ArkIdentityPoliciesService'

description

identity_roles property

Returns the Identity Roles Service if the appropriate authenticators were given

Returns:

Name Type Description
ArkIdentityRolesService 'ArkIdentityRolesService'

description

identity_users property

Returns the Identity Users Service if the appropriate authenticators were given

Returns:

Name Type Description
ArkIdentityUsersService 'ArkIdentityUsersService'

description

pcloud_accounts property

Returns the PCloud Accounts service if the appropriate authenticators were given

Returns:

Name Type Description
ArkPCloudAccountsService 'ArkPCloudAccountsService'

description

pcloud_applications property

Returns the PCloud Applications service if the appropriate authenticators were given

Returns:

Name Type Description
ArkPCloudApplicationsService 'ArkPCloudApplicationsService'

description

pcloud_platforms property

Returns the PCloud Platforms service if the appropriate authenticators were given

Returns:

Name Type Description
ArkPCloudPlatformsService 'ArkPCloudPlatformsService'

description

pcloud_safes property

Returns the PCloud Safes service if the appropriate authenticators were given

Returns:

Name Type Description
ArkPCloudSafesService 'ArkPCloudSafesService'

description

profile property

Gets the API profile

Returns:

Name Type Description
ArkProfile ArkProfile

description

sia_access property

Returns the SIA Access service if the appropriate authenticators were given

Returns:

Name Type Description
ArkSIAAccessService 'ArkSIAAccessService'

description

sia_certificates property

Returns SIA certificates service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIACertificatesService 'ArkSIACertificatesService'

description

sia_db property

Returns the SIA DB service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIADBService 'ArkSIADBService'

description

sia_k8s property

Returns the SIA Policies service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIAK8SService 'ArkSIAK8SService'

description

sia_policies_db property

Returns the SIA DB Policies service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIADBPoliciesService 'ArkSIADBPoliciesService'

description

sia_policies_vm property

Returns the SIA VM Policies service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIAVMPoliciesService 'ArkSIAVMPoliciesService'

description

sia_secrets_db property

Returns the SIA DB Secrets service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIADBSecretsService 'ArkSIADBSecretsService'

description

sia_secrets_vm property

Returns the SIA VM Secrets service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIAVMSecretsService 'ArkSIAVMSecretsService'

description

sia_sso property

Returns the SIA sso service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIASSOService 'ArkSIASSOService'

description

sia_workspaces_db property

Returns the SIA DB Workspace service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIADBWorkspaceService 'ArkSIADBWorkspaceService'

description

sia_workspaces_target_sets property

Returns the SIA Target Sets Workspace service if the appropriate authenticators were provided.

Returns:

Name Type Description
ArkSIATargetSetsWorkspaceService 'ArkSIATargetSetsWorkspaceService'

description

sm property

Returns the SM service if the appropriate authenticators were given

Returns:

Name Type Description
ArkSMService 'ArkSMService'

description

authenticator(authenticator_name)

Returns the specified authenticator.

Parameters:

Name Type Description Default
authenticator_name str

description

required

Raises:

Type Description
ArkServiceException

description

Returns:

Name Type Description
ArkAuth ArkAuth

description

Source code in ark_sdk_python/ark_api.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def authenticator(self, authenticator_name: str) -> ArkAuth:
    """
    Returns the specified authenticator.

    Args:
        authenticator_name (str): _description_

    Raises:
        ArkServiceException: _description_

    Returns:
        ArkAuth: _description_
    """
    for auth in self.__authenticators:
        if auth.authenticator_name() == authenticator_name:
            return auth
    raise ArkServiceException(f'{authenticator_name} is not supported or not found')

service(service_type)

Returns the specified service when the appropriate authenticators were provided.

Parameters:

Name Type Description Default
service_type Type[ArkService]

description

required

Raises:

Type Description
ArkServiceException

description

Returns:

Name Type Description
ArkService ArkService

description

Source code in ark_sdk_python/ark_api.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def service(self, service_type: Type[ArkService]) -> ArkService:
    """
    Returns the specified service when the appropriate authenticators were provided.

    Args:
        service_type (Type[ArkService]): _description_

    Raises:
        ArkServiceException: _description_

    Returns:
        ArkService: _description_
    """
    if not issubclass(service_type, ArkService):
        raise ArkServiceException(f"Type {service_type} is invalid")
    service_name = service_type.service_config().service_name
    if service_name in self.__lazy_loaded_services:
        return self.__lazy_loaded_services[service_name]
    return self.__lazy_load_service(service_type)