glare package¶
Subpackages¶
- glare.api package
- glare.cmd package
- glare.common package
- glare.db package
- glare.hacking package
- glare.objects package
- glare.store package
- glare.tests package
- Subpackages
- glare.tests.functional package
- Submodules
- glare.tests.functional.base module
- glare.tests.functional.test_all module
- glare.tests.functional.test_database_store module
- glare.tests.functional.test_quotas module
- glare.tests.functional.test_sample_artifact module
- glare.tests.functional.test_schemas module
- glare.tests.functional.test_scrubber module
- glare.tests.functional.test_visibility module
- Module contents
- glare.tests.unit package
- Subpackages
- glare.tests.unit.api package
- Submodules
- glare.tests.unit.api.test_create module
- glare.tests.unit.api.test_delete module
- glare.tests.unit.api.test_delete_blobs module
- glare.tests.unit.api.test_download module
- glare.tests.unit.api.test_list module
- glare.tests.unit.api.test_locations module
- glare.tests.unit.api.test_update module
- glare.tests.unit.api.test_upload module
- Module contents
- glare.tests.unit.db package
- glare.tests.unit.middleware package
- glare.tests.unit.api package
- Submodules
- glare.tests.unit.base module
- glare.tests.unit.glare_fixtures module
- glare.tests.unit.test_fixtures module
- glare.tests.unit.test_hacking module
- glare.tests.unit.test_multistore module
- glare.tests.unit.test_quotas module
- glare.tests.unit.test_store_api module
- glare.tests.unit.test_unpacking module
- glare.tests.unit.test_utils module
- glare.tests.unit.test_validation_hooks module
- glare.tests.unit.test_validators module
- glare.tests.unit.test_versions module
- glare.tests.unit.test_wsgi module
- Module contents
- Subpackages
- glare.tests.functional package
- Submodules
- glare.tests.hooks_artifact module
- glare.tests.sample_artifact module
- glare.tests.unpacking_artifact module
- glare.tests.utils module
- Module contents
- Subpackages
Submodules¶
glare.engine module¶
-
class
glare.engine.
Engine
[source]¶ Bases:
object
Engine is responsible for executing different helper operations when processing incoming requests from Glare API.
- Engine receives incoming data and does the following:
- check basic policy permissions;
- requests artifact definition from artifact type registry;
- check access permission(ro, rw);
- lock artifact for update if needed;
- pass data to base artifact type to execute all business logic operations with database;
- check quotas during upload;
- call operations pre- and post- hooks;
- notify other users about finished operation.
Engine should not include any business logic and validation related to artifacts types. Engine should not know any internal details of artifact type, because this part of the work is done by Base artifact type.
-
add_blob_location
(context, type_name, artifact_id, field_name, location, blob_meta, blob_key=None)[source]¶ Add external/internal location to blob.
Parameters: - context – user context
- type_name – name of artifact type
- artifact_id – id of the artifact to be updated
- field_name – name of blob or blob dict field
- location – blob url
- blob_meta – dictionary containing blob metadata like md5 checksum
- blob_key – if field_name is blob dict it specifies key in this dict
Returns: dict representation of updated artifact
-
create
(context, type_name, values)[source]¶ Create artifact record in Glare.
Parameters: - context – user context
- type_name – artifact type name
- values – dict with artifact fields
Returns: dict representation of created artifact
-
delete
(context, type_name, artifact_id)[source]¶ Delete artifact from Glare.
Parameters: - context – User context
- type_name – Artifact type name
- artifact_id – id of artifact to delete
-
delete_external_blob
(context, type_name, artifact_id, field_name, blob_key=None)[source]¶ Delete artifact blob with external location.
Parameters: - context – user context
- type_name – name of artifact type
- artifact_id – id of artifact with the blob to delete
- field_name – name of blob or blob dict field
- blob_key – if field_name is blob dict it specifies key in this dictionary
-
download_blob
(context, type_name, artifact_id, field_name, blob_key=None)[source]¶ Download binary data from Glare Artifact.
Parameters: - context – user context
- type_name – name of artifact type
- artifact_id – id of the artifact to be updated
- field_name – name of blob or blob dict field
- blob_key – if field_name is blob dict it specifies key in this dict
Returns: file iterator for requested file
-
static
list
(context, type_name, filters, marker=None, limit=None, sort=None, latest=False)[source]¶ Return list of artifacts requested by user.
Parameters: - context – user context
- type_name – Artifact type name
- filters – filters that need to be applied to artifact
- marker – the artifact that considered as begin of the list so all artifacts before marker (including marker itself) will not be added to artifact list
- limit – maximum number of items in list
- sort – sorting options
- latest – flag that indicates, that only artifacts with highest versions should be returned in output
Returns: list of artifact definitions
-
list_all_quotas
(context)[source]¶ Get detailed info about all available quotas.
Parameters: context – user request context Returns: dict with definitions of redefined quotas for all projects and global defaults
-
list_project_quotas
(context, project_id=None)[source]¶ Get detailed info about project quotas.
Parameters: - context – user request context
- project_id – id of the project for which to show quotas
Returns: definition of requested quotas for the project
-
lock_engine
= <glare.locking.LockEngine object at 0x4e400d0>¶
-
save
(context, type_name, artifact_id, patch)[source]¶ Update artifact with json patch.
Apply patch to artifact and validate artifact before updating it in database. If there is request for visibility or status change then call specific method for that.
Parameters: - context – user context
- type_name – name of artifact type
- artifact_id – id of the artifact to be updated
- patch – json patch object
Returns: dict representation of updated artifact
-
static
set_quotas
(context, values)[source]¶ Set quota records in Glare.
Parameters: - context – user request context
- values – dict with quota values to set
-
show
(context, type_name, artifact_id)[source]¶ Show detailed artifact info.
Parameters: - context – user context
- type_name – Artifact type name
- artifact_id – id of artifact to show
Returns: definition of requested artifact
-
upload_blob
(context, type_name, artifact_id, field_name, fd, content_type, content_length=None, blob_key=None)[source]¶ Upload Artifact blob.
Parameters: - context – user context
- type_name – name of artifact type
- artifact_id – id of the artifact to be updated
- field_name – name of blob or blob dict field
- fd – file descriptor that Glare uses to upload the file
- content_type – data content-type
- content_length – amount of data user wants to upload
- blob_key – if field_name is blob dict it specifies key in this dictionary
Returns: dict representation of updated artifact
glare.i18n module¶
glare.locking module¶
-
class
glare.locking.
Lock
(context, lock_id, lock_key, release_method)[source]¶ Bases:
object
Object that stores lock context for users. This class is internal and used only in lock engine, so users shouldn’t use this class directly.
-
class
glare.locking.
LockApiBase
[source]¶ Bases:
object
Lock Api Base class that responsible for acquiring/releasing locks.
-
class
glare.locking.
LockEngine
(lock_api)[source]¶ Bases:
object
Glare lock engine.
Defines how artifact updates must be synchronized with each other. When some user obtains a lock for the same artifact then other user cannot request that lock and gets a Conflict error.
-
MAX_LOCK_LENGTH
= 255¶
-
glare.notification module¶
glare.opts module¶
glare.quota module¶
-
glare.quota.
verify_artifact_count
(context, type_name)[source]¶ Verify if user can upload data based on his quota limits.
Parameters: - context – user context
- type_name – name of artifact type
-
glare.quota.
verify_uploaded_data_amount
(context, type_name, data_amount=None)[source]¶ Verify if user can upload data based on his quota limits.
Parameters: - context – user context
- type_name – name of artifact type
- data_amount – number of bytes user wants to upload. Value None means that user hasn’t specified data amount. In this case don’t raise an exception, but just return the amount of data he is able to upload.
Returns: number of bytes user can upload if data_amount isn’t specified