Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 136 additions & 117 deletions go/gen/sift/remote_files/v1/remote_files.pb.go

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions go/gen/sift/remote_files/v1/remote_files_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions protos/sift/remote_files/v1/remote_files.proto
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ enum EntityType {
ENTITY_TYPE_ASSET = 3;
ENTITY_TYPE_ANNOTATION_LOG = 4;
ENTITY_TYPE_TEST_REPORT = 5;
ENTITY_TYPE_TEST_STEP = 6;
}

// The request for a call to `RemoteFileService_GetRemoteFile` to retrieve a remote file;
Expand Down Expand Up @@ -167,6 +168,13 @@ message ListRemoteFilesRequest {

// This field is only required if your user belongs to multiple organizations.
string organization_id = 4 [(google.api.field_behavior) = OPTIONAL];

// How to order the retrieved reports. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
// Available fields to order_by are `name`, `created_date` and `modified_date`.
// If left empty, items are ordered by `created_date` in descending order (newest-first).
// For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
// Example: "created_date desc,modified_date"
string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// The response of a call to `RemoteFileService_ListRemoteFilesResponse`.
Expand Down Expand Up @@ -198,6 +206,9 @@ message CreateRemoteFileRequest {

// The metadata values associated with this remote file.
repeated sift.metadata.v1.MetadataValue metadata_values = 13 [(google.api.field_behavior) = OPTIONAL];

// Optional custom storage key for uploaded object that is not managed by the RemoteFileService.
// When provided, caller is responsible for ensuring uniqueness to avoid collisions or API will return an error.
}

// The response for a call to `RemoteFileService_CreateRemoteFile`.
Expand Down
58 changes: 30 additions & 28 deletions python/lib/sift/remote_files/v1/remote_files_pb2.py

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion python/lib/sift/remote_files/v1/remote_files_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class _EntityTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._Enu
ENTITY_TYPE_ASSET: _EntityType.ValueType # 3
ENTITY_TYPE_ANNOTATION_LOG: _EntityType.ValueType # 4
ENTITY_TYPE_TEST_REPORT: _EntityType.ValueType # 5
ENTITY_TYPE_TEST_STEP: _EntityType.ValueType # 6

class EntityType(_EntityType, metaclass=_EntityTypeEnumTypeWrapper): ...

Expand All @@ -43,6 +44,7 @@ ENTITY_TYPE_ANNOTATION: EntityType.ValueType # 2
ENTITY_TYPE_ASSET: EntityType.ValueType # 3
ENTITY_TYPE_ANNOTATION_LOG: EntityType.ValueType # 4
ENTITY_TYPE_TEST_REPORT: EntityType.ValueType # 5
ENTITY_TYPE_TEST_STEP: EntityType.ValueType # 6
global___EntityType = EntityType

@typing.final
Expand Down Expand Up @@ -232,6 +234,7 @@ class ListRemoteFilesRequest(google.protobuf.message.Message):
PAGE_TOKEN_FIELD_NUMBER: builtins.int
FILTER_FIELD_NUMBER: builtins.int
ORGANIZATION_ID_FIELD_NUMBER: builtins.int
ORDER_BY_FIELD_NUMBER: builtins.int
page_size: builtins.int
"""The maximum number of remote files to return. The service may return fewer than this value.
If unspecified, at most 50 remote files will be returned. The maximum value is 1000; values above
Expand All @@ -251,15 +254,23 @@ class ListRemoteFilesRequest(google.protobuf.message.Message):
"""
organization_id: builtins.str
"""This field is only required if your user belongs to multiple organizations."""
order_by: builtins.str
"""How to order the retrieved reports. Formatted as a comma-separated string i.e. "FIELD_NAME[ desc],...".
Available fields to order_by are `name`, `created_date` and `modified_date`.
If left empty, items are ordered by `created_date` in descending order (newest-first).
For more information about the format of this field, read [this](https://google.aip.dev/132#ordering)
Example: "created_date desc,modified_date"
"""
def __init__(
self,
*,
page_size: builtins.int = ...,
page_token: builtins.str = ...,
filter: builtins.str = ...,
organization_id: builtins.str = ...,
order_by: builtins.str = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["filter", b"filter", "organization_id", b"organization_id", "page_size", b"page_size", "page_token", b"page_token"]) -> None: ...
def ClearField(self, field_name: typing.Literal["filter", b"filter", "order_by", b"order_by", "organization_id", b"organization_id", "page_size", b"page_size", "page_token", b"page_token"]) -> None: ...

global___ListRemoteFilesRequest = ListRemoteFilesRequest

Expand Down
10 changes: 10 additions & 0 deletions python/lib/sift_client/_tests/resources/test_file_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ async def test_list_by_entity_type(
for fa in file_attachments:
assert fa.entity_type == RemoteFileEntityType.TEST_REPORTS

# Test filtering by TEST_STEPS entity type
file_attachments = await file_attachments_api_async.list_(
entity_type=RemoteFileEntityType.TEST_STEPS,
limit=100,
)
assert isinstance(file_attachments, list)
# All returned attachments should be for TEST_STEPS
for fa in file_attachments:
assert fa.entity_type == RemoteFileEntityType.TEST_STEPS

@pytest.mark.asyncio
async def test_list_by_file_name(
self, file_attachments_api_async, uploaded_file_attachment
Expand Down
7 changes: 5 additions & 2 deletions python/lib/sift_client/sift_types/file_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sift_client.client import SiftClient
from sift_client.sift_types.asset import Asset
from sift_client.sift_types.run import Run
from sift_client.sift_types.test_report import TestReport
from sift_client.sift_types.test_report import TestReport, TestStep


class RemoteFileEntityType(Enum):
Expand All @@ -27,6 +27,7 @@ class RemoteFileEntityType(Enum):
ASSETS = EntityType.ENTITY_TYPE_ASSET # 3
ANNOTATION_LOGS = EntityType.ENTITY_TYPE_ANNOTATION_LOG # 4
TEST_REPORTS = EntityType.ENTITY_TYPE_TEST_REPORT # 5
TEST_STEPS = EntityType.ENTITY_TYPE_TEST_STEP # 6

@classmethod
def from_str(cls, val: str) -> RemoteFileEntityType | None:
Expand Down Expand Up @@ -97,14 +98,16 @@ def _from_proto(
)

@property
def entity(self) -> Run | Asset | TestReport:
def entity(self) -> Run | Asset | TestReport | TestStep:
"""Get the entity that this file attachment is attached to."""
if self.entity_type == RemoteFileEntityType.RUNS:
return self.client.runs.get(run_id=self.entity_id)
elif self.entity_type == RemoteFileEntityType.ASSETS:
return self.client.assets.get(asset_id=self.entity_id)
elif self.entity_type == RemoteFileEntityType.TEST_REPORTS:
return self.client.test_results.get(test_report_id=self.entity_id)
elif self.entity_type == RemoteFileEntityType.TEST_STEPS:
return self.client.test_results.get_step(test_step=self.entity_id)
elif self.entity_type in (
RemoteFileEntityType.ANNOTATIONS,
RemoteFileEntityType.ANNOTATION_LOGS,
Expand Down
Loading
Loading