here.platform.api.artifact_api module#
This module contains a ArtifactApi class to perform Artifact API operations.
- class here.platform.api.artifact_api.AccessType(value)[source]#
Bases:
EnumAccess types enum used to list artifacts and schemas
- default = 0#
- orgAdmin = 1#
- class here.platform.api.artifact_api.ArtifactApi(base_url: str, platform_config: PlatformConfig, application_config: ApplicationConfig, auth: Auth | None, proxies: dict | None = None)[source]#
Bases:
BaseApiThis class provides access to HERE platform Artifact APIs.
The artifact service provides a way to store/consume schemas and artifacts. An artifact is the package which can contain code, assets, binary files, and configuration data. Artifacts are uniquely named, versioned, and immutable. Each schema and artifact are identified by group ID, artifact ID and version.
- add_schema_to_resource_policy(schema_hrn: str, body: dict) dict[source]#
Add schema and all attached artifacts to a newly created resource policy. This API works for tokens with or without a project scope. When the access token is project scoped, all the resources added to a resource policy must either be homed or referenced in the project.
- Parameters:
schema_hrn – The HRN of the Schema.
body – a dictionary with resource policy.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- delete_artifact(artifact_hrn: str, force: bool | None = None) bool[source]#
Delete the artifact and related files by given HRN. If scoped token is used, then the artifact is deleted within the project the token belongs to. Partial HRN without version could be used. If more than one version of artifact exists and partial HRN is passed then force flag must be set to true.
- Parameters:
artifact_hrn – The HRN of the schema.
force – The flag to force the deletion even if the artifact is linked to a project. By default force flag is set to false.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- delete_artifact_file(artifact_hrn: str, file_name: str) bool[source]#
Delete file from the artifact. for the given HRN
- Parameters:
artifact_hrn – The HRN of the artifact
file_name – The path to artifact file
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- delete_schema(schema_hrn: str) bool[source]#
Delete the schema and related artifacts by given HRN. If scoped token is used, then the schema is deleted within the project the token belongs to.
- Parameters:
schema_hrn – The HRN of the schema.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- download_artifact_file_by_reference(artifact_hrn: str, file_name: str, api_key: str | None = None) bytes[source]#
Downloads artifact file using API Key authentication. Reference access must be granted to the artifact before this endpoint can be used. The calling principal must have “readResource” permission to the artifact in order to retrieve the file. In addition to API Key, this API supports tokens with or without a project scope.
- Parameters:
artifact_hrn – The HRN of the artifact.
file_name – The path to artifact file
api_key – The API key token used for request authentication
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_artifact(artifact_hrn: str) dict[source]#
Return the information about artifact (hrn, groupId, artifactId, version) and linked files. If scoped token is used, then the information about artifact is returned within the project the token belongs to.
- Parameters:
artifact_hrn – The HRN of the artifact.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_artifact_file(artifact_hrn: str, file_name: str) bytes[source]#
Return the binary data of file linked to artifact.
- Parameters:
artifact_hrn – The HRN of the artifact
file_name – The path to artifact file
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_artifact_file_from_archive(artifact_hrn: str, archive_file: str, file_in_archive: str) bytes[source]#
Returns the binary data of a file stored in archive.
- Parameters:
artifact_hrn – The HRN of the schema.
archive_file – The name of artifact archive. Supported archive types are zip and jar
file_in_archive – Relative path of file in archive
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_artifact_registration(artifact_id: str, group_id: str) dict[source]#
Return the information about registered artifact. Requires ‘accessApi’ permission and ‘readResource’ permission to specified artifact
- Parameters:
group_id – The groupId of the artifact.
artifact_id – The ID of the artifact.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_reference_access_state(artifact_hrn: str) dict[source]#
Check that specified artifact has API key access enabled. The calling principal must have “readResource” permission to the artifact in order to use this endpoint.
- Parameters:
artifact_hrn – The HRN of the artifact.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_schema(schema_hrn: str) dict[source]#
Return the information about schema (hrn, groupId, artifactId, version) and related artifact and variants for the given HRN. If scoped token is used, then the information about schema is returned within the project the token belongs to.
- Parameters:
schema_hrn – The HRN of the schema.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_schema_document(schema_hrn: str, file: str) str[source]#
Return the url to schema documentation.
- Parameters:
schema_hrn – The HRN of the schema.
file – The path to schema file.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- get_schema_main_message(schema_hrn: str) bytes[source]#
Return the binary data of main message file from the schema.
- Parameters:
schema_hrn – The HRN of the Schema.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- grant_reference_access(artifact_hrn: str) dict[source]#
Grants API Key access to the artifact. This allows any principal that has “readResource” permission to the artifact to use the “references” API to download artifact files using API Access Key instead of the Bearer Token authorization. The calling principal must have “shareResource” permission to the artifact in order to use this endpoint. This API works for tokens with or without a project scope.
- Parameters:
artifact_hrn – The HRN of the artifact.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- link_schema_to_project(schema_hrn: str, body: dict) dict[source]#
Link schema to project request.
- Parameters:
schema_hrn – The HRN of the Schema.
body – a dictionary with project HRN.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- list_artifacts(access: AccessType | None = None, sort: str | None = None, order: str | None = None, from_param: str | None = None, group_id: str | None = None, artifact_id: str | None = None, limit: int | None = None, offset: int | None = None) dict[source]#
Return the list of available artifacts. Requires permission to ‘apiAccess’.If scoped token is used, then the list of artifacts is returned within the project the token belongs to. If unscoped token is used, then the list of artifacts is returned including the artifacts belonging to the projects.
- Parameters:
access – Comma separated list of access types (with OR semantic) to filter result. If ‘default’, returns artifacts user has read access to. If ‘orgAdmin’, returns artifacts OrgAdmin user have access to.
sort – sort parameter
order – order of sorting. Available values : ASC, DESC
from_param – from parameter
group_id – Applies filtering based on groupId
artifact_id – Applies filtering based on artifactId
limit – limit number of records
offset – offset number of records
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- list_schemas(access: str | None = None, sort: str | None = None, order: str | None = None, from_param: str | None = None, group_id: str | None = None, artifact_id: str | None = None, limit: int | None = None, offset: int | None = None) dict[source]#
Return the list of available schemas. If scoped token is used, then the list of schemas is returned within the project the token belongs to. If unscoped token is used, then the list of schemas is returned including the schemas belonging to the projects.
- Parameters:
access – Comma separated list of access types (with OR semantic) to filter result. If ‘default’, returns schema user have read access to. If ‘orgAdmin’, returns catalogs OrgAdmin user have access to.
sort – sort parameter
order – order of sorting
from_param – from parameter
group_id – Applies filtering based on groupId
artifact_id – Applies filtering based on artifactId
limit – limit number of records
offset – offset number of records
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- make_schema_linkable(schema_hrn: str, body: dict) dict[source]#
Make schema and all attached artifacts available for linking to a specific project or realm.
- Parameters:
schema_hrn – The HRN of the Schema.
body – a dictionary with project or realm Hrn.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- put_artifact_file(artifact_hrn: str, file_name: str, body: bytes) bool[source]#
Upload the file and linked to artifact. Requires permission to ‘modifyResource’ for the given HRN.
- Parameters:
artifact_hrn – The HRN of the artifact.
body – Data to be uploaded
file_name – The path to artifact file
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- register_artifact(artifact_id: str, group_id: str, body: dict) dict[source]#
Requires ‘accessApi’ permission. Create artifact with version ‘NONE’. If scoped token is used then the artifact is registered within the project the token belongs to otherwise grant ‘readResource’, ‘modifyResource’ and ‘shareResource’ permissions to app which send request and provided user id
- Parameters:
group_id – The groupId of the artifact.
artifact_id – The ID of the artifact.
body – Contains the data you want to add or remove from the UserID
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- remove_schema_linkability(schema_hrn: str, target_hrn: str) dict[source]#
Makes schema and all attached artifacts not available for linking to a project or realm.
- Parameters:
schema_hrn – The HRN of the schema.
target_hrn – The HRN of the target. Project HRN from which schema is to be unlinked
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- revoke_reference_access(artifact_hrn: str) dict[source]#
Revokes API Key access from the artifact. This removes the ability to use the “references” API to download artifact files using API Access Key. The calling principal must have “shareResource” permission to the artifact in order to use this endpoint. This API works for tokens with or without a project scope.
- Parameters:
artifact_hrn – The HRN of the artifact.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- unlink_schema_from_project(schema_hrn: str, project_hrn: str) dict[source]#
Unlink schema and all attached Artifacts from the project it was previously linked. This API works for tokens with or without a project scope.
- Parameters:
schema_hrn – The HRN of the schema.
project_hrn – The HRN of the project.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- update_artifact_permission(artifact_hrn: str, body: dict) bool[source]#
READ grants ‘readResource’, MODIFY grants ‘modifyResource’, SHARE grants ‘shareResource’. Requires permission to ‘shareResource’ for the given HRN.
- Parameters:
artifact_hrn – The HRN of the artifact.
body – a dictionary with permissions.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.
- update_schema_permission(schema_hrn: str, body: dict) bool[source]#
Grant/revoke permissions for schema. READ grants ‘readResource’, MODIFY grants ‘modifyResource’, SHARE grants ‘shareResource’.
- Parameters:
schema_hrn – The HRN of the schema.
body – a dictionary with permissions.
- Returns:
response from the API.
- Raises:
PlatformException – If platform responds with an HTTP error.