list_storage_containers
Retrieve a list of storage containers for a specified Optimizely DXP environment. Use project details and credentials to access Integration, Preproduction, or Production environments for efficient container management.
Instructions
List storage containers for an environment (uses configured project)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | ||
| apiSecret | No | ||
| environment | Yes | ||
| projectId | No | ||
| projectName | No |
Implementation Reference
- lib/tools/storage-tools.ts:105-154 (handler)Primary handler for 'list_storage_containers' tool. Handles argument resolution, self-hosted detection, project credential resolution, and delegates to core listStorageContainers function.static async handleListStorageContainers(args: StorageArgs): Promise<any> { try { // Check if this is a self-hosted project if (args.connectionString || args.isSelfHosted) { const containers = await SelfHostedStorage.listContainers(args.connectionString!); return ResponseBuilder.success(this.formatSelfHostedContainers(containers)); } // Resolve project configuration if credentials not provided let resolvedArgs = args; if (!args.apiKey || !args.apiSecret || !args.projectId) { const resolved = ProjectTools.resolveCredentials(args); // Check if the resolved project is self-hosted if (resolved.project?.isSelfHosted) { const containers = await SelfHostedStorage.listContainers(resolved.project.connectionString as string); return ResponseBuilder.success(this.formatSelfHostedContainers(containers)); } if (!resolved.success || !resolved.credentials) { return ResponseBuilder.invalidParams('Missing required parameters. Either provide apiKey/apiSecret/projectId or configure a project.'); } resolvedArgs = { ...args, apiKey: resolved.credentials.apiKey || undefined, apiSecret: resolved.credentials.apiSecret || undefined, projectId: resolved.credentials.projectId || undefined, projectName: resolved.project?.name }; } // Default to Production if no environment specified if (!resolvedArgs.environment) { resolvedArgs.environment = 'Production'; } const result = await this.listStorageContainers(resolvedArgs); // DXP-66: Check if result is structured response with data and message if (result && typeof result === 'object' && 'data' in result && 'message' in result) { return ResponseBuilder.successWithStructuredData(result.data, result.message); } // Fallback for legacy string responses return ResponseBuilder.success(result); } catch (error: any) { // console.error('List storage containers error:', error); return ResponseBuilder.internalError('Failed to list storage containers', error.message); } }
- lib/tools/storage-tools.ts:156-223 (helper)Core implementation of container listing using DXPRestClient.getStorageContainers API call, with pagination support and response formatting.static async listStorageContainers(args: StorageArgs): Promise<StorageContainersResult | string> { // DXP-76-4: Extract pagination parameters const { limit = 20, offset = 0 } = args; // Extract authentication parameters const apiKey = args.apiKey!; const apiSecret = args.apiSecret!; const projectId = args.projectId!; const environment = args.environment!; // console.error(`Listing storage containers for ${environment}`); // DXP-102: Use REST API instead of PowerShell (3-10x faster, no PowerShell dependency) try { const result: StorageContainersResponse | string[] = await DXPRestClient.getStorageContainers( projectId, apiKey, apiSecret, environment, false, // writable parameter { apiUrl: args.apiUrl } // Support custom API URLs ); // Get all containers let allContainers: string[]; if (Array.isArray(result)) { allContainers = result; } else if (result && (result as any).storageContainers) { allContainers = (result as any).storageContainers; } else { allContainers = []; } // DXP-76-4: Apply pagination const total = allContainers.length; const paginatedContainers = allContainers.slice(offset, offset + limit); // Format response - REST API returns array of container names directly if (paginatedContainers.length > 0) { return this.formatStorageContainers(paginatedContainers, environment, { total, limit, offset, hasMore: (offset + limit) < total }); } else if (allContainers.length === 0) { return this.formatStorageContainers([], environment, { total: 0, limit, offset, hasMore: false }); } else { return this.formatStorageContainers(paginatedContainers, environment, { total, limit, offset, hasMore: false }); } return ResponseBuilder.addFooter('No storage containers found'); } catch (error: any) { // Handle REST API errors throw new Error(`Failed to list storage containers: ${error.message}`); } }
- lib/tools/storage-tools.ts:66-80 (schema)Input schema defining StorageArgs interface for tool parameters including credentials, project details, environment, pagination, and self-hosted options.interface StorageArgs { apiKey?: string; apiSecret?: string; projectId?: string; projectName?: string; environment?: string; containerName?: string; permissions?: string; expiryHours?: number; connectionString?: string; isSelfHosted?: boolean; apiUrl?: string; limit?: number; offset?: number; }
- lib/tools/storage-tools.ts:38-41 (schema)Output schema defining structured StorageContainersResult with data (environment, containerCount, containers) and formatted message.interface StorageContainersResult { data: StorageContainersData; message: string; }
- lib/utils/tool-availability-matrix.ts:249-253 (registration)Tool availability registration defining hosting types, category, and description for 'list_storage_containers' in the central tool matrix.'list_storage_containers': { hostingTypes: ['dxp-paas', 'dxp-saas', 'self-hosted'], category: 'Storage & Downloads', description: 'List available storage containers' },