Skip to content

applications

ArkPCloudApplicationsService

Bases: ArkPCloudBaseService

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
 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
class ArkPCloudApplicationsService(ArkPCloudBaseService):
    def __init__(
        self,
        isp_auth: Optional[ArkISPAuth] = None,
    ) -> None:
        super().__init__(isp_auth, 'webservices')

    def add_application(self, add_application: ArkPCloudAddApplication) -> ArkPCloudApplication:
        """
        Adds a new application for CP / CCP
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Application.htm

        Args:
            add_application (ArkPCloudAddApplication): _description_

        Returns:
            ArkPCloudApplication: _description_
        """
        self._logger.info(f'Adding new application with id [{add_application.app_id}]')
        try:
            parse(add_application.expiration_date)
        except Exception as ex:
            raise ArkServiceException('Expiration date format is invalid') from ex
        add_dict = add_application.model_dump(by_alias=True, exclude_none=True, exclude={'app_id'})
        add_dict['AppID'] = add_application.app_id
        resp: Response = self._client.post(BASE_APPLICATIONS_URL, json={'application': add_dict})
        if resp.status_code == HTTPStatus.CREATED:
            return self.application(ArkPCloudGetApplication(app_id=add_application.app_id))
        raise ArkServiceException(f'Failed to add application [{resp.text}] - [{resp.status_code}]')

    def delete_application(self, delete_application: ArkPCloudDeleteApplication) -> None:
        """
        Delete application by its id
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Application.htm

        Args:
            delete_application (ArkPCloudDeleteApplication): _description_

        Raises:
            ArkServiceException: _description_
        """
        self._logger.info(f'Deleting application with id [{delete_application.app_id}]')
        resp: Response = self._client.delete(BASE_APPLICATION_URL.format(app_id=delete_application.app_id))
        if resp.status_code != HTTPStatus.OK:
            raise ArkServiceException(f'Failed to delete application [{resp.text}] - [{resp.status_code}]')

    def list_applications(self) -> List[ArkPCloudApplication]:
        """
        Lists all applications
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

        Returns:
            List[ArkPCloudApplication]: _description_
        """
        self._logger.info('Listing all applications')
        resp: Response = self._client.get(BASE_APPLICATIONS_URL)
        if resp.status_code == HTTPStatus.OK:
            return TypeAdapter(List[ArkPCloudApplication]).validate_python(resp.json()['application'])
        raise ArkServiceException(f'Failed to list applications [{resp.text}] - [{resp.status_code}]')

    def list_applications_by(self, applications_filter: ArkPCloudApplicationsFilter) -> List[ArkPCloudApplication]:
        """
        Lists applications by given filters
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

        Args:
            applications_filter (ArkPCloudApplicationsFilter): _description_

        Returns:
            List[ArkPCloudApplication]: _description_
        """
        self._logger.info(f'Listing applications by filters [{applications_filter}]')
        applications = self.list_applications()
        if applications_filter.location:
            applications = [a for a in applications if fnmatch(a.location, applications_filter.location)]
        if applications_filter.only_enabled:
            applications = [a for a in applications if not a.disabled]
        if applications_filter.business_owner_name:
            applications = [
                a
                for a in applications
                if fnmatch(a.business_owner_first_name, applications_filter.business_owner_name)
                or fnmatch(a.business_owner_first_name, applications_filter.business_owner_name)
            ]
        if applications_filter.business_owner_email:
            applications = [a for a in applications if a.business_owner_email == applications_filter.business_owner_email]
        return applications

    def application(self, get_application: ArkPCloudGetApplication) -> ArkPCloudApplication:
        """
        Retrieves an application by id
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20a%20Specific%20Application.htm

        Args:
            get_application (ArkPCloudGetApplication): _description_

        Returns:
            ArkPCloudApplication: _description_
        """
        self._logger.info(f'Retrieving application by id [{get_application.app_id}]')
        resp: Response = self._client.get(BASE_APPLICATION_URL.format(app_id=get_application.app_id))
        if resp.status_code == HTTPStatus.OK:
            return ArkPCloudApplication.model_validate(resp.json()['application'])
        raise ArkServiceException(f'Failed to retrieve application [{resp.text}] - [{resp.status_code}]')

    def applications_stats(self) -> ArkPCloudAppicationsStats:
        """
        Calculates applications stats

        Returns:
            ArkPCloudAppicationsStats: _description_
        """
        self._logger.info('Calculating applications stats')
        applications = self.list_applications()
        applications_stats = ArkPCloudAppicationsStats.model_construct()
        applications_stats.count = len(applications)
        applications_stats.disabled_apps = [a.app_id for a in applications if a.disabled]
        apps_auth_types = {}
        for a in applications:
            auth_methods = self.list_application_auth_methods(ArkPCloudListApplicationAuthMethods(app_id=a.app_id))
            apps_auth_types[a.app_id] = [am.auth_type for am in auth_methods]
        applications_stats.applications_auth_method_types = apps_auth_types
        applications_stats.auth_types_count = {}
        for auth_method_types in apps_auth_types.values():
            for auth_method in auth_method_types:
                if auth_method not in applications_stats.auth_types_count:
                    applications_stats.auth_types_count[auth_method] = 0
                applications_stats.auth_types_count[auth_method] += 1
        return applications_stats

    def add_application_auth_method(self, add_application_auth_method: ArkPCloudAddApplicationAuthMethod) -> ArkPCloudApplicationAuthMethod:
        """
        Adds a new auth method for the application
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Authentication.htm

        Args:
            add_application_auth_method (ArkPCloudAddApplicationAuthMethod): _description_

        Returns:
            ArkPCloudApplicationAuthMethod: _description_
        """
        self._logger.info(
            f'Adding a new auth method [{add_application_auth_method.auth_type}] for app [{add_application_auth_method.app_id}]'
        )
        auth_method_dict = None
        if add_application_auth_method.auth_type in [
            ArkPCloudApplicationAuthMethodType.Hash,
            ArkPCloudApplicationAuthMethodType.IP,
            ArkPCloudApplicationAuthMethodType.OsUser,
            ArkPCloudApplicationAuthMethodType.Path,
            ArkPCloudApplicationAuthMethodType.CertificateSerialNumber,
        ]:
            if not add_application_auth_method.auth_value:
                raise ArkServiceException('Auth value is required for the chosen auth method type')
            keys = {'auth_id', 'auth_type', 'auth_value', 'comment'}
            if add_application_auth_method.auth_type == ArkPCloudApplicationAuthMethodType.Path:
                keys = keys.union({'is_folder', 'allow_internal_scripts'})
            auth_method_dict = add_application_auth_method.model_dump(include=keys, by_alias=True, exclude_none=True)
        elif add_application_auth_method == ArkPCloudApplicationAuthMethodType.Certificate:
            if (
                not add_application_auth_method.subject
                and not add_application_auth_method.issuer
                and not add_application_auth_method.subject_alternative_name
            ):
                raise ArkServiceException('At least issuer, subject or san needs to be given for certificate auth type')
            auth_method_dict = add_application_auth_method.model_dump(
                include={'auth_id', 'auth_type', 'auth_value', 'subject', 'issuer', 'subject_alternative_name'},
                by_alias=True,
                exclude_none=True,
            )
        elif add_application_auth_method == ArkPCloudApplicationAuthMethodType.Kubernetes:
            if (
                not add_application_auth_method.namespace
                and not add_application_auth_method.image
                and not add_application_auth_method.env_var_name
                or not add_application_auth_method.env_var_value
            ):
                raise ArkServiceException('At least namespace, image, env var key and value needs to be given for kubernetes auth type')
            auth_method_dict = add_application_auth_method.model_dump(
                include={'auth_id', 'auth_type', 'auth_value', 'namespace', 'image', 'env_var_name', 'env_var_value'},
                by_alias=True,
                exclude_none=True,
            )
        else:
            raise ArkServiceException('Unsupported auth method type')
        resp: Response = self._client.post(
            BASE_AUTH_METHODS_URL.format(app_id=add_application_auth_method.app_id),
            json={
                'authentication': auth_method_dict,
            },
        )
        if resp.status_code == HTTPStatus.CREATED:
            return self.list_application_auth_methods_by(
                ArkPCloudApplicationAuthMethodsFilter(
                    app_id=add_application_auth_method.app_id, auth_types=[add_application_auth_method.auth_type]
                )
            )[0]
        raise ArkServiceException(f'Failed to add app auth method [{resp.text}] - [{resp.status_code}]')

    def delete_application_auth_method(self, delete_application_auth_method: ArkPCloudDeleteApplicationAuthMethod) -> None:
        """
        Deletes an auth method from an application
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Authentication.htm

        Args:
            delete_application_auth_method (ArkPCloudDeleteApplicationAuthMethod): _description_
        """
        self._logger.info(
            f'Deleting auth method from app [{delete_application_auth_method.app_id}] with id [{delete_application_auth_method.auth_id}]'
        )
        resp: Response = self._client.delete(
            BASE_AUTH_METHOD_URL.format(app_id=delete_application_auth_method.app_id, auth_id=delete_application_auth_method.auth_id)
        )
        if resp.status_code != HTTPStatus.OK:
            raise ArkServiceException(f'Failed to delete auth method [{resp.text}] - [{resp.status_code}]')

    def list_application_auth_methods(
        self, list_application_auth_methods: ArkPCloudListApplicationAuthMethods
    ) -> List[ArkPCloudApplicationAuthMethod]:
        """
        Lists all application auth methods
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

        Args:
            list_application_auth_methods (ArkPCloudListApplicationAuthMethods): _description_

        Returns:
            List[ArkPCloudApplicationAuthMethod]: _description_
        """
        self._logger.info(f'Listing all application [{list_application_auth_methods.app_id}]] auth methods')
        resp: Response = self._client.get(BASE_AUTH_METHODS_URL.format(app_id=list_application_auth_methods.app_id))
        if resp.status_code == HTTPStatus.OK:
            return TypeAdapter(List[ArkPCloudApplicationAuthMethod]).validate_python(resp.json()['authentication'])
        raise ArkServiceException(f'Failed to list application auth methods [{resp.text}] - [{resp.status_code}]]')

    def list_application_auth_methods_by(
        self, application_auth_methods_filter: ArkPCloudApplicationAuthMethodsFilter
    ) -> List[ArkPCloudApplicationAuthMethod]:
        """
        Lists application auth methods by given filters
        https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

        Args:
            application_auth_methods_filter (ArkPCloudApplicationAuthMethodsFilter): _description_

        Returns:
            List[ArkPCloudApplicationAuthMethod]: _description_
        """
        self._logger.info(f'Listing auth methods of app filtered [{application_auth_methods_filter}]')
        auth_methods = self.list_application_auth_methods(
            ArkPCloudListApplicationAuthMethods(app_id=application_auth_methods_filter.app_id)
        )
        if application_auth_methods_filter.auth_types:
            auth_methods = [a for a in auth_methods if a.auth_type in application_auth_methods_filter.auth_types]
        return auth_methods

    def application_auth_method(self, get_application_auth_method: ArkPCloudGetApplicationAuthMethod) -> ArkPCloudApplicationAuthMethod:
        """
        Retrives an auth method by app id and auth id

        Args:
            get_application_auth_method (ArkPCloudGetApplicationAuthMethod): _description_

        Returns:
            ArkPCloudApplicationAuthMethod: _description_
        """
        self._logger.info(
            f'Retrieving auth method of app [{get_application_auth_method.app_id}] and id [{get_application_auth_method.auth_id}]'
        )
        auth_methods = [
            a
            for a in self.list_application_auth_methods(ArkPCloudListApplicationAuthMethods(app_id=get_application_auth_method.app_id))
            if a.auth_id == get_application_auth_method.auth_id
        ]
        if not auth_methods:
            raise ArkServiceException('Failed to find auth method')
        return auth_methods[0]

    @staticmethod
    @overrides
    def service_config() -> ArkServiceConfig:
        return SERVICE_CONFIG

