AzureAdConfig

Struct AzureAdConfig 

Source
pub struct AzureAdConfig {
    pub auth_method: String,
    pub tenant_id: Option<String>,
    pub client_id: Option<String>,
    pub client_secret: Option<String>,
    pub subscription_id: Option<String>,
    pub resource_group: Option<String>,
    pub namespace: Option<String>,
}
Expand description

Configuration for Azure Active Directory authentication and resource access.

This struct contains all the necessary information for authenticating with Azure AD and accessing Azure Service Bus resources. It supports multiple authentication methods and can load configuration from both direct values and environment variables.

§Authentication Methods

  • device_code - Interactive device code flow (default for CLI usage)
  • client_secret - Service principal authentication
  • connection_string - Direct connection string authentication

§Examples

use quetty_server::service_bus_manager::AzureAdConfig;

let config = AzureAdConfig {
    auth_method: "device_code".to_string(),
    tenant_id: Some("tenant-id".to_string()),
    client_id: Some("client-id".to_string()),
    subscription_id: Some("subscription-id".to_string()),
    resource_group: Some("resource-group".to_string()),
    namespace: Some("servicebus-namespace".to_string()),
    ..Default::default()
};

Fields§

§auth_method: String

Authentication method: “device_code”, “client_secret”, or “connection_string”

§tenant_id: Option<String>

Azure AD tenant ID

§client_id: Option<String>

Azure AD application (client) ID

§client_secret: Option<String>

Azure AD application client secret (required for client_secret)

§subscription_id: Option<String>

Azure subscription ID for resource discovery

§resource_group: Option<String>

Resource group name containing the Service Bus namespace

§namespace: Option<String>

Service Bus namespace name

Implementations§

Source§

impl AzureAdConfig

Source

pub fn tenant_id(&self) -> Result<&str, ServiceBusError>

Gets the Azure AD tenant ID, returning an error if not configured.

§Returns

The tenant ID as a string reference

§Errors

Returns ServiceBusError::ConfigurationError if the tenant ID is not set

Source

pub fn client_id(&self) -> Result<&str, ServiceBusError>

Gets the Azure AD client ID, returning an error if not configured.

§Returns

The client ID as a string reference

§Errors

Returns ServiceBusError::ConfigurationError if the client ID is not set

Source

pub fn client_secret(&self) -> Result<String, ServiceBusError>

Gets the Azure AD client secret, returning an error if not configured.

Required for client credentials authentication flow.

§Returns

The client secret as a string reference

§Errors

Returns ServiceBusError::ConfigurationError if the client secret is not set

Source

pub fn subscription_id(&self) -> Result<String, ServiceBusError>

Gets the Azure subscription ID from config or environment variables.

Checks the config first, then falls back to the AZURE_AD__SUBSCRIPTION_ID environment variable.

§Returns

The subscription ID as a string

§Errors

Returns ServiceBusError::ConfigurationError if the subscription ID is not found

Source

pub fn resource_group(&self) -> Result<String, ServiceBusError>

Gets the Azure resource group name from config or environment variables.

Checks the config first, then falls back to the AZURE_AD__RESOURCE_GROUP environment variable.

§Returns

The resource group name as a string

§Errors

Returns ServiceBusError::ConfigurationError if the resource group is not found

Source

pub fn namespace(&self) -> Result<String, ServiceBusError>

Gets the Service Bus namespace name from config or environment variables.

Checks the config first, then falls back to the AZURE_AD__NAMESPACE environment variable.

§Returns

The namespace name as a string

§Errors

Returns ServiceBusError::ConfigurationError if the namespace is not found

Source

pub fn has_tenant_id(&self) -> bool

Checks if tenant ID is configured (in config only, not environment).

§Returns

true if tenant ID is set in the configuration

Source

pub fn has_client_id(&self) -> bool

Checks if client ID is configured (in config only, not environment).

§Returns

true if client ID is set in the configuration

Source

pub fn has_client_secret(&self) -> bool

Checks if client secret is configured (in config only, not environment).

§Returns

true if client secret is set in the configuration

Source

pub fn has_subscription_id(&self) -> bool

Checks if subscription ID is available (config or environment).

§Returns

true if subscription ID is available from config or environment variables

Source

pub fn has_resource_group(&self) -> bool

Checks if resource group is available (config or environment).

§Returns

true if resource group is available from config or environment variables

Source

pub fn has_namespace(&self) -> bool

Checks if namespace is available (config or environment).

§Returns

true if namespace is available from config or environment variables

Source

pub async fn get_azure_ad_token( &self, http_client: &Client, ) -> Result<String, Box<dyn Error>>

Obtains an Azure AD access token using the configured authentication method.

This method tries different authentication approaches based on the configured auth method:

  1. For device code flow, attempts UI-integrated auth first
  2. Falls back to regular auth provider for other methods
  3. Returns an error for connection string auth (no Azure AD token available)
§Arguments
  • http_client - HTTP client for making authentication requests
§Returns

An Azure AD access token string

§Errors

Returns an error if:

  • Authentication fails
  • Connection string auth is used (Azure AD tokens not available)
  • Required configuration is missing
Source

pub async fn list_queues_azure_ad( &self, http_client: &Client, ) -> Result<Vec<String>, Box<dyn Error>>

Lists all Service Bus queues in the configured namespace using Azure AD authentication.

§Arguments
  • http_client - HTTP client for making API requests
§Returns

A vector of queue names

§Errors

Returns an error if:

  • Authentication fails
  • Azure Management API request fails
  • Required configuration (subscription, resource group, namespace) is missing
Source

pub async fn list_namespaces_azure_ad( &self, http_client: &Client, ) -> Result<Vec<String>, Box<dyn Error>>

Lists all Service Bus namespaces in the configured resource group using Azure AD authentication.

§Arguments
  • http_client - HTTP client for making API requests
§Returns

A vector of namespace names

§Errors

Returns an error if:

  • Authentication fails
  • Azure Management API request fails
  • Required configuration (subscription, resource group) is missing

Trait Implementations§

Source§

impl Clone for AzureAdConfig

Source§

fn clone(&self) -> AzureAdConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AzureAdConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AzureAdConfig

Source§

fn default() -> AzureAdConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AzureAdConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<D> DeserializeWith<JsonFormat> for D

Source§

fn deserialize_with<'async_trait>( body: ResponseBody, ) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait>>
where D: 'async_trait,

Source§

impl<D> DeserializeWith<JsonFormat> for D

Source§

fn deserialize_with<'async_trait>( body: ResponseBody, ) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait>>
where D: 'async_trait,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

impl<T> SendBound for T
where T: Send,