Skip to main content

ConfigManager

Struct ConfigManager 

Source
pub struct ConfigManager<F: FileSystem> { /* private fields */ }

Implementations§

Source§

impl ConfigManager<OsFileSystem>

Source

pub fn new() -> Result<Self, Error>

Creates a new ConfigManager with the default filesystem and config directory.

§Errors

Returns an error if the home directory cannot be determined.

Source§

impl<F: FileSystem> ConfigManager<F>

Source

pub const fn with_fs(fs: F, config_dir: PathBuf) -> Self

Source

pub fn config_dir(&self) -> &Path

Get the configuration directory path

Source

pub fn skipped_endpoints_to_warnings( skipped_endpoints: &[SkippedEndpoint], ) -> Vec<ValidationWarning>

Convert skipped endpoints to validation warnings for display

Source

pub fn get_strict_preference(&self, api_name: &str) -> Result<bool, Error>

Get the strict mode preference for an API

§Errors

Returns an error if the global config cannot be loaded

Source

pub fn format_validation_warnings( warnings: &[ValidationWarning], total_operations: Option<usize>, indent: &str, ) -> Vec<String>

Display validation warnings with custom prefix

Source

pub fn display_validation_warnings( warnings: &[ValidationWarning], total_operations: Option<usize>, )

Display validation warnings to stderr

Source

pub fn add_spec( &self, name: &str, file_path: &Path, force: bool, strict: bool, ) -> Result<(), Error>

Adds a new OpenAPI specification to the configuration from a local file.

§Errors

Returns an error if:

  • The spec already exists and force is false
  • File I/O operations fail
  • The OpenAPI spec is invalid YAML
  • The spec contains unsupported features
§Panics

Panics if the spec path parent directory is None (should not happen in normal usage).

Source

pub async fn add_spec_from_url( &self, name: &str, url: &str, force: bool, strict: bool, ) -> Result<(), Error>

Adds a new OpenAPI specification to the configuration from a URL.

§Errors

Returns an error if:

  • The spec already exists and force is false
  • Network requests fail
  • The OpenAPI spec is invalid YAML
  • The spec contains unsupported features
  • Response size exceeds 10MB limit
  • Request times out (30 seconds)
§Panics

Panics if the spec path parent directory is None (should not happen in normal usage).

Source

pub async fn add_spec_auto( &self, name: &str, file_or_url: &str, force: bool, strict: bool, ) -> Result<(), Error>

Adds a new OpenAPI specification from either a file path or URL.

This is a convenience method that automatically detects whether the input is a URL or file path and calls the appropriate method.

§Errors

Returns an error if:

  • The spec already exists and force is false
  • File I/O operations fail (for local files)
  • Network requests fail (for URLs)
  • The OpenAPI spec is invalid YAML
  • The spec contains unsupported features
  • Response size exceeds 10MB limit (for URLs)
  • Request times out (for URLs)
Source

pub fn list_specs(&self) -> Result<Vec<String>, Error>

Lists all registered API contexts.

§Errors

Returns an error if the specs directory cannot be read.

Source

pub fn remove_spec(&self, name: &str) -> Result<(), Error>

Removes an API specification from the configuration.

§Errors

Returns an error if the spec does not exist or cannot be removed.

Source

pub fn edit_spec(&self, name: &str) -> Result<(), Error>

Opens an API specification in the default editor.

§Errors

Returns an error if:

  • The spec does not exist.
  • The $EDITOR environment variable is not set.
  • The editor command fails to execute.
Source

pub fn load_global_config(&self) -> Result<GlobalConfig, Error>

Loads the global configuration from config.toml.

§Errors

Returns an error if the configuration file exists but cannot be read or parsed.

Source

pub fn save_global_config(&self, config: &GlobalConfig) -> Result<(), Error>

Saves the global configuration to config.toml.

§Errors

Returns an error if the configuration cannot be serialized or written.

Source

pub fn set_setting( &self, key: &SettingKey, value: &SettingValue, ) -> Result<(), Error>

Sets a global configuration setting value.

Uses toml_edit to preserve comments and formatting in the config file.

§Arguments
  • key - The setting key to modify
  • value - The value to set