add_application(add_application)

Adds a new application for CP / CCP https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Application.htm

Parameters:

Name Type Description Default
add_application ArkPCloudAddApplication

description

required

Returns:

Name Type Description
ArkPCloudApplication ArkPCloudApplication

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def add_application(self, add_application: ArkPCloudAddApplication) -> ArkPCloudApplication:
    """
    Adds a new application for CP / CCP
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Application.htm

    Args:
        add_application (ArkPCloudAddApplication): _description_

    Returns:
        ArkPCloudApplication: _description_
    """
    self._logger.info(f'Adding new application with id [{add_application.app_id}]')
    try:
        parse(add_application.expiration_date)
    except Exception as ex:
        raise ArkServiceException('Expiration date format is invalid') from ex
    add_dict = add_application.model_dump(by_alias=True, exclude_none=True, exclude={'app_id'})
    add_dict['AppID'] = add_application.app_id
    resp: Response = self._client.post(BASE_APPLICATIONS_URL, json={'application': add_dict})
    if resp.status_code == HTTPStatus.CREATED:
        return self.application(ArkPCloudGetApplication(app_id=add_application.app_id))
    raise ArkServiceException(f'Failed to add application [{resp.text}] - [{resp.status_code}]')

add_application_auth_method(add_application_auth_method)

