-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGlobalField.cs
More file actions
184 lines (173 loc) · 9.49 KB
/
GlobalField.cs
File metadata and controls
184 lines (173 loc) · 9.49 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
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
namespace Contentstack.Management.Core.Models
{
public class GlobalField : BaseModel<ContentModelling>
{
private readonly string apiVersion;
internal GlobalField(Stack stack, string uid = null, string apiVersion = null)
: base(stack, "global_field", uid)
{
resourcePath = uid == null ? "/global_fields" : $"/global_fields/{uid}";
this.apiVersion = apiVersion;
}
/// <summary>
/// The Query on Global Field will allow to fetch details of all or specific Content Type.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").GlobalField().Query().Find();
/// </code></pre>
/// </example>
/// <returns>The <see cref="Queryable.Query"/></returns>
public Query Query()
{
ThrowIfUidNotEmpty();
return new Query(stack, resourcePath, apiVersion);
}
/// <summary>
/// The Create global field with JSON RTE request shows you how to add a JSON RTE field while creating a global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentModeling model = new ContentModeling() // Add global field schema or field rules
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").GlobalField().Create(model);
/// </code></pre>
/// </example>
/// <param name="model">IGlobalField for updating Content Type.</param>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Create(ContentModelling model, ParameterCollection collection = null)
{
ThrowIfUidNotEmpty();
var service = new GlobalFieldService(stack.client.serializer, stack, resourcePath, model, this.fieldName, apiVersion, collection: collection);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}
/// <summary>
/// The Create global fieldwith JSON RTE request shows you how to add a JSON RTE field while creating a global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentModeling model = new ContentModeling() // Add global field schema or field rules
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").GlobalField().CreateAsync(model);
/// </code></pre>
/// </example>
/// <param name="model">IGlobalField for updating Content Type.</param>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> CreateAsync(ContentModelling model, ParameterCollection collection = null)
{
ThrowIfUidNotEmpty();
stack.ThrowIfNotLoggedIn();
var service = new GlobalFieldService(stack.client.serializer, stack, resourcePath, model, this.fieldName, apiVersion, collection: collection);
return stack.client.InvokeAsync<GlobalFieldService, ContentstackResponse>(service, apiVersion: apiVersion);
}
/// <summary>
/// The Update Content Type call is used to update the schema of an existing global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentModeling model = new ContentModeling() // Add global field schema or field rules
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").Update(model);
/// </code></pre>
/// </example>
/// <param name="model">IGlobalField for updating Content Type.</param>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Update(ContentModelling model, ParameterCollection collection = null)
{
ThrowIfUidEmpty();
var service = new GlobalFieldService(stack.client.serializer, stack, resourcePath, model, this.fieldName, apiVersion, "PUT", collection: collection);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}
/// <summary>
/// The Update Content Type call is used to update the schema of an existing global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentModeling model = new ContentModeling() // Add global field schema or field rules
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").UpdateAsync(model);
/// </code></pre>
/// </example>
/// <param name="model">IGlobalField for updating Content Type.</param>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> UpdateAsync(ContentModelling model, ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new GlobalFieldService(stack.client.serializer, stack, resourcePath, model, this.fieldName, apiVersion, "PUT", collection: collection);
return stack.client.InvokeAsync<GlobalFieldService, ContentstackResponse>(service, apiVersion: apiVersion);
}
/// <summary>
/// The Fetch a single global fieldcall returns information of a specific global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").Fetch();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Fetch(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new GlobalFieldFetchDeleteService(stack.client.serializer, stack, resourcePath, apiVersion, collection: collection);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}
/// <summary>
/// The Fetch a single global fieldcall returns information of a specific global field.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").FetchAsync();
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> FetchAsync(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new GlobalFieldFetchDeleteService(stack.client.serializer, stack, resourcePath, apiVersion, collection: collection);
return stack.client.InvokeAsync<GlobalFieldFetchDeleteService, ContentstackResponse>(service, apiVersion: apiVersion);
}
/// <summary>
/// The Delete Content Type call deletes an existing global fieldand all the entries within it.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").Delete();
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/>.</returns>
public override ContentstackResponse Delete(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new GlobalFieldFetchDeleteService(stack.client.serializer, stack, resourcePath, apiVersion, "DELETE", collection: collection);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}
/// <summary>
/// The Delete Content Type call deletes an existing global fieldand all the entries within it.
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.Stack("<API_KEY>").GlobalField("<GLOBAL_FIELD_UID>").DeleteAsync();
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public override Task<ContentstackResponse> DeleteAsync(ParameterCollection collection = null)
{
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
var service = new GlobalFieldFetchDeleteService(stack.client.serializer, stack, resourcePath, apiVersion, "DELETE", collection: collection);
return stack.client.InvokeAsync<GlobalFieldFetchDeleteService, ContentstackResponse>(service, apiVersion: apiVersion);
}
}
}