§Errors

Returns an error if the config file cannot be read, parsed, or written.

Source

pub fn get_setting(&self, key: &SettingKey) -> Result<SettingValue, Error>

Gets a global configuration setting value.

§Arguments
  • key - The setting key to retrieve
§Errors

Returns an error if the config file cannot be read or parsed.

Source

pub fn list_settings(&self) -> Result<Vec<SettingInfo>, Error>

Lists all available configuration settings with their current values.

§Errors

Returns an error if the config file cannot be read or parsed.

Source

pub fn set_url( &self, api_name: &str, url: &str, environment: Option<&str>, ) -> Result<(), Error>

Sets the base URL for an API specification.

§Arguments
  • api_name - The name of the API specification
  • url - The base URL to set
  • environment - Optional environment name for environment-specific URLs
§Errors

Returns an error if the spec doesn’t exist or config cannot be saved.

Source

pub fn get_url( &self, api_name: &str, ) -> Result<(Option<String>, HashMap<String, String>, String), Error>

Gets the base URL configuration for an API specification.

§Arguments
  • api_name - The name of the API specification
§Returns

A tuple of (base_url_override, environment_urls, resolved_url)

§Errors

Returns an error if the spec doesn’t exist.

Source

pub fn list_urls( &self, ) -> Result<HashMap<String, (Option<String>, HashMap<String, String>)>, Error>

Lists all configured base URLs across all API specifications.

§Returns

A map of API names to their URL configurations

§Errors

Returns an error if the config cannot be loaded.

Source

pub fn set_secret( &self, api_name: &str, scheme_name: &str, env_var_name: &str, ) -> Result<(), Error>

Sets a secret configuration for a specific security scheme

§Arguments
  • api_name - The name of the API specification
  • scheme_name - The name of the security scheme
  • env_var_name - The environment variable name containing the secret
§Errors

Returns an error if the spec doesn’t exist or config cannot be saved.

Source

pub fn list_secrets( &self, api_name: &str, ) -> Result<HashMap<String, ApertureSecret>, Error>

Lists configured secrets for an API specification

§Arguments
  • api_name - The name of the API specification
§Returns

A map of scheme names to their secret configurations

§Errors

Returns an error if the spec doesn’t exist.

Source

pub fn get_secret( &self, api_name: &str, scheme_name: &str, ) -> Result<Option<ApertureSecret>, Error>

Gets a secret configuration for a specific security scheme

§Arguments
  • api_name - The name of the API specification
  • scheme_name - The name of the security scheme
§Returns

The secret configuration if found

§Errors

Returns an error if the spec doesn’t exist.

Source

pub fn remove_secret( &self, api_name: &str, scheme_name: &str, ) -> Result<(), Error>

Removes a specific secret configuration for a security scheme

§Arguments
  • api_name - The name of the API specification
  • scheme_name - The name of the security scheme to remove
§Errors

Returns an error if the spec doesn’t exist or if the scheme is not configured

Source

pub fn clear_secrets(&self, api_name: &str) -> Result<(), Error>

Removes all secret configurations for an API specification

§Arguments
  • api_name - The name of the API specification
§Errors

Returns an error if the spec doesn’t exist

Source

pub fn set_secret_interactive(&self, api_name: &str) -> Result<(), Error>

Configure secrets interactively for an API specification

Loads the cached spec to discover available security schemes and presents an interactive menu for configuration.

§Arguments
  • api_name - The name of the API specification
§Errors

Returns an error if:

  • The spec doesn’t exist
  • Cannot load cached spec
  • User interaction fails
  • Cannot save configuration
§Panics

Panics if the selected scheme is not found in the cached spec (this should never happen due to menu validation)

Auto Trait Implementations§

§

impl<F> Freeze for ConfigManager<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for ConfigManager<F>
where F: RefUnwindSafe,

§

impl<F> Send for ConfigManager<F>
where F: Send,

§

impl<F> Sync for ConfigManager<F>
where F: Sync,

§

impl<F> Unpin for ConfigManager<F>
where F: Unpin,

§

impl<F> UnwindSafe for ConfigManager<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,