-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWorkflow.cs
More file actions
320 lines (295 loc) · 14.6 KB
/
Workflow.cs
File metadata and controls
320 lines (295 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;
namespace Contentstack.Management.Core.Models
{
public class Workflow: BaseModel<WorkflowModel>
{
internal Workflow(Stack stack, string uid)
: base(stack, "workflow", uid)
{
resourcePath = uid == null ? "/workflows" : $"/workflows/{uid}";
}
/// <summary>
/// The Get all Workflows request retrieves the details of all the Workflows of a stack.
/// </summary>
/// <param name="collection">Query parameter</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow().FindAll();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual ContentstackResponse FindAll(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidNotEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, collection: collection);
return stack.client.InvokeSync(service);
}
/// <summary>
/// The Get all Workflows request retrieves the details of all the Workflows of a stack.
/// </summary>
/// <param name="collection">Query parameter</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow().FindAllAsync();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual Task<ContentstackResponse> FindAllAsync(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidNotEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, collection: collection);
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}
/// <summary>
/// The Create Workflow request allows you to create a Workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// WorkflowModel model = new WorkflowModel();
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow().Create(model);
/// </code></pre>
/// </example>
/// <param name="model">Workflow Model for creating workflow.</param>
/// <returns></returns>
public override ContentstackResponse Create(WorkflowModel model, ParameterCollection collection = null)
{
return base.Create(model, collection);
}
/// <summary>
/// The Create Workflow request allows you to create a Workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// WorkflowModel model = new WorkflowModel();
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow().CreateAsync(model);
/// </code></pre>
/// </example>
/// <param name="model">Workflow Model for creating workflow.</param>
/// <returns></returns>
public override Task<ContentstackResponse> CreateAsync(WorkflowModel model, ParameterCollection collection = null)
{
return base.CreateAsync(model, collection);
}
/// <summary>
/// The Update Workflow request allows you to add a workflow stage or update the details of the existing stages of a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// WorkflowModel model = new WorkflowModel();
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").Update(model);
/// </code></pre>
/// </example>
/// <param name="model">Workflow Model for updating Content Type.</param>
/// <returns></returns>
public override ContentstackResponse Update(WorkflowModel model, ParameterCollection collection = null)
{
return base.Update(model, collection);
}
/// <summary>
/// The Update Workflow request allows you to add a workflow stage or update the details of the existing stages of a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// WorkflowModel model = new WorkflowModel();
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").UpdateAsync(model);
/// </code></pre>
/// </example>
/// <param name="model">Workflow Model for updating Content Type.</param>
/// <returns></returns>
public override Task<ContentstackResponse> UpdateAsync(WorkflowModel model, ParameterCollection collection = null)
{
return base.UpdateAsync(model, collection);
}
/// <summary>
/// The fetch Workflow request retrieves the comprehensive details of a specific Workflow of a stack.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").Fetch();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Fetch(ParameterCollection collection = null)
{
return base.Fetch(collection);
}
/// <summary>
/// The fetch Workflow request retrieves the comprehensive details of a specific Workflow of a stack.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").FetchAsync();
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> FetchAsync(ParameterCollection collection = null)
{
return base.FetchAsync(collection);
}
/// <summary>
/// The Delete Workflow request allows you to delete a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").Delete();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Delete(ParameterCollection collection = null)
{
return base.Delete(collection);
}
/// <summary>
/// The Delete Workflow request allows you to delete a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").DeleteAsync();
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> DeleteAsync(ParameterCollection collection = null)
{
return base.DeleteAsync(collection);
}
/// <summary>
/// The Disable Workflow request allows you to disable a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").Disable();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual ContentstackResponse Disable()
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, $"{resourcePath}/disable");
return stack.client.InvokeSync(service);
}
/// <summary>
/// The Disable Workflow request allows you to disable a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").DisableAsync();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual Task<ContentstackResponse> DisableAsync()
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, $"{resourcePath}/disable");
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}
/// <summary>
/// The Enable Workflow request allows you to enable a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").Enable();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual ContentstackResponse Enable()
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, $"{resourcePath}/disable");
return stack.client.InvokeSync(service);
}
/// <summary>
/// The Enable Workflow request allows you to enable a workflow.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").EnableAsync();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual Task<ContentstackResponse> EnableAsync()
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new FetchDeleteService(stack.client.serializer, stack, $"{resourcePath}/disable");
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}
/// <summary>
/// <see cref="Models.PublishRule" /> is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow().PublishRule("<ENTRY_UID>").Fetch();
/// </code></pre>
/// </example>
/// <param name="uid">Optional Publish rule uid for performing rule specific operation</param>
/// <returns></returns>
public PublishRule PublishRule(string uid = null)
{
return new PublishRule(stack, uid);
}
/// <summary>
/// The Get Publish Rules by Content Types request allows you to retrieve details of a Publish Rule applied to a specific content type of your stack.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").GetPublishRule("<CONTENT_TYPE_UID>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual ContentstackResponse GetPublishRule(string contentType, ParameterCollection collection)
{
stack.ThrowIfNotLoggedIn();
if (string.IsNullOrEmpty(contentType))
{
throw new ArgumentNullException("contentType", CSConstants.ContentTypeRequired);
}
var service = new FetchDeleteService(stack.client.serializer, stack, $"/workflows/content_type/{contentType}", collection: collection);
return stack.client.InvokeSync(service);
}
/// <summary>
/// The Get Publish Rules by Content Types request allows you to retrieve details of a Publish Rule applied to a specific content type of your stack.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").Workflow("<WORKFLOW_UID>").GetPublishRuleAsync("<CONTENT_TYPE_UID>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public virtual Task<ContentstackResponse> GetPublishRuleAsync(string contentType, ParameterCollection collection)
{
stack.ThrowIfNotLoggedIn();
if (string.IsNullOrEmpty(contentType))
{
throw new ArgumentNullException("contentType", CSConstants.ContentTypeRequired);
}
var service = new FetchDeleteService(stack.client.serializer, stack, $"/workflows/content_type/{contentType}", collection: collection);
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}
}
}