Adds a new auth method for the application https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Authentication.htm

Parameters:

Name Type Description Default
add_application_auth_method ArkPCloudAddApplicationAuthMethod

description

required

Returns:

Name Type Description
ArkPCloudApplicationAuthMethod ArkPCloudApplicationAuthMethod

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
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
def add_application_auth_method(self, add_application_auth_method: ArkPCloudAddApplicationAuthMethod) -> ArkPCloudApplicationAuthMethod:
    """
    Adds a new auth method for the application
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Add%20Authentication.htm

    Args:
        add_application_auth_method (ArkPCloudAddApplicationAuthMethod): _description_

    Returns:
        ArkPCloudApplicationAuthMethod: _description_
    """
    self._logger.info(
        f'Adding a new auth method [{add_application_auth_method.auth_type}] for app [{add_application_auth_method.app_id}]'
    )
    auth_method_dict = None
    if add_application_auth_method.auth_type in [
        ArkPCloudApplicationAuthMethodType.Hash,
        ArkPCloudApplicationAuthMethodType.IP,
        ArkPCloudApplicationAuthMethodType.OsUser,
        ArkPCloudApplicationAuthMethodType.Path,
        ArkPCloudApplicationAuthMethodType.CertificateSerialNumber,
    ]:
        if not add_application_auth_method.auth_value:
            raise ArkServiceException('Auth value is required for the chosen auth method type')
        keys = {'auth_id', 'auth_type', 'auth_value', 'comment'}
        if add_application_auth_method.auth_type == ArkPCloudApplicationAuthMethodType.Path:
            keys = keys.union({'is_folder', 'allow_internal_scripts'})
        auth_method_dict = add_application_auth_method.model_dump(include=keys, by_alias=True, exclude_none=True)
    elif add_application_auth_method == ArkPCloudApplicationAuthMethodType.Certificate:
        if (
            not add_application_auth_method.subject
            and not add_application_auth_method.issuer
            and not add_application_auth_method.subject_alternative_name
        ):
            raise ArkServiceException('At least issuer, subject or san needs to be given for certificate auth type')
        auth_method_dict = add_application_auth_method.model_dump(
            include={'auth_id', 'auth_type', 'auth_value', 'subject', 'issuer', 'subject_alternative_name'},
            by_alias=True,
            exclude_none=True,
        )
    elif add_application_auth_method == ArkPCloudApplicationAuthMethodType.Kubernetes:
        if (
            not add_application_auth_method.namespace
            and not add_application_auth_method.image
            and not add_application_auth_method.env_var_name
            or not add_application_auth_method.env_var_value
        ):
            raise ArkServiceException('At least namespace, image, env var key and value needs to be given for kubernetes auth type')
        auth_method_dict = add_application_auth_method.model_dump(
            include={'auth_id', 'auth_type', 'auth_value', 'namespace', 'image', 'env_var_name', 'env_var_value'},
            by_alias=True,
            exclude_none=True,
        )
    else:
        raise ArkServiceException('Unsupported auth method type')
    resp: Response = self._client.post(
        BASE_AUTH_METHODS_URL.format(app_id=add_application_auth_method.app_id),
        json={
            'authentication': auth_method_dict,
        },
    )
    if resp.status_code == HTTPStatus.CREATED:
        return self.list_application_auth_methods_by(
            ArkPCloudApplicationAuthMethodsFilter(
                app_id=add_application_auth_method.app_id, auth_types=[add_application_auth_method.auth_type]
            )
        )[0]
    raise ArkServiceException(f'Failed to add app auth method [{resp.text}] - [{resp.status_code}]')

