Skip to content

Commit

Permalink
[Core-547] Client: Catalog support for new event rules and new event …
Browse files Browse the repository at this point in the history
…types (#12708)

GitOrigin-RevId: a601c1bee027f55073963429237b36d4312b3d11
  • Loading branch information
stephencpope authored and Descartes Labs Build committed Oct 19, 2024
1 parent 526ae37 commit d15cecd
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 21 deletions.
10 changes: 10 additions & 0 deletions descarteslabs/core/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@
from .event_rule import EventRule, EventRuleCollection, EventRuleSearch, EventRuleTarget
from .event_schedule import EventSchedule, EventScheduleCollection, EventScheduleSearch
from .event_subscription import (
ComputeFunctionCompletedEventSubscription,
EventSubscription,
EventSubscriptionCollection,
EventSubscriptionComputeTarget,
EventSubscriptionSearch,
EventSubscriptionSqsTarget,
EventSubscriptionTarget,
EventType,
NewImageEventSubscription,
NewStorageEventSubscription,
NewVectorEventSubscription,
Placeholder,
ScheduledEventSubscription,
)
Expand Down Expand Up @@ -119,6 +124,7 @@
"CatalogObject",
"ClassBand",
"Colormap",
"ComputeFunctionCompletedEventSubscription",
"DataType",
"DeletedObjectError",
"DeletionTaskStatus",
Expand All @@ -140,6 +146,7 @@
"EventSubscriptionCollection",
"EventSubscriptionComputeTarget",
"EventSubscriptionSearch",
"EventSubscriptionSqsTarget",
"EventSubscriptionTarget",
"EventType",
"File",
Expand All @@ -160,6 +167,9 @@
"MaskBand",
"MicrowaveBand",
"NamedCatalogObject",
"NewImageEventSubscription",
"NewStorageEventSubscription",
"NewVectorEventSubscription",
"OverviewResampler",
"Placeholder",
"ProcessingLevelsAttribute",
Expand Down
6 changes: 5 additions & 1 deletion descarteslabs/core/catalog/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ def get_or_create(
if (not id and not name) or (id and name):
raise TypeError("Must specify exactly one of id or name parameters")
if not id:
id = f"{storage_type}/{Blob.namespace_id(namespace)}/{name}"
namespace = cls.namespace_id(namespace)
id = f"{storage_type}/{namespace}/{name}"
kwargs["storage_type"] = storage_type
kwargs["namespace"] = namespace
kwargs["name"] = name

return super(cls, Blob).get_or_create(id, client=client, **kwargs)

Expand Down
5 changes: 4 additions & 1 deletion descarteslabs/core/catalog/event_api_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ def get_or_create(
if (not id and not name) or (id and name):
raise TypeError("Must specify exactly one of id or name parameters")
if not id:
id = f"{cls.namespace_id(namespace)}:{name}"
namespace = cls.namespace_id(namespace)
id = f"{namespace}:{name}"
kwargs["namespace"] = namespace
kwargs["name"] = name

return super(cls, EventApiDestination).get_or_create(
id, client=client, **kwargs
Expand Down
12 changes: 11 additions & 1 deletion descarteslabs/core/catalog/event_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ class EventRule(CatalogObject):
str,
doc="""str: The ARN of the event bus to which this rule belongs.""",
)
role_arn = TypedAttribute(
str,
doc="""str, optional: The ARN of the role to assume when targeting another Event Bus.
*Filterable, sortable*.
""",
)
rule_arn = TypedAttribute(
str,
doc="""str: The ARN of the rule.""",
Expand Down Expand Up @@ -444,7 +451,10 @@ def get_or_create(
if (not id and not name) or (id and name):
raise TypeError("Must specify exactly one of id or name parameters")
if not id:
id = f"{cls.namespace_id(namespace)}:{name}"
namespace = cls.namespace_id(namespace)
id = f"{namespace}:{name}"
kwargs["namespace"] = namespace
kwargs["name"] = name

return super(cls, EventRule).get_or_create(id, client=client, **kwargs)

Expand Down
5 changes: 4 additions & 1 deletion descarteslabs/core/catalog/event_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ def get_or_create(
if (not id and not name) or (id and name):
raise TypeError("Must specify exactly one of id or name parameters")
if not id:
id = f"{cls.namespace_id(namespace)}:{name}"
namespace = cls.namespace_id(namespace)
id = f"{namespace}:{name}"
kwargs["namespace"] = namespace
kwargs["name"] = name

return super(cls, EventSchedule).get_or_create(id, client=client, **kwargs)

Expand Down
Loading

0 comments on commit d15cecd

Please sign in to comment.