Profile Management¶
Manage multiple authentication profiles for different tenants and environments.
Listing Profiles¶
import { getProfileManager } from '@robinmordasiewicz/f5xc-auth';
const profileManager = getProfileManager();
// Get all profile names
const profiles = await profileManager.list();
console.log('Available profiles:', profiles);
// Output: ['production', 'staging', 'development']
Getting Active Profile¶
// Get currently active profile
const activeProfile = await profileManager.getActiveProfile();
console.log('Active profile:', activeProfile?.name);
// Check if a profile is active
const isProduction = await profileManager.isActive('production');
console.log('Is production active?', isProduction);
Loading Profile Data¶
// Load specific profile
const 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¶
// Switch to different profile
await profileManager.setActive('staging');
console.log('Switched to staging profile');
// Reinitialize credential manager to use new profile
const credentialManager = new CredentialManager();
await credentialManager.initialize();
Deleting Profiles¶
// Delete a specific profile
await profileManager.delete('old-profile');
console.log('Profile deleted');
// Delete the active profile
await profileManager.deleteActive();
console.log('Active profile deleted');
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¶
- Authentication - Configure authentication methods
- ProfileManager API - Complete API reference
- Examples - Profile switching example