application(get_application)

Retrieves an application by id https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20a%20Specific%20Application.htm

Parameters:

Name Type Description Default
get_application ArkPCloudGetApplication

description

required

Returns:

Name Type Description
ArkPCloudApplication ArkPCloudApplication

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def application(self, get_application: ArkPCloudGetApplication) -> ArkPCloudApplication:
    """
    Retrieves an application by id
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20a%20Specific%20Application.htm

    Args:
        get_application (ArkPCloudGetApplication): _description_

    Returns:
        ArkPCloudApplication: _description_
    """
    self._logger.info(f'Retrieving application by id [{get_application.app_id}]')
    resp: Response = self._client.get(BASE_APPLICATION_URL.format(app_id=get_application.app_id))
    if resp.status_code == HTTPStatus.OK:
        return ArkPCloudApplication.model_validate(resp.json()['application'])
    raise ArkServiceException(f'Failed to retrieve application [{resp.text}] - [{resp.status_code}]')

application_auth_method(get_application_auth_method)

Retrives an auth method by app id and auth id

Parameters:

Name Type Description Default
get_application_auth_method ArkPCloudGetApplicationAuthMethod

description

required

Returns:

Name Type Description
ArkPCloudApplicationAuthMethod ArkPCloudApplicationAuthMethod

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
def application_auth_method(self, get_application_auth_method: ArkPCloudGetApplicationAuthMethod) -> ArkPCloudApplicationAuthMethod:
    """
    Retrives an auth method by app id and auth id

    Args:
        get_application_auth_method (ArkPCloudGetApplicationAuthMethod): _description_

    Returns:
        ArkPCloudApplicationAuthMethod: _description_
    """
    self._logger.info(
        f'Retrieving auth method of app [{get_application_auth_method.app_id}] and id [{get_application_auth_method.auth_id}]'
    )
    auth_methods = [
        a
        for a in self.list_application_auth_methods(ArkPCloudListApplicationAuthMethods(app_id=get_application_auth_method.app_id))
        if a.auth_id == get_application_auth_method.auth_id
    ]
    if not auth_methods:
        raise ArkServiceException('Failed to find auth method')
    return auth_methods[0]

