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
16 changes: 16 additions & 0 deletions dashscope/agentstudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
DeploymentCreateParams,
DeploymentUpdateParams,
SessionEventSendParams,
WebhookEndpointCreateParams,
WebhookEndpointUpdateParams,
WebhookEventListParams,
)
from .constants import (
WebhookDeliveryStatus,
WebhookDisabledReason,
WebhookEventType,
WebhookStatus,
)

__all__ = [
Expand Down Expand Up @@ -119,4 +128,11 @@
"DeploymentCreateParams",
"DeploymentUpdateParams",
"SessionEventSendParams",
"WebhookEndpointCreateParams",
"WebhookEndpointUpdateParams",
"WebhookEventListParams",
"WebhookStatus",
"WebhookDisabledReason",
"WebhookDeliveryStatus",
"WebhookEventType",
]
6 changes: 6 additions & 0 deletions dashscope/agentstudio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
from dashscope.agentstudio.resources.sessions import Sessions, AsyncSessions
from dashscope.agentstudio.resources.skills import Skills, AsyncSkills
from dashscope.agentstudio.resources.vaults import Vaults, AsyncVaults
from dashscope.agentstudio.resources.webhook_endpoints import (
AsyncWebhookEndpoints,
WebhookEndpoints,
)
from dashscope.agentstudio.constants import (
AGENTSTUDIO_BASE_URL_TEMPLATE,
AGENTSTUDIO_DEFAULT_REGION,
Expand Down Expand Up @@ -129,6 +133,7 @@ def __init__(
self.files = Files(self)
self.skills = Skills(self)
self.vaults = Vaults(self)
self.webhook_endpoints = WebhookEndpoints(self)

def close(self) -> None:
self.transport.close()
Expand Down Expand Up @@ -201,6 +206,7 @@ def __init__(
self.files = AsyncFiles(self)
self.skills = AsyncSkills(self)
self.vaults = AsyncVaults(self)
self.webhook_endpoints = AsyncWebhookEndpoints(self)

async def aclose(self) -> None:
await self.transport.aclose()
Expand Down
110 changes: 110 additions & 0 deletions dashscope/agentstudio/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,113 @@ class SessionStatus(StrEnum):
RUNNING = "running"
RESCHEDULING = "rescheduling"
TERMINATED = "terminated"


class WebhookStatus(StrEnum):
"""Webhook endpoint activation status."""

# The endpoint can receive webhook deliveries.
ACTIVE = "ACTIVE"
# The endpoint does not receive webhook deliveries.
DISABLED = "DISABLED"


class WebhookDisabledReason(StrEnum):
"""Reason why a webhook endpoint was disabled."""

# The endpoint was disabled manually.
MANUAL = "MANUAL"
# The endpoint reached the consecutive delivery failure threshold.
CONSECUTIVE_DELIVERY_FAILURES = "CONSECUTIVE_DELIVERY_FAILURES"
# The endpoint returned an HTTP redirect response.
REDIRECT_RESPONSE = "REDIRECT_RESPONSE"
# The endpoint failed server-side request forgery validation.
SSRF_VALIDATION_FAILED = "SSRF_VALIDATION_FAILED"
# The endpoint failed Transport Layer Security validation.
TLS_VALIDATION_FAILED = "TLS_VALIDATION_FAILED"


class WebhookDeliveryStatus(StrEnum):
"""Webhook delivery status."""

# The delivery is waiting to start.
PENDING = "PENDING"
# The delivery is currently being sent.
DELIVERING = "DELIVERING"
# The delivery is waiting for its next retry.
WAITING_RETRY = "WAITING_RETRY"
# The delivery completed successfully.
SUCCEEDED = "SUCCEEDED"
# The delivery exhausted all attempts.
FAILED = "FAILED"
# The delivery was canceled because its endpoint was disabled or deleted.
CANCELED = "CANCELED"


class WebhookEventType(StrEnum):
"""Event types accepted by webhook endpoint subscriptions."""

# A session was created.
SESSION_CREATED = "session.created"
# A session was updated.
SESSION_UPDATED = "session.updated"
# A session was archived.
SESSION_ARCHIVED = "session.archived"
# A session was deleted.
SESSION_DELETED = "session.deleted"
# A session run started.
SESSION_STATUS_RUN_STARTED = "session.status_run_started"
# A session entered the idle state.
SESSION_STATUS_IDLED = "session.status_idled"
# A session entered the terminated state.
SESSION_STATUS_TERMINATED = "session.status_terminated"
# A session thread was created.
SESSION_THREAD_CREATED = "session.thread_created"
# A session thread run started.
SESSION_THREAD_RUN_STARTED = "session.thread_run_started"
# A session thread entered the idle state.
SESSION_THREAD_IDLED = "session.thread_idled"
# A session thread entered the terminated state.
SESSION_THREAD_TERMINATED = "session.thread_terminated"
# An agent was created.
AGENT_CREATED = "agent.created"
# An agent was updated.
AGENT_UPDATED = "agent.updated"
# An agent was archived.
AGENT_ARCHIVED = "agent.archived"
# A deployment was created.
DEPLOYMENT_CREATED = "deployment.created"
# A deployment was updated.
DEPLOYMENT_UPDATED = "deployment.updated"
# A deployment was archived.
DEPLOYMENT_ARCHIVED = "deployment.archived"
# A deployment was paused.
DEPLOYMENT_PAUSED = "deployment.paused"
# A deployment was resumed.
DEPLOYMENT_UNPAUSED = "deployment.unpaused"
# A deployment run started.
DEPLOYMENT_RUN_STARTED = "deployment_run.started"
# A deployment run failed.
DEPLOYMENT_RUN_FAILED = "deployment_run.failed"
# A deployment run succeeded.
DEPLOYMENT_RUN_SUCCEEDED = "deployment_run.succeeded"
# An environment was created.
ENVIRONMENT_CREATED = "environment.created"
# An environment was updated.
ENVIRONMENT_UPDATED = "environment.updated"
# An environment was archived.
ENVIRONMENT_ARCHIVED = "environment.archived"
# An environment was deleted.
ENVIRONMENT_DELETED = "environment.deleted"
# A vault was created.
VAULT_CREATED = "vault.created"
# A vault was archived.
VAULT_ARCHIVED = "vault.archived"
# A vault was deleted.
VAULT_DELETED = "vault.deleted"
# A vault credential was created.
VAULT_CREDENTIAL_CREATED = "vault_credential.created"
# A vault credential was archived.
VAULT_CREDENTIAL_ARCHIVED = "vault_credential.archived"
# A vault credential was deleted.
VAULT_CREDENTIAL_DELETED = "vault_credential.deleted"
6 changes: 6 additions & 0 deletions dashscope/agentstudio/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
Credentials,
Vaults,
)
from dashscope.agentstudio.resources.webhook_endpoints import (
AsyncWebhookEndpoints,
WebhookEndpoints,
)

__all__ = [
"Agents",
Expand All @@ -70,6 +74,8 @@
"AsyncSessionEvents",
"Vaults",
"AsyncVaults",
"WebhookEndpoints",
"AsyncWebhookEndpoints",
"_TypedEventStream",
"_AioTypedEventStream",
]
17 changes: 17 additions & 0 deletions dashscope/agentstudio/resources/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
Skill,
SkillVersion,
Vault,
WebhookEndpoint,
WebhookEvent,
WebhookSecretReset,
parse_server_event,
)

Expand Down Expand Up @@ -68,6 +71,20 @@ def _coerce_credential(payload: Mapping[str, Any]) -> Credential:
return Credential(**dict(payload))


def _coerce_webhook_endpoint(payload: Mapping[str, Any]) -> WebhookEndpoint:
return WebhookEndpoint(**dict(payload))


def _coerce_webhook_event(payload: Mapping[str, Any]) -> WebhookEvent:
return WebhookEvent(**dict(payload))


def _coerce_webhook_secret_reset(
payload: Mapping[str, Any],
) -> WebhookSecretReset:
return WebhookSecretReset(**dict(payload))


def _coerce_deployment(payload: Mapping[str, Any]) -> Deployment:
return Deployment(**dict(payload))

Expand Down
Loading
Loading