@apistudio/apim-cli
Version:
CLI for API Management Products
63 lines (54 loc) • 2.08 kB
JavaScript
// Test using the inventory through the CommonRuntimeSDK
import { RuntimeSDK } from './dist/index.js';
console.log('=== Testing inventory through CommonRuntimeSDK ===');
// Create a new instance of RuntimeSDK
const sdk = new RuntimeSDK();
// Check if the inventory is available
console.log('SDK inventory available:', sdk.inventory ? 'Yes' : 'No');
// Test the getSchema method
console.log('\nTesting getSchema method:');
try {
const apiSchema = sdk.inventory.getSchema('api');
console.log('API schema found:', apiSchema ? 'Yes' : 'No');
if (apiSchema) {
console.log('Schema sample:', typeof apiSchema === 'string'
? apiSchema.substring(0, 50) + '...'
: JSON.stringify(apiSchema).substring(0, 50) + '...');
}
} catch (error) {
console.error('Error getting API schema:', error);
}
// Test the getPolicySequenceType method
console.log('\nTesting getPolicySequenceType method:');
try {
const sequenceTypes = sdk.inventory.getPolicySequenceType();
console.log('Sequence types found:', sequenceTypes ? 'Yes' : 'No');
if (sequenceTypes) {
console.log('Sequence types:', sequenceTypes.sequenceTypes);
}
} catch (error) {
console.error('Error getting policy sequence types:', error);
}
// Test the getStagedPolicies method
console.log('\nTesting getStagedPolicies method:');
try {
const stagedPolicies = sdk.inventory.getStagedPolicies();
console.log('Staged policies found:', stagedPolicies ? 'Yes' : 'No');
if (stagedPolicies) {
console.log('Staged policy stages:', Object.keys(stagedPolicies));
}
} catch (error) {
console.error('Error getting staged policies:', error);
}
// Test the getFreeFlowPolicies method
console.log('\nTesting getFreeFlowPolicies method:');
try {
const freeFlowPolicies = sdk.inventory.getFreeFlowPolicies();
console.log('Free flow policies found:', freeFlowPolicies ? 'Yes' : 'No');
if (freeFlowPolicies) {
console.log('Free flow policy groups:', Object.keys(freeFlowPolicies));
}
} catch (error) {
console.error('Error getting free flow policies:', error);
}
// Made with Bob