applications_stats()

Calculates applications stats

Returns:

Name Type Description
ArkPCloudAppicationsStats ArkPCloudAppicationsStats

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
def applications_stats(self) -> ArkPCloudAppicationsStats:
    """
    Calculates applications stats

    Returns:
        ArkPCloudAppicationsStats: _description_
    """
    self._logger.info('Calculating applications stats')
    applications = self.list_applications()
    applications_stats = ArkPCloudAppicationsStats.model_construct()
    applications_stats.count = len(applications)
    applications_stats.disabled_apps = [a.app_id for a in applications if a.disabled]
    apps_auth_types = {}
    for a in applications:
        auth_methods = self.list_application_auth_methods(ArkPCloudListApplicationAuthMethods(app_id=a.app_id))
        apps_auth_types[a.app_id] = [am.auth_type for am in auth_methods]
    applications_stats.applications_auth_method_types = apps_auth_types
    applications_stats.auth_types_count = {}
    for auth_method_types in apps_auth_types.values():
        for auth_method in auth_method_types:
            if auth_method not in applications_stats.auth_types_count:
                applications_stats.auth_types_count[auth_method] = 0
            applications_stats.auth_types_count[auth_method] += 1
    return applications_stats

delete_application(delete_application)

Delete application by its id https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Application.htm

