1
1
"""Port.io action model."""
2
2
3
- from typing import Any
3
+ from typing import Any , Literal
4
4
5
5
from pydantic import Field
6
6
from pydantic .json_schema import SkipJsonSchema
@@ -25,76 +25,153 @@ class ActionTrigger(BaseModel):
25
25
26
26
type : str = Field (..., description = "The type of trigger" )
27
27
operation : str | SkipJsonSchema [None ] = Field (
28
- None , description = "The operation type (CREATE, DAY_2 , DELETE)"
28
+ None , description = "The operation type (CREATE, DAY-2 , DELETE)"
29
29
)
30
30
event : str | SkipJsonSchema [None ] = Field (
31
31
None , description = "The event that triggers the action"
32
32
)
33
33
condition : dict [str , Any ] | SkipJsonSchema [None ] = Field (
34
34
None , description = "Conditions for the trigger"
35
35
)
36
+ user_inputs : ActionSchema | SkipJsonSchema [None ] = Field (
37
+ None , description = "User input schema for the trigger" , alias = "userInputs"
38
+ )
39
+ blueprint_identifier : str | SkipJsonSchema [None ] = Field (
40
+ None , description = "The blueprint identifier for the trigger" , alias = "blueprintIdentifier"
41
+ )
42
+
43
+
44
+ class ActionInvocationMethodGitHub (BaseModel ):
45
+ """GitHub invocation method configuration."""
46
+
47
+ type : Literal ["GITHUB" ] = Field (..., description = "The type of invocation method" )
48
+ org : str = Field (..., description = "GitHub organization" )
49
+ repo : str = Field (..., description = "GitHub repository" )
50
+ workflow : str = Field (..., description = "GitHub workflow filename" )
51
+ omit_payload : bool | SkipJsonSchema [None ] = Field (None , description = "Whether to omit payload" )
52
+ omit_user_inputs : bool | SkipJsonSchema [None ] = Field (
53
+ None , description = "Whether to omit user inputs"
54
+ )
55
+ report_workflow_status : bool | SkipJsonSchema [None ] = Field (
56
+ None , description = "Whether to report workflow status"
57
+ )
58
+
59
+
60
+ class ActionInvocationMethodGitLab (BaseModel ):
61
+ """GitLab invocation method configuration."""
62
+
63
+ type : Literal ["GITLAB" ] = Field (..., description = "The type of invocation method" )
64
+ project_name : str = Field (..., description = "GitLab project name" , alias = "projectName" )
65
+ group_name : str = Field (..., description = "GitLab group name" , alias = "groupName" )
66
+ agent : Literal [True ] = Field (..., description = "Agent must be true for GitLab" )
67
+ omit_payload : bool | SkipJsonSchema [None ] = Field (
68
+ None , description = "Whether to omit payload" , alias = "omitPayload"
69
+ )
70
+ omit_user_inputs : bool | SkipJsonSchema [None ] = Field (
71
+ None , description = "Whether to omit user inputs" , alias = "omitUserInputs"
72
+ )
73
+ default_ref : str | SkipJsonSchema [None ] = Field (
74
+ None , description = "Default Git reference" , alias = "defaultRef"
75
+ )
76
+
77
+
78
+ class ActionInvocationMethodAzureDevOps (BaseModel ):
79
+ """Azure DevOps invocation method configuration."""
36
80
81
+ type : Literal ["AZURE-DEVOPS" ] = Field (..., description = "The type of invocation method" )
82
+ org : str = Field (..., description = "Azure DevOps organization" )
83
+ webhook : str = Field (..., description = "Azure DevOps webhook URL" )
37
84
38
- class ActionInvocationMethod (BaseModel ):
39
- """Action invocation method configuration."""
40
85
41
- type : str = Field (..., description = "The type of invocation method" )
42
- url : str | SkipJsonSchema [None ] = Field (None , description = "URL for webhook invocation" )
86
+ class ActionInvocationMethodWebhook (BaseModel ):
87
+ """Webhook invocation method configuration."""
88
+
89
+ type : Literal ["WEBHOOK" ] = Field (..., description = "The type of invocation method" )
90
+ url : str = Field (..., description = "Webhook URL" )
43
91
agent : bool | SkipJsonSchema [None ] = Field (
44
92
None , description = "Whether to use agent for invocation"
45
93
)
46
- method : str | SkipJsonSchema [None ] = Field (None , description = "HTTP method for webhook" )
94
+ synchronized : bool | SkipJsonSchema [None ] = Field (
95
+ None , description = "Whether the webhook is synchronized"
96
+ )
97
+ method : Literal ["POST" , "DELETE" , "PATCH" , "PUT" ] | SkipJsonSchema [None ] = Field (
98
+ None , description = "HTTP method for webhook"
99
+ )
47
100
headers : dict [str , str ] | SkipJsonSchema [None ] = Field (None , description = "Headers for webhook" )
48
101
body : str | dict [str , Any ] | SkipJsonSchema [None ] = Field (
49
102
None , description = "Body template for webhook (can be string or dict)"
50
103
)
51
104
52
105
53
- class ActionSummary (BaseModel ):
54
- """Simplified Action model with only basic information ."""
106
+ class ActionInvocationMethodKafka (BaseModel ):
107
+ """Kafka invocation method configuration ."""
55
108
56
- identifier : str = Field (..., description = "The unique identifier of the action" )
57
- title : str = Field (..., description = "The title of the action" )
58
- description : str | SkipJsonSchema [None ] = Field (
59
- None , description = "The description of the action"
60
- )
61
- blueprint : str | SkipJsonSchema [None ] = Field (
62
- None , description = "The blueprint this action belongs to"
63
- )
109
+ type : Literal ["KAFKA" ] = Field (..., description = "The type of invocation method" )
64
110
65
111
66
- class Action (BaseModel ):
67
- """Port.io Action model."""
112
+ # Union type for all invocation methods
113
+ ActionInvocationMethod = (
114
+ ActionInvocationMethodGitHub
115
+ | ActionInvocationMethodGitLab
116
+ | ActionInvocationMethodAzureDevOps
117
+ | ActionInvocationMethodWebhook
118
+ | ActionInvocationMethodKafka
119
+ )
120
+
121
+
122
+ class ActionCommon (BaseModel ):
123
+ """Common fields for action models."""
68
124
69
125
identifier : str = Field (..., description = "The unique identifier of the action" )
70
126
title : str = Field (..., description = "The title of the action" )
71
127
description : str | SkipJsonSchema [None ] = Field (
72
128
None , description = "The description of the action"
73
129
)
74
130
icon : Icon | SkipJsonSchema [None ] = Field (None , description = "The icon of the action" )
75
- blueprint : str | SkipJsonSchema [None ] = Field (
76
- None , description = "The blueprint this action belongs to"
77
- )
78
131
trigger : ActionTrigger = Field (..., description = "The trigger configuration" )
79
132
invocation_method : ActionInvocationMethod = Field (
80
133
...,
81
134
description = "The invocation method configuration" ,
82
135
alias = "invocationMethod" ,
83
136
serialization_alias = "invocationMethod" ,
84
137
)
85
- user_inputs : ActionSchema = Field (
86
- default_factory = ActionSchema ,
87
- description = "User input schema for the action" ,
88
- alias = "userInputs" ,
89
- serialization_alias = "userInputs" ,
90
- )
91
138
approval_notification : dict [str , Any ] | SkipJsonSchema [None ] = Field (
92
139
None ,
93
140
description = "Approval notification configuration" ,
94
141
alias = "approvalNotification" ,
95
142
serialization_alias = "approvalNotification" ,
96
143
)
144
+
145
+
146
+ class ActionSummary (BaseModel ):
147
+ """Simplified Action model with only basic information."""
148
+
149
+ identifier : str = Field (..., description = "The unique identifier of the action" )
150
+ title : str = Field (..., description = "The title of the action" )
151
+ description : str | SkipJsonSchema [None ] = Field (
152
+ None , description = "The description of the action"
153
+ )
154
+ blueprint : str | SkipJsonSchema [None ] = Field (
155
+ None , description = "The blueprint this action belongs to"
156
+ )
157
+
158
+
159
+ class Action (ActionCommon ):
160
+ """Port.io Action model."""
161
+
97
162
created_at : str | SkipJsonSchema [None ] = Field (None , description = "Creation timestamp" )
98
163
created_by : str | SkipJsonSchema [None ] = Field (None , description = "Creator user" )
99
164
updated_at : str | SkipJsonSchema [None ] = Field (None , description = "Last update timestamp" )
100
165
updated_by : str | SkipJsonSchema [None ] = Field (None , description = "Last updater user" )
166
+
167
+
168
+ class ActionCreate (ActionCommon ):
169
+ """Model for creating a new action."""
170
+
171
+ pass
172
+
173
+
174
+ class ActionUpdate (ActionCommon ):
175
+ """Model for updating an existing action."""
176
+
177
+ pass
0 commit comments