-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from tektronix/artifacts
File artifacts
- Loading branch information
Showing
17 changed files
with
414 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ Models | |
:maxdepth: 2 | ||
:caption: Models | ||
|
||
models/artifact | ||
models/file | ||
models/folder | ||
models/member | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. _artifact: | ||
|
||
Artifact | ||
======== | ||
|
||
.. autoclass:: tekdrive.models.Artifact | ||
:inherited-members: | ||
:exclude-members: parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Provides the Artifact class.""" | ||
from typing import TYPE_CHECKING, Optional, Dict, Any, Union | ||
|
||
from .base import DriveBase, Downloadable | ||
from ..base import BaseList | ||
from ...routing import Route, ENDPOINTS | ||
|
||
if TYPE_CHECKING: | ||
from .. import TekDrive | ||
|
||
|
||
class Artifact(DriveBase, Downloadable): | ||
""" | ||
Represents a file artifact. | ||
Attributes: | ||
bytes (str): Artifact size in bytes. | ||
created_at (datetime): When the artifact was created. | ||
context_type (str): Context to identify the type of artifact such as ``"SETTING"`` or ``"CHANNEL"``. | ||
file_id (str): ID of the file that the artifact is associated with. | ||
file_type (str): Artifact file type such as ``"TSS"`` or ``"SET"``. | ||
id (str): Unique artifact ID. | ||
name (str): Artifact name. | ||
parent_artifact_id: ID of the parent artifact. | ||
updated_at (datetime, optional): When the artifact was last updated. | ||
""" | ||
|
||
STR_FIELD = "id" | ||
|
||
@classmethod | ||
def from_data(cls, tekdrive, data): | ||
return cls(tekdrive, data) | ||
|
||
def __init__( | ||
self, | ||
tekdrive: "TekDrive", | ||
_data: Optional[Dict[str, Any]] = None, | ||
): | ||
super().__init__(tekdrive, _data=_data) | ||
|
||
def __setattr__( | ||
self, | ||
attribute: str, | ||
value: Union[str, int, Dict[str, Any]], | ||
): | ||
super().__setattr__(attribute, value) | ||
|
||
def _fetch_download_url(self): | ||
route = Route("GET", ENDPOINTS["file_artifact_download"], file_id=self.file_id, artifact_id=self.id) | ||
download_details = self._tekdrive.request(route) | ||
return download_details["download_url"] | ||
|
||
|
||
class ArtifactsList(BaseList): | ||
"""List of artifacts""" | ||
|
||
_parent = None | ||
|
||
LIST_ATTRIBUTE = "artifacts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"""Settings/constants""" | ||
|
||
__version__ = "1.0.0" | ||
__version__ = "1.1.0" | ||
|
||
RATELIMIT_SECONDS = 1 | ||
TIMEOUT = 15 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.