Parameters:

Name Type Description Default
delete_application ArkPCloudDeleteApplication

description

required

Raises:

Type Description
ArkServiceException

description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def delete_application(self, delete_application: ArkPCloudDeleteApplication) -> None:
    """
    Delete application by its id
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Application.htm

    Args:
        delete_application (ArkPCloudDeleteApplication): _description_

    Raises:
        ArkServiceException: _description_
    """
    self._logger.info(f'Deleting application with id [{delete_application.app_id}]')
    resp: Response = self._client.delete(BASE_APPLICATION_URL.format(app_id=delete_application.app_id))
    if resp.status_code != HTTPStatus.OK:
        raise ArkServiceException(f'Failed to delete application [{resp.text}] - [{resp.status_code}]')

delete_application_auth_method(delete_application_auth_method)

Deletes an auth method from an application https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Authentication.htm

Parameters:

Name Type Description Default
delete_application_auth_method ArkPCloudDeleteApplicationAuthMethod

description

required
Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
def delete_application_auth_method(self, delete_application_auth_method: ArkPCloudDeleteApplicationAuthMethod) -> None:
    """
    Deletes an auth method from an application
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/Delete%20a%20Specific%20Authentication.htm

    Args:
        delete_application_auth_method (ArkPCloudDeleteApplicationAuthMethod): _description_
    """
    self._logger.info(
        f'Deleting auth method from app [{delete_application_auth_method.app_id}] with id [{delete_application_auth_method.auth_id}]'
    )
    resp: Response = self._client.delete(
        BASE_AUTH_METHOD_URL.format(app_id=delete_application_auth_method.app_id, auth_id=delete_application_auth_method.auth_id)
    )
    if resp.status_code != HTTPStatus.OK:
        raise ArkServiceException(f'Failed to delete auth method [{resp.text}] - [{resp.status_code}]')

list_application_auth_methods(list_application_auth_methods)

Lists all application auth methods https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

Parameters:

Name Type Description Default
list_application_auth_methods ArkPCloudListApplicationAuthMethods

description

required

Returns:

Type Description
List[ArkPCloudApplicationAuthMethod]

List[ArkPCloudApplicationAuthMethod]: description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
def list_application_auth_methods(
    self, list_application_auth_methods: ArkPCloudListApplicationAuthMethods
) -> List[ArkPCloudApplicationAuthMethod]:
    """
    Lists all application auth methods
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

    Args:
        list_application_auth_methods (ArkPCloudListApplicationAuthMethods): _description_

    Returns:
        List[ArkPCloudApplicationAuthMethod]: _description_
    """
    self._logger.info(f'Listing all application [{list_application_auth_methods.app_id}]] auth methods')
    resp: Response = self._client.get(BASE_AUTH_METHODS_URL.format(app_id=list_application_auth_methods.app_id))
    if resp.status_code == HTTPStatus.OK:
        return TypeAdapter(List[ArkPCloudApplicationAuthMethod]).validate_python(resp.json()['authentication'])
    raise ArkServiceException(f'Failed to list application auth methods [{resp.text}] - [{resp.status_code}]]')

list_application_auth_methods_by(application_auth_methods_filter)

Lists application auth methods by given filters https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

Parameters:

Name Type Description Default
application_auth_methods_filter ArkPCloudApplicationAuthMethodsFilter

description

required

Returns:

Type Description
List[ArkPCloudApplicationAuthMethod]

List[ArkPCloudApplicationAuthMethod]: description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
def list_application_auth_methods_by(
    self, application_auth_methods_filter: ArkPCloudApplicationAuthMethodsFilter
) -> List[ArkPCloudApplicationAuthMethod]:
    """
    Lists application auth methods by given filters
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20all%20Authentication%20Methods%20of%20a%20Specific%20Application.htm

    Args:
        application_auth_methods_filter (ArkPCloudApplicationAuthMethodsFilter): _description_

    Returns:
        List[ArkPCloudApplicationAuthMethod]: _description_
    """
    self._logger.info(f'Listing auth methods of app filtered [{application_auth_methods_filter}]')
    auth_methods = self.list_application_auth_methods(
        ArkPCloudListApplicationAuthMethods(app_id=application_auth_methods_filter.app_id)
    )
    if application_auth_methods_filter.auth_types:
        auth_methods = [a for a in auth_methods if a.auth_type in application_auth_methods_filter.auth_types]
    return auth_methods

list_applications()

Lists all applications https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

Returns:

Type Description
List[ArkPCloudApplication]

List[ArkPCloudApplication]: description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
85
86
87
88
89
90
91
92
93
94
95
96
97
def list_applications(self) -> List[ArkPCloudApplication]:
    """
    Lists all applications
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

    Returns:
        List[ArkPCloudApplication]: _description_
    """
    self._logger.info('Listing all applications')
    resp: Response = self._client.get(BASE_APPLICATIONS_URL)
    if resp.status_code == HTTPStatus.OK:
        return TypeAdapter(List[ArkPCloudApplication]).validate_python(resp.json()['application'])
    raise ArkServiceException(f'Failed to list applications [{resp.text}] - [{resp.status_code}]')

list_applications_by(applications_filter)

Lists applications by given filters https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

Parameters:

Name Type Description Default
applications_filter ArkPCloudApplicationsFilter

description

required

Returns:

Type Description
List[ArkPCloudApplication]

List[ArkPCloudApplication]: description

Source code in ark_sdk_python/services/pcloud/applications/ark_pcloud_applications_service.py
 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
def list_applications_by(self, applications_filter: ArkPCloudApplicationsFilter) -> List[ArkPCloudApplication]:
    """
    Lists applications by given filters
    https://docs.cyberark.com/Product-Doc/OnlineHelp/PrivCloud/Latest/en/Content/WebServices/List%20Applications.htm

    Args:
        applications_filter (ArkPCloudApplicationsFilter): _description_

    Returns:
        List[ArkPCloudApplication]: _description_
    """
    self._logger.info(f'Listing applications by filters [{applications_filter}]')
    applications = self.list_applications()
    if applications_filter.location:
        applications = [a for a in applications if fnmatch(a.location, applications_filter.location)]
    if applications_filter.only_enabled:
        applications = [a for a in applications if not a.disabled]
    if applications_filter.business_owner_name:
        applications = [
            a
            for a in applications
            if fnmatch(a.business_owner_first_name, applications_filter.business_owner_name)
            or fnmatch(a.business_owner_first_name, applications_filter.business_owner_name)
        ]
    if applications_filter.business_owner_email:
        applications = [a for a in applications if a.business_owner_email == applications_filter.business_owner_email]
    return applications