Fabric Capacity Hook

Hooks for managing Microsoft Fabric capacities via the Azure Resource Manager API.

class scamander.providers.fabric.hooks.fabric_capacity_hook.FabricCapacityAsyncHook(*, fabric_capacity_conn_id: str = 'fabric_capacity_default')

Bases: FabricCapacityHook

Interact with Microsoft Fabric Capacities asynchronously.

Parameters:

fabric_capacity_conn_id – Airflow Connection ID that contains the connection

async async_get_capacity(subscription_id: str, resource_group: str, capacity_name: str) → dict

Get details of the capacity and cache them on self.capacity_info.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

The capacity resource payload from the API.

async async_get_headers() → dict[str, str]

Form of auth headers based on OAuth token.

async async_is_capacity_active(subscription_id: str, resource_group: str, capacity_name: str) → bool

Fetch the capacity and check whether its state is Active.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

True if the capacity’s provisioning state is Active.

async async_resume_capacity(subscription_id: str, resource_group: str, capacity_name: str) → dict

Resume the capacity if it is suspended. No-op if it is already active.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

The response payload from the resume request.

async async_suspend_capacity(subscription_id: str, resource_group: str, capacity_name: str) → dict

Suspend the capacity if it is active. No-op if it is already suspended.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

The response payload from the suspend request.

async async_update_capacity_sku(subscription_id: str, resource_group: str, capacity_name: str, sku_name: str, sku_tier: str = 'Fabric') → dict

Scale the capacity by PATCHing the resource with a new sku.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

  • sku_name – The target sku name (e.g. F8, F64).

  • sku_tier – The target sku tier.

Returns:

The response payload from the PATCH request.

class scamander.providers.fabric.hooks.fabric_capacity_hook.FabricCapacityHook(*, fabric_capacity_conn_id: str = 'fabric_capacity_default', max_retries: int = 5, retry_delay: int = 1)

Bases: BaseHook

Hook to interact with Microsoft Fabric capacities via the Azure Resource Manager API. Uses the same pattern as the existing FabricHook: tenant/client/secret from the Airflow connection. Connection type: ‘fabric_capacity’

get_capacity(subscription_id: str, resource_group: str, capacity_name: str) → dict

Get details of the capacity and cache them on self.capacity_info.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

The capacity resource payload from the API.

get_headers() → dict[str, str]

Form of auth headers based on ARM token.

Returns:

Headers with the authorization token.

is_capacity_active(subscription_id: str, resource_group: str, capacity_name: str) → bool

Fetch the capacity and check whether its state is Active.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

Returns:

True if the capacity’s provisioning state is Active.

list_capacities_by_subscription(subscription_id: str) → dict

List all Fabric capacities in a subscription.

Parameters:

subscription_id – The Azure subscription Id.

Returns:

The list-capacities response payload from the API.

resume_capacity(subscription_id: str, resource_group: str, capacity_name: str, wait: bool = True) → dict

Resume the capacity if it is suspended. No-op if it is already active.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

  • wait – When True, poll the ARM long-running operation until it completes.

Returns:

The final capacity resource payload from the API.

suspend_capacity(subscription_id: str, resource_group: str, capacity_name: str, wait: bool = True) → dict

Suspend the capacity if it is active. No-op if it is already suspended.

Parameters:
  • subscription_id – The Azure subscription Id.

  • resource_group – The resource group in which the capacity is located.

  • capacity_name – The name of the capacity.

  • wait – When True, poll the ARM long-running operation until it completes.

Returns:

The final capacity resource payload from the API.

update_capacity_sku(subscription_id: str, resource_group: str, capacity_name: str, sku_name: str, sku_tier: str = 'Fabric', wait: bool = True) → dict

Scale capacity by PATCHing the capacity resource with a new sku. Example sku_name: ‘F8’, ‘F64’, etc.