Profile Management
Manage multiple authentication profiles for different tenants and environments.
Listing Profiles
Section titled “Listing Profiles”import { getProfileManager } from '@robinmordasiewicz/f5xc-auth';
const profileManager = getProfileManager();
// Get all profile namesconst profiles = await profileManager.list();console.log('Available profiles:', profiles);// Output: ['production', 'staging', 'development']Getting Active Profile
Section titled “Getting Active Profile”// Get currently active profileconst activeProfile = await profileManager.getActiveProfile();console.log('Active profile:', activeProfile?.name);
// Check if a profile is activeconst isProduction = await profileManager.isActive('production');console.log('Is production active?', isProduction);Loading Profile Data
Section titled “Loading Profile Data”// Load specific profileconst profile = await profileManager.load('production');if (profile) { console.log('Profile:', profile.name); console.log('API URL:', profile.apiUrl); console.log('Namespace:', profile.defaultNamespace);}Switching Profiles
Section titled “Switching Profiles”// Switch to different profileawait profileManager.setActive('staging');console.log('Switched to staging profile');
// Reinitialize credential manager to use new profileconst credentialManager = new CredentialManager();await credentialManager.initialize();Deleting Profiles
Section titled “Deleting Profiles”// Delete a specific profileawait profileManager.delete('old-profile');console.log('Profile deleted');
// Delete the active profileawait profileManager.deleteActive();console.log('Active profile deleted');Complete Profile Management Example
Section titled “Complete Profile Management Example”import { getProfileManager, CredentialManager } from '@robinmordasiewicz/f5xc-auth';
async function manageProfiles() { const profileManager = getProfileManager();
// Create production profile await profileManager.save({ name: 'production', apiUrl: 'https://prod.console.ves.volterra.io', apiToken: 'prod-token', defaultNamespace: 'prod-namespace' });
// Create staging profile await profileManager.save({ name: 'staging', apiUrl: 'https://staging.console.ves.volterra.io', apiToken: 'staging-token', defaultNamespace: 'staging-namespace' });
// List all profiles const profiles = await profileManager.list(); console.log('Available profiles:', profiles);
// Switch to production await profileManager.setActive('production');
// Use the active profile const credentialManager = new CredentialManager(); await credentialManager.initialize(); console.log('Using profile:', credentialManager.getTenant());}
manageProfiles().catch(console.error);See Also
Section titled “See Also”- Authentication - Configure authentication methods
- ProfileManager API - Complete API reference
- Examples - Profile switching example