Reserved Instance
Reserved Instance
- class nops_sdk.ri.ri_utilization.RIUtilization
Bases:
object
Get insights about your Reserve Instance Utilization from the nOps API!
Example
>>> from nops_sdk.ri.ri_utilization import RIUtilization >>> ri_util = RIUtilization() We start by querying for an overview to get a general picture of RI utilization as well as available permutations of AWS region and instance family, tenancy and platforms. >>> overview = ri_util.overview() >>> overview [ RIOverviewSchema( instance_region='us-east-1', instance_family='t2', instance_platform='linux', instance_tenancy='default', coverage=0, unused_units=0, accounts=['202279780353'], reserved_units=0, running_units=1.0 ), RIOverviewSchema( instance_region='us-west-2', instance_family='t3', instance_platform='linux', instance_tenancy='default', coverage=0, unused_units=0, accounts=['202279780353'], reserved_units=0, running_units=16 ) ], After taking a glance, we pick the us-east-1/t2/linux/default permutation to delve further into and select it like so: >>> query_params = overview[0].query_params >>> query_params RIQueryParams(region='us-east-1', family='t2', tenancy='default', platform='linux') ------------------------- Now, we use the query params to get a more detailed overview of EC2 instances in that region, family, tenancy and platform. >>> ri_util.ec2_detail(query_params) [ EC2DetailSchema( size_count=2, account=['202279780353'], instance_size='micro' ), EC2DetailSchema( size_count=14, account=['202279780353'], instance_size='medium' ) ]
- ec2_detail(query_params)
Given a permutations of AWS region and instance family, tenancy and platform, get detailed information about matching ec2 instances.
- Parameters
query_params (nops_sdk.ri.query.RIQueryParams) – an instance of
RIQueryParams
specifying a permutation of interest- Returns
list of
EC2DetailSchema
- Return type
- overview()
Get an overview of your Reserve Instance utilization. For each permutation of AWS region and instance family, tenancy and platform, returns the number of running and reserved normalized units.
- Returns
list of
RIOverviewSchema
- Return type
- ri_detail(query_params)
Given a permutations of AWS region and instance family, tenancy and platform, get detailed information about matching reserved instances.
- Parameters
query_params (nops_sdk.ri.query.RIQueryParams) – an instance of
RIQueryParams
specifying a permutation of interest- Returns
list of
RIDetailSchema
- Return type
- timeseries(query_params, period)
Given a permutations of AWS region and instance family, tenancy and platform, get timeseries data.
- Parameters
query_params (nops_sdk.ri.query.RIQueryParams) – an instance of
RIQueryParams
specifying a permutation of interestperiod (Literal['0.5', '1', '7', '30']) –
- Returns
list of
Timeseries
- Return type
Schemas
This module contains schemas - dataclasses that deserialize raw API responses and usually correspond to 1 nOps API endpoint - for the Reserved Instances module.
- class nops_sdk.ri.schemas.EC2DetailSchema(size_count: 'int', account: 'list[str]', instance_size: 'str', normalized_units: 'int')
Bases:
nops_sdk.ri.schemas._BaseSchema
- Parameters
size_count (int) –
account (list[str]) –
instance_size (str) –
normalized_units (int) –
- Return type
None
- __init__(size_count, account, instance_size, normalized_units)
- Parameters
size_count (int) –
account (list[str]) –
instance_size (str) –
normalized_units (int) –
- Return type
None
- account: list[str]
- instance_size: str
- normalized_units: int
- size_count: int
- class nops_sdk.ri.schemas.RIDetailSchema(instance_type: 'str', account: 'str', offering_class: 'str', platform: 'str', terms: 'str', expiration_date: 'str')
Bases:
nops_sdk.ri.schemas._BaseSchema
- Parameters
instance_type (str) –
account (str) –
offering_class (str) –
platform (str) –
terms (str) –
expiration_date (str) –
- Return type
None
- __init__(instance_type, account, offering_class, platform, terms, expiration_date)
- Parameters
instance_type (str) –
account (str) –
offering_class (str) –
platform (str) –
terms (str) –
expiration_date (str) –
- Return type
None
- account: str
- expiration_date: str
- instance_type: str
- offering_class: str
- platform: str
- terms: str
- class nops_sdk.ri.schemas.RIOverviewSchema(instance_region: 'str', instance_family: 'str', instance_platform: 'str', instance_tenancy: 'str', coverage: 'float', unused_units: 'float', accounts: 'Optional[set[str]]', reserved_units: 'Optional[Decimal]', running_units: 'Optional[Decimal]')
Bases:
nops_sdk.ri.schemas._BaseSchema
- Parameters
instance_region (str) –
instance_family (str) –
instance_platform (str) –
instance_tenancy (str) –
coverage (float) –
unused_units (float) –
accounts (Optional[set[str]]) –
reserved_units (Optional[decimal.Decimal]) –
running_units (Optional[decimal.Decimal]) –
- Return type
None
- __init__(instance_region, instance_family, instance_platform, instance_tenancy, coverage, unused_units, accounts, reserved_units, running_units)
- Parameters
instance_region (str) –
instance_family (str) –
instance_platform (str) –
instance_tenancy (str) –
coverage (float) –
unused_units (float) –
accounts (Optional[set[str]]) –
reserved_units (Optional[decimal.Decimal]) –
running_units (Optional[decimal.Decimal]) –
- Return type
None
- accounts: Optional[set[str]]
- coverage: float
- instance_family: str
- instance_platform: str
- instance_region: str
- instance_tenancy: str
- property query_params: nops_sdk.ri.query.RIQueryParams
Query params corresponding to this overview item.
- reserved_units: Optional[decimal.Decimal]
- running_units: Optional[decimal.Decimal]
- unused_units: float
- class nops_sdk.ri.schemas.TimeseriesSchema(formatted_timestamp: 'str', reserved_units: 'float', running_units: 'float')
Bases:
nops_sdk.ri.schemas._BaseSchema
- Parameters
formatted_timestamp (str) –
reserved_units (float) –
running_units (float) –
- Return type
None
- __init__(formatted_timestamp, reserved_units, running_units)
- Parameters
formatted_timestamp (str) –
reserved_units (float) –
running_units (float) –
- Return type
None
- formatted_timestamp: str
- reserved_units: float
- running_units: float