@agility/management-sdk 0.1.38 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,268 +1,268 @@
1
- # Agility CMS & Management API TypeScript SDK
2
-
3
- ## ContainerMethods
4
-
5
- This class provides comprehensive container management operations for organizing and managing content within Agility CMS. Containers are used to group related content items and control access permissions.
6
-
7
- **Important Notes:**
8
- - Containers organize content items by their definition types
9
- - Each container has security settings that control user access
10
- - Containers can have notification settings for workflow events
11
- - Reference names must be unique within the instance
12
- - Containers cannot be deleted if they contain content items
13
-
14
- ### Function List
15
- - [getContainerByID](#getcontainerbyid) - Retrieves a specific container by ID
16
- - [getContainersByModel](#getcontainersbymodel) - Retrieves containers associated with a content model
17
- - [getContainerByReferenceName](#getcontainerbyreferencename) - Retrieves a container by reference name
18
- - [getContainerSecurity](#getcontainersecurity) - Retrieves security settings for a container
19
- - [getContainerList](#getcontainerlist) - Retrieves list of all containers
20
- - [getNotificationList](#getnotificationlist) - Retrieves notification settings for a container
21
- - [saveContainer](#savecontainer) - Creates or updates a container
22
- - [deleteContainer](#deletecontainer) - Deletes a container by ID
23
-
24
- ---
25
-
26
- ### getContainerByID
27
-
28
- Retrieves a specific container by its unique ID.
29
-
30
- | Parameter | Type | Required | Description |
31
- |-----------|------|----------|-------------|
32
- | `id` | `number` | Yes | The container ID to retrieve |
33
- | `guid` | `string` | Yes | Current website GUID |
34
-
35
- **Returns:** `Container` - Container object with complete configuration
36
-
37
- **Usage Example:**
38
- ```typescript
39
- const container = await apiClient.containerMethods.getContainerByID(123, guid);
40
- console.log('Container name:', container.displayName);
41
- console.log('Reference name:', container.referenceName);
42
- console.log('Model ID:', container.modelId);
43
- ```
44
-
45
- **Error Handling:**
46
- - Throws `Exception` when container not found
47
-
48
- ### getContainersByModel
49
-
50
- Retrieves all containers associated with a specific content model.
51
-
52
- | Parameter | Type | Required | Description |
53
- |-----------|------|----------|-------------|
54
- | `modelId` | `number` | Yes | The content model ID |
55
- | `guid` | `string` | Yes | Current website GUID |
56
-
57
- **Returns:** `Container[]` - Array of containers using the specified model
58
-
59
- **Usage Example:**
60
- ```typescript
61
- const containers = await apiClient.containerMethods.getContainersByModel(456, guid);
62
- console.log(`Found ${containers.length} containers for this model`);
63
-
64
- // Process each container
65
- containers.forEach(container => {
66
- console.log(`Container: ${container.displayName} (${container.referenceName})`);
67
- });
68
- ```
69
-
70
- **Error Handling:**
71
- - Throws `Exception` when model not found or retrieval fails
72
-
73
- ### getContainerByReferenceName
74
-
75
- Retrieves a container by its reference name. Returns null if the container doesn't exist.
76
-
77
- | Parameter | Type | Required | Description |
78
- |-----------|------|----------|-------------|
79
- | `referenceName` | `string` | Yes | The reference name of the container |
80
- | `guid` | `string` | Yes | Current website GUID |
81
-
82
- **Returns:** `Container | null` - Container object or null if not found
83
-
84
- **Usage Example:**
85
- ```typescript
86
- const container = await apiClient.containerMethods.getContainerByReferenceName('blog-posts', guid);
87
- if (container) {
88
- console.log('Container found:', container.displayName);
89
- console.log('Container ID:', container.id);
90
- } else {
91
- console.log('Container not found');
92
- }
93
- ```
94
-
95
- **Error Handling:**
96
- - Returns `null` for 404 errors (container not found)
97
- - Throws `Exception` for other errors
98
-
99
- ### getContainerSecurity
100
-
101
- Retrieves the security settings for a specific container.
102
-
103
- | Parameter | Type | Required | Description |
104
- |-----------|------|----------|-------------|
105
- | `id` | `number` | Yes | The container ID |
106
- | `guid` | `string` | Yes | Current website GUID |
107
-
108
- **Returns:** `Container` - Container object with security information
109
-
110
- **Usage Example:**
111
- ```typescript
112
- const security = await apiClient.containerMethods.getContainerSecurity(123, guid);
113
- console.log('Security settings:', security.securitySettings);
114
-
115
- // Check if container has specific permissions
116
- if (security.securitySettings) {
117
- console.log('Container has custom security settings');
118
- } else {
119
- console.log('Container uses default security settings');
120
- }
121
- ```
122
-
123
- **Error Handling:**
124
- - Throws `Exception` when container not found or access denied
125
-
126
- ### getContainerList
127
-
128
- Retrieves a list of all containers in the current website.
129
-
130
- | Parameter | Type | Required | Description |
131
- |-----------|------|----------|-------------|
132
- | `guid` | `string` | Yes | Current website GUID |
133
-
134
- **Returns:** `Container[]` - Array of all containers
135
-
136
- **Usage Example:**
137
- ```typescript
138
- const containers = await apiClient.containerMethods.getContainerList(guid);
139
- console.log(`Total containers: ${containers.length}`);
140
-
141
- // Filter by content type
142
- const blogContainers = containers.filter(c => c.referenceName.includes('blog'));
143
- console.log(`Blog-related containers: ${blogContainers.length}`);
144
-
145
- // Group by model
146
- const containersByModel = containers.reduce((acc, container) => {
147
- const modelId = container.modelId;
148
- if (!acc[modelId]) acc[modelId] = [];
149
- acc[modelId].push(container);
150
- return acc;
151
- }, {});
152
- ```
153
-
154
- **Error Handling:**
155
- - Throws `Exception` when retrieval fails
156
-
157
- ### getNotificationList
158
-
159
- Retrieves the notification settings for a specific container.
160
-
161
- | Parameter | Type | Required | Description |
162
- |-----------|------|----------|-------------|
163
- | `id` | `number` | Yes | The container ID |
164
- | `guid` | `string` | Yes | Current website GUID |
165
-
166
- **Returns:** `Notification[]` - Array of notification configurations
167
-
168
- **Usage Example:**
169
- ```typescript
170
- const notifications = await apiClient.containerMethods.getNotificationList(123, guid);
171
- console.log(`Container has ${notifications.length} notification rules`);
172
-
173
- notifications.forEach(notification => {
174
- console.log(`Notification: ${notification.name}`);
175
- console.log(`Type: ${notification.type}`);
176
- console.log(`Recipients: ${notification.recipients}`);
177
- });
178
- ```
179
-
180
- **Error Handling:**
181
- - Throws `Exception` when container not found or access denied
182
-
183
- ### saveContainer
184
-
185
- Creates a new container or updates an existing one.
186
-
187
- | Parameter | Type | Required | Description |
188
- |-----------|------|----------|-------------|
189
- | `container` | `Container` | Yes | Container object to save |
190
- | `guid` | `string` | Yes | Current website GUID |
191
- | `forceReferenceName` | `boolean` | No | Force reference name validation *(Optional, default: false)* |
192
-
193
- **Returns:** `Container` - Saved container object with updated metadata
194
-
195
- **Usage Example:**
196
- ```typescript
197
- // Create a new container
198
- const newContainer = {
199
- referenceName: 'product-reviews',
200
- displayName: 'Product Reviews',
201
- modelId: 789,
202
- isPublicListing: true,
203
- description: 'Container for product review content items'
204
- };
205
-
206
- const savedContainer = await apiClient.containerMethods.saveContainer(
207
- newContainer,
208
- guid,
209
- true
210
- );
211
- console.log('Container saved with ID:', savedContainer.id);
212
-
213
- // Update existing container
214
- const existingContainer = await apiClient.containerMethods.getContainerByID(123, guid);
215
- existingContainer.displayName = 'Updated Display Name';
216
- const updatedContainer = await apiClient.containerMethods.saveContainer(existingContainer, guid);
217
- ```
218
-
219
- **Error Handling:**
220
- - Throws `Exception` when validation fails or save operation fails
221
-
222
- ### deleteContainer
223
-
224
- Deletes a container by its ID.
225
-
226
- | Parameter | Type | Required | Description |
227
- |-----------|------|----------|-------------|
228
- | `id` | `number` | Yes | The container ID to delete |
229
- | `guid` | `string` | Yes | Current website GUID |
230
-
231
- **Returns:** `string` - Confirmation message of successful deletion
232
-
233
- **Usage Example:**
234
- ```typescript
235
- try {
236
- const result = await apiClient.containerMethods.deleteContainer(123, guid);
237
- console.log(result); // "Container deleted successfully"
238
- } catch (error) {
239
- if (error.message.includes('contains content')) {
240
- console.log('Cannot delete container: still contains content items');
241
- // Handle by moving or deleting content first
242
- } else {
243
- console.error('Failed to delete container:', error.message);
244
- }
245
- }
246
- ```
247
-
248
- **Error Handling:**
249
- - Throws `Exception` when container not found, has content, or deletion fails
250
-
251
- **Note:** Containers cannot be deleted if they contain content items. Remove all content first.
252
-
253
- ---
254
-
255
- ## Navigation
256
- - [← Back to Main Documentation](../README.md)
257
- - [Authentication & Setup](./auth.md)
258
- - [CI/CD & Automated Environments](./cicd.md)
259
- - [AssetMethods](./asset-methods.md)
260
- - [BatchMethods](./batch-methods.md)
261
- - [ContentMethods](./content-methods.md)
262
- - [InstanceMethods](./instance-methods.md)
263
- - [InstanceUserMethods](./instance-user-methods.md)
264
- - [ModelMethods](./model-methods.md)
265
- - [PageMethods](./page-methods.md)
266
- - [ServerUserMethods](./server-user-methods.md)
267
- - [WebhookMethods](./webhook-methods.md)
1
+ # Agility CMS & Management API TypeScript SDK
2
+
3
+ ## ContainerMethods
4
+
5
+ This class provides comprehensive container management operations for organizing and managing content within Agility CMS. Containers are used to group related content items and control access permissions.
6
+
7
+ **Important Notes:**
8
+ - Containers organize content items by their definition types
9
+ - Each container has security settings that control user access
10
+ - Containers can have notification settings for workflow events
11
+ - Reference names must be unique within the instance
12
+ - Containers cannot be deleted if they contain content items
13
+
14
+ ### Function List
15
+ - [getContainerByID](#getcontainerbyid) - Retrieves a specific container by ID
16
+ - [getContainersByModel](#getcontainersbymodel) - Retrieves containers associated with a content model
17
+ - [getContainerByReferenceName](#getcontainerbyreferencename) - Retrieves a container by reference name
18
+ - [getContainerSecurity](#getcontainersecurity) - Retrieves security settings for a container
19
+ - [getContainerList](#getcontainerlist) - Retrieves list of all containers
20
+ - [getNotificationList](#getnotificationlist) - Retrieves notification settings for a container
21
+ - [saveContainer](#savecontainer) - Creates or updates a container
22
+ - [deleteContainer](#deletecontainer) - Deletes a container by ID
23
+
24
+ ---
25
+
26
+ ### getContainerByID
27
+
28
+ Retrieves a specific container by its unique ID.
29
+
30
+ | Parameter | Type | Required | Description |
31
+ |-----------|------|----------|-------------|
32
+ | `id` | `number` | Yes | The container ID to retrieve |
33
+ | `guid` | `string` | Yes | Current website GUID |
34
+
35
+ **Returns:** `Container` - Container object with complete configuration
36
+
37
+ **Usage Example:**
38
+ ```typescript
39
+ const container = await apiClient.containerMethods.getContainerByID(123, guid);
40
+ console.log('Container name:', container.displayName);
41
+ console.log('Reference name:', container.referenceName);
42
+ console.log('Model ID:', container.modelId);
43
+ ```
44
+
45
+ **Error Handling:**
46
+ - Throws `Exception` when container not found
47
+
48
+ ### getContainersByModel
49
+
50
+ Retrieves all containers associated with a specific content model.
51
+
52
+ | Parameter | Type | Required | Description |
53
+ |-----------|------|----------|-------------|
54
+ | `modelId` | `number` | Yes | The content model ID |
55
+ | `guid` | `string` | Yes | Current website GUID |
56
+
57
+ **Returns:** `Container[]` - Array of containers using the specified model
58
+
59
+ **Usage Example:**
60
+ ```typescript
61
+ const containers = await apiClient.containerMethods.getContainersByModel(456, guid);
62
+ console.log(`Found ${containers.length} containers for this model`);
63
+
64
+ // Process each container
65
+ containers.forEach(container => {
66
+ console.log(`Container: ${container.displayName} (${container.referenceName})`);
67
+ });
68
+ ```
69
+
70
+ **Error Handling:**
71
+ - Throws `Exception` when model not found or retrieval fails
72
+
73
+ ### getContainerByReferenceName
74
+
75
+ Retrieves a container by its reference name. Returns null if the container doesn't exist.
76
+
77
+ | Parameter | Type | Required | Description |
78
+ |-----------|------|----------|-------------|
79
+ | `referenceName` | `string` | Yes | The reference name of the container |
80
+ | `guid` | `string` | Yes | Current website GUID |
81
+
82
+ **Returns:** `Container | null` - Container object or null if not found
83
+
84
+ **Usage Example:**
85
+ ```typescript
86
+ const container = await apiClient.containerMethods.getContainerByReferenceName('blog-posts', guid);
87
+ if (container) {
88
+ console.log('Container found:', container.displayName);
89
+ console.log('Container ID:', container.id);
90
+ } else {
91
+ console.log('Container not found');
92
+ }
93
+ ```
94
+
95
+ **Error Handling:**
96
+ - Returns `null` for 404 errors (container not found)
97
+ - Throws `Exception` for other errors
98
+
99
+ ### getContainerSecurity
100
+
101
+ Retrieves the security settings for a specific container.
102
+
103
+ | Parameter | Type | Required | Description |
104
+ |-----------|------|----------|-------------|
105
+ | `id` | `number` | Yes | The container ID |
106
+ | `guid` | `string` | Yes | Current website GUID |
107
+
108
+ **Returns:** `Container` - Container object with security information
109
+
110
+ **Usage Example:**
111
+ ```typescript
112
+ const security = await apiClient.containerMethods.getContainerSecurity(123, guid);
113
+ console.log('Security settings:', security.securitySettings);
114
+
115
+ // Check if container has specific permissions
116
+ if (security.securitySettings) {
117
+ console.log('Container has custom security settings');
118
+ } else {
119
+ console.log('Container uses default security settings');
120
+ }
121
+ ```
122
+
123
+ **Error Handling:**
124
+ - Throws `Exception` when container not found or access denied
125
+
126
+ ### getContainerList
127
+
128
+ Retrieves a list of all containers in the current website.
129
+
130
+ | Parameter | Type | Required | Description |
131
+ |-----------|------|----------|-------------|
132
+ | `guid` | `string` | Yes | Current website GUID |
133
+
134
+ **Returns:** `Container[]` - Array of all containers
135
+
136
+ **Usage Example:**
137
+ ```typescript
138
+ const containers = await apiClient.containerMethods.getContainerList(guid);
139
+ console.log(`Total containers: ${containers.length}`);
140
+
141
+ // Filter by content type
142
+ const blogContainers = containers.filter(c => c.referenceName.includes('blog'));
143
+ console.log(`Blog-related containers: ${blogContainers.length}`);
144
+
145
+ // Group by model
146
+ const containersByModel = containers.reduce((acc, container) => {
147
+ const modelId = container.modelId;
148
+ if (!acc[modelId]) acc[modelId] = [];
149
+ acc[modelId].push(container);
150
+ return acc;
151
+ }, {});
152
+ ```
153
+
154
+ **Error Handling:**
155
+ - Throws `Exception` when retrieval fails
156
+
157
+ ### getNotificationList
158
+
159
+ Retrieves the notification settings for a specific container.
160
+
161
+ | Parameter | Type | Required | Description |
162
+ |-----------|------|----------|-------------|
163
+ | `id` | `number` | Yes | The container ID |
164
+ | `guid` | `string` | Yes | Current website GUID |
165
+
166
+ **Returns:** `Notification[]` - Array of notification configurations
167
+
168
+ **Usage Example:**
169
+ ```typescript
170
+ const notifications = await apiClient.containerMethods.getNotificationList(123, guid);
171
+ console.log(`Container has ${notifications.length} notification rules`);
172
+
173
+ notifications.forEach(notification => {
174
+ console.log(`Notification: ${notification.name}`);
175
+ console.log(`Type: ${notification.type}`);
176
+ console.log(`Recipients: ${notification.recipients}`);
177
+ });
178
+ ```
179
+
180
+ **Error Handling:**
181
+ - Throws `Exception` when container not found or access denied
182
+
183
+ ### saveContainer
184
+
185
+ Creates a new container or updates an existing one.
186
+
187
+ | Parameter | Type | Required | Description |
188
+ |-----------|------|----------|-------------|
189
+ | `container` | `Container` | Yes | Container object to save |
190
+ | `guid` | `string` | Yes | Current website GUID |
191
+ | `forceReferenceName` | `boolean` | No | Force reference name validation *(Optional, default: false)* |
192
+
193
+ **Returns:** `Container` - Saved container object with updated metadata
194
+
195
+ **Usage Example:**
196
+ ```typescript
197
+ // Create a new container
198
+ const newContainer = {
199
+ referenceName: 'product-reviews',
200
+ displayName: 'Product Reviews',
201
+ modelId: 789,
202
+ isPublicListing: true,
203
+ description: 'Container for product review content items'
204
+ };
205
+
206
+ const savedContainer = await apiClient.containerMethods.saveContainer(
207
+ newContainer,
208
+ guid,
209
+ true
210
+ );
211
+ console.log('Container saved with ID:', savedContainer.id);
212
+
213
+ // Update existing container
214
+ const existingContainer = await apiClient.containerMethods.getContainerByID(123, guid);
215
+ existingContainer.displayName = 'Updated Display Name';
216
+ const updatedContainer = await apiClient.containerMethods.saveContainer(existingContainer, guid);
217
+ ```
218
+
219
+ **Error Handling:**
220
+ - Throws `Exception` when validation fails or save operation fails
221
+
222
+ ### deleteContainer
223
+
224
+ Deletes a container by its ID.
225
+
226
+ | Parameter | Type | Required | Description |
227
+ |-----------|------|----------|-------------|
228
+ | `id` | `number` | Yes | The container ID to delete |
229
+ | `guid` | `string` | Yes | Current website GUID |
230
+
231
+ **Returns:** `string` - Confirmation message of successful deletion
232
+
233
+ **Usage Example:**
234
+ ```typescript
235
+ try {
236
+ const result = await apiClient.containerMethods.deleteContainer(123, guid);
237
+ console.log(result); // "Container deleted successfully"
238
+ } catch (error) {
239
+ if (error.message.includes('contains content')) {
240
+ console.log('Cannot delete container: still contains content items');
241
+ // Handle by moving or deleting content first
242
+ } else {
243
+ console.error('Failed to delete container:', error.message);
244
+ }
245
+ }
246
+ ```
247
+
248
+ **Error Handling:**
249
+ - Throws `Exception` when container not found, has content, or deletion fails
250
+
251
+ **Note:** Containers cannot be deleted if they contain content items. Remove all content first.
252
+
253
+ ---
254
+
255
+ ## Navigation
256
+ - [← Back to Main Documentation](../README.md)
257
+ - [Authentication & Setup](./auth.md)
258
+ - [CI/CD & Automated Environments](./cicd.md)
259
+ - [AssetMethods](./asset-methods.md)
260
+ - [BatchMethods](./batch-methods.md)
261
+ - [ContentMethods](./content-methods.md)
262
+ - [InstanceMethods](./instance-methods.md)
263
+ - [InstanceUserMethods](./instance-user-methods.md)
264
+ - [ModelMethods](./model-methods.md)
265
+ - [PageMethods](./page-methods.md)
266
+ - [ServerUserMethods](./server-user-methods.md)
267
+ - [WebhookMethods](./webhook-methods.md)
268
268
  - [Multi-Instance Operations](./multi-instance-operations.md)