ansible_aap_api_client package

Subpackages

Submodules

ansible_aap_api_client.aap_client module

APP Client

class ansible_aap_api_client.aap_client.AAPClient(base_url: str, username: str, password: str, ssl_verify: bool | str = True)[source]

Bases: _CommonClientNeeds

APP Client

Parameters:
  • base_url (str) – Base URL for APP Client example: https://example.com

  • username (str) – APP Username

  • password (str) – APP Password

  • ssl_verify – Verify SSL certificates True, False or pass the path to the certificate file

add_group_to_inventory(inventory_id: int, group: InventoryGroupRequestSchema) dict[source]

Add group to inventory

Parameters:
  • inventory_id – The inventory id

  • group – The group to add

Returns:

Response

Raises:

TypeError – If group is not an InventoryGroupRequestSchema

add_host_to_group(group_id: int, host: InventoryHostRequestSchema) dict[source]

Add host to group

Parameters:
  • group_id – The group id

  • host – The host to add

Returns:

Response

Raises:
  • TypeError – If host is not of type InventoryHostRequestSchema

  • TypeError – If group_id is not of type int

add_host_to_inventory(inventory_id: int, host: InventoryHostRequestSchema) dict[source]

Add host to inventory

Parameters:
  • inventory_id – The inventory id

  • host – The host to add

Returns:

Response

Raises:

TypeError – If host is not an InventoryHostRequestSchema

create_inventory(inventory: InventoryRequestSchema) dict[source]

Create inventory

Parameters:

inventory – The inventory to create

Returns:

Response

Raises:

TypeError – If inventory is not a InventoryRequestSchema

create_organization(organization: OrganizationRequestSchema)[source]

Create an organization

Parameters:

organization – The organization object

Returns:

The created organization

Raises:

TypeError – If organization is not of type OrganizationRequestSchema

delete_group(group_id: int) int | None[source]

Delete group

Parameters:

group_id – The group id

Returns:

Response Status Code

Raises:

TypeError – If inventory_id is not of type int

delete_host(host_id: int) None | int[source]

Delete a host

Parameters:

host_id – The id of the host

Returns:

The id of the deleted host

Raises:

TypeError – If host_id is not of type int

delete_inventory(inventory_id: int) None | int[source]

Delete inventory

Parameters:

inventory_id – The inventory id

Returns:

Response Status Code

Raises:

TypeError – If inventory_id is not of type int

delete_organization(organization_id: int) None | int[source]

Delete organization

Parameters:

organization_id – The id of the organization

Returns:

Response Status Code

Raises:

TypeError – If organization_id is not of type int

get_all_groups() dict[source]

Get all groups

Returns:

Response

get_all_hosts() dict[source]

Get all hosts

Returns:

Response

get_all_inventories() dict[source]

Get all inventories

Returns:

Response

get_all_job_templates() dict[source]

Get all job templates

Returns:

Response

get_all_jobs() dict[source]

Get all jobs

Returns:

Response

get_all_organizations() dict[source]

Get all organizations

Returns:

Response

get_all_projects() dict[source]

Get all projects

Returns:

The created organization

get_group(name: str) dict[source]

Get all instances of a group by name

Parameters:

name – The name of the group

Returns:

Response

Raises:

TypeError – If name is not of type str

get_group_id(name: str) int[source]

Get the id of a group if one exists

Parameters:

name – The name of the group

Returns:

The id of the group

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

get_host(name: str) dict[source]

Get all instances of a host by name

Parameters:

name – The name of the host

Returns:

Response

Raises:

TypeError – If name is not of type str

get_host_id(name: str) int[source]

Get the id of a host if one exists

Parameters:

name – The name of the host

Returns:

The id of the host

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

get_inventory(name: str) dict[source]

Get all instances of an inventory by name

Parameters:

name – The inventory name

Returns:

Response

Raises:

TypeError – If name is not of type str

get_inventory_id(name: str) int[source]

Get the id of an inventory if one exists

Parameters:

name – The name of the inventory

Returns:

The id of the inventory

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

get_job(job_id: int) dict[source]

Get a job by id

Parameters:

job_id – The ID of the job

Returns:

Response

Raises:

TypeError – If job_id is not of type int

get_job_status(job_id: int) str[source]

Get the status of a job by id

Parameters:

job_id – The ID of the job

Returns:

The status of the job

Raises:

TypeError – If job_id is not of type int

get_job_stdout(job_id: int, output_format: Literal['txt', 'json', 'html'] = 'txt') None | str[source]

Get the stdout of a job by id, this is the ansible run log

Parameters:
  • job_id – The ID of the job

  • output_format – The format of the output default: txt

Returns:

The stdout of the job

Raises:

TypeError – If job_id is not of type int

get_job_template(name: str) dict[source]

Get all instances of a job template by name

Parameters:

name – The name of the job template

Returns:

Response

Raises:

TypeError – If name is not of type str

get_job_template_id(name: str) int[source]

Get the id of a job template if one exists

Parameters:

name – The name of the job template

Returns:

The id of the job template

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

get_organization(name: str) dict[source]

Get all instances of an organization by name

Parameters:

name – The name of the organization

Returns:

Response

Raises:

TypeError – If name is not of type str

get_organization_data(name: str, data_type: OrganizationDataEnum | str) dict[source]

Get the data of an organization by organization name and data type

Parameters:
  • name – The name of the organization

  • data_type – The type of data to retrieve

Returns:

The data of the organization

Raises:
  • TypeError – If name is not of type str

  • TypeError – If data_type is not of type OrganizationDataEnum or str

get_organization_id(name: str) int[source]

Get the id of an organization if one exists

Parameters:

name – The name of the organization

Returns:

The id of the organization

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

get_project(name: str) dict[source]

Get a project by name

Parameters:

name – The name of the project

Returns:

Response

Raises:

TypeError – If name is not of type str

get_project_id(name: str) int[source]

Get the id of a project if one exists

Parameters:

name – The name of the project

Returns:

The id of the project

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

launch_job_template(job_template_id: int, **kwargs) dict[source]

Launch a job template

Parameters:
  • job_template_id – The id of the job template

  • kwargs – The key word args to launch the job with, example: inventory=1, extra_vars={“key”: “value”}

Returns:

Response

Raises:

TypeError – If job_template_id is not of type int

sync_project(name: str) dict[source]

Sync a project by name

Parameters:

name – The name of the project

Returns:

Response

Raises:
  • TypeError – If name is not of type str

  • ValueError – If zero instances is found

update_group(group_id: int, group: InventoryGroupRequestSchema) dict[source]

Update group

Parameters:
  • group_id – The group id

  • group – The group data

Returns:

Response

Raises:
  • TypeError – If group is not a InventoryGroupRequestSchema

  • TypeError – If group_id is not of type int

update_host(host_id: int, host: InventoryHostRequestSchema) dict[source]

Update a host

Parameters:
  • host_id – The id of the host

  • host – The inventory host object

Returns:

The updated host

Raises:
  • TypeError – If host_id is not of type int

  • TypeError – If host is not of type InventoryHostRequestSchema

update_inventory(inventory_id: int, inventory: InventoryRequestSchema) dict[source]

Update inventory

Parameters:
  • inventory_id – The inventory id

  • inventory – The inventory data

Returns:

Response

Raises:
  • TypeError – If inventory is not a InventoryRequestSchema

  • TypeError – If inventory_id is not of type int

update_organization(organization_id: int, organization: OrganizationRequestSchema) dict[source]

Update a organization

Parameters:
  • organization_id – The id of the OrganizationRequestSchema

  • organization – The organization object

Returns:

The updated host

Raises:
  • TypeError – If organization_id is not of type int

  • TypeError – If organization is not of type OrganizationRequestSchema

ansible_aap_api_client.ansible_aap_api_client_cli module

CLI for ansible_aap_api_client

ansible_aap_api_client.ansible_aap_api_client_cli.cli() None[source]

Function to run the command line :rtype: None :returns: Nothing it is the CLI

ansible_aap_api_client.ansible_aap_api_client_cli.cli_argument_parser() ArgumentParser[source]

Function to create the argument parser

Return type:

ArgumentParser

Returns:

The argument parser

ansible_aap_api_client.async_aap_client module

Async APP Client

class ansible_aap_api_client.async_aap_client.AsyncAAPClient(base_url: str, username: str, password: str, ssl_verify: bool | str = True)[source]

Bases: _CommonClientNeeds

Asynchronous APP Client

Parameters:
  • base_url (str) – Base URL for APP Client example: https://example.com

  • username (str) – APP Username

  • password (str) – APP Password

  • ssl_verify – Verify SSL certificates True, False or pass the path to the certificate file

async add_group_to_inventory(inventory_id: int, group: InventoryGroupRequestSchema) dict[source]

Add group to inventory

Parameters:
  • inventory_id – The inventory id

  • group – The group to add

Returns:

Response

Raises:

TypeError – If group is not an InventoryGroupRequestSchema

async add_host_to_group(group_id: int, host: InventoryHostRequestSchema) dict[source]

Add host to group

Parameters:
  • group_id – The group id

  • host – The host to add

Returns:

Response

Raises:
  • TypeError – If host is not of type InventoryHostRequestSchema

  • TypeError – If group_id is not of type int

async add_host_to_inventory(inventory_id: int, host: InventoryHostRequestSchema) dict[source]

Add host to inventory

Parameters:
  • inventory_id – The inventory id

  • host – The host to add

Returns:

Response

Raises:

TypeError – If host is not an InventoryHostRequestSchema

async create_inventory(inventory: InventoryRequestSchema) dict[source]

Create inventory

Parameters:

inventory – The inventory to create

Returns:

Response

Raises:

TypeError – If inventory is not a InventoryRequestSchema

async create_organization(organization: OrganizationRequestSchema) dict[source]

Create an organization

Parameters:

organization – The organization object

Returns:

The created organization

Raises:

TypeError – If organization is not of type OrganizationRequestSchema

async delete_group(group_id: int) int | None[source]

Delete group

Parameters:

group_id – The group id

Returns:

Response Status Code

Raises:

TypeError – If inventory_id is not of type int

async delete_host(host_id: int) None | int[source]

Delete a host

Parameters:

host_id – The id of the host

Returns:

The id of the deleted host

Raises:

TypeError – If host_id is not of type int

async delete_inventory(inventory_id: int) None | int[source]

Delete inventory

Parameters:

inventory_id – The inventory id

Returns:

Response Status Code

Raises:

TypeError – If inventory_id is not of type int

async delete_organization(organization_id: int) None | int[source]

Delete organization

Parameters:

organization_id – The id of the organization

Returns:

Response Status Code

Raises:

TypeError – If organization_id is not of type int

async get_all_groups() dict[source]

Get all groups

Returns:

Response

async get_all_hosts() dict[source]

Get all hosts

Returns:

Response

async get_all_inventories() dict[source]

Get all inventories

Returns:

Response

async get_all_job_templates() dict[source]

Get all job templates

Returns:

Response

async get_all_jobs() dict[source]

Get all jobs

Returns:

Response

async get_all_organizations() dict[source]

Get all organizations

Returns:

Response

async get_all_projects() dict[source]

Get all projects

Returns:

The created organization

async get_group(name: str) dict[source]

Get all instances of a group by name

Parameters:

name – The name of the group

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_group_id(name: str) int[source]

Get the id of a group if one exists

Parameters:

name – The name of the group

Returns:

The id of the group

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async get_host(name: str) dict[source]

Get all instances of a host by name

Parameters:

name – The name of the host

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_host_id(name: str) int[source]

Get the id of a host if one exists

Parameters:

name – The name of the host

Returns:

The id of the host

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async get_inventory(name: str) dict[source]

Get all instances of an inventory by name

Parameters:

name – The inventory name

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_inventory_id(name: str) int[source]

Get the id of an inventory if one exists

Parameters:

name – The name of the inventory

Returns:

The id of the inventory

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async get_job(job_id: int) dict[source]

Get a job by id

Parameters:

job_id – The ID of the job

Returns:

Response

Raises:

TypeError – If job_id is not of type int

async get_job_status(job_id: int) str[source]

Get the status of a job by id

Parameters:

job_id – The ID of the job

Returns:

The status of the job

Raises:

TypeError – If job_id is not of type int

async get_job_stdout(job_id: int, output_format: Literal['txt', 'json', 'html'] = 'txt') None | str[source]

Get the stdout of a job by id, this is the ansible run log

Parameters:
  • job_id – The ID of the job

  • output_format – The format of the output default: txt

Returns:

The stdout of the job

Raises:

TypeError – If job_id is not of type int

async get_job_template(name: str) dict[source]

Get all instances of a job template by name

Parameters:

name – The name of the job template

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_job_template_id(name: str) int[source]

Get the id of a job template if one exists

Parameters:

name – The name of the job template

Returns:

The id of the job template

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async get_organization(name: str) dict[source]

Get an organization by name

Parameters:

name – The name of the organization

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_organization_data(name: str, data_type: OrganizationDataEnum | str) dict[source]

Get the data of an organization by organization name and data type

Parameters:
  • name – The name of the organization

  • data_type – The type of data to retrieve

Returns:

The data of the organization

Raises:
  • TypeError – If name is not of type str

  • TypeError – If data_type is not of type OrganizationDataEnum or str

async get_organization_id(name: str) int[source]

Get the id of an organization if one exists

Parameters:

name – The name of the organization

Returns:

The id of the organization

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async get_project(name: str) dict[source]

Get a project by name

Parameters:

name – The name of the project

Returns:

Response

Raises:

TypeError – If name is not of type str

async get_project_id(name: str) int[source]

Get the id of a project if one exists

Parameters:

name – The name of the project

Returns:

The id of the project

Raises:
  • ValueError – If zero or more than one instance is found

  • TypeError – If name is not of type str

async launch_job_template(job_template_id: int, **kwargs) dict[source]

Launch a job template

Parameters:
  • job_template_id – The id of the job template

  • kwargs – The key word args to launch the job with, example: inventory=1, extra_vars={“key”: “value”}

Returns:

Response

Raises:

TypeError – If job_template_id is not of type int

async sync_project(name: str) dict[source]

Sync a project by name

Parameters:

name – The name of the project

Returns:

Response

Raises:
  • TypeError – If name is not of type str

  • ValueError – If zero instances is found

async update_group(group_id: int, group: InventoryGroupRequestSchema) dict[source]

Update group

Parameters:
  • group_id – The group id

  • group – The group data

Returns:

Response

Raises:
  • TypeError – If group is not a InventoryGroupRequestSchema

  • TypeError – If group_id is not of type int

async update_host(host_id: int, host: InventoryHostRequestSchema) dict[source]

Update a host

Parameters:
  • host_id – The id of the host

  • host – The inventory host object

Returns:

The updated host

Raises:
  • TypeError – If host_id is not of type int

  • TypeError – If host is not of type InventoryHostRequestSchema

async update_inventory(inventory_id: int, inventory: InventoryRequestSchema) dict[source]

Update inventory

Parameters:
  • inventory_id – The inventory id

  • inventory – The inventory data

Returns:

Response

Raises:
  • TypeError – If inventory is not a InventoryRequestSchema

  • TypeError – If inventory_id is not of type int

async update_organization(organization_id: int, organization: OrganizationRequestSchema) dict[source]

Update a organization

Parameters:
  • organization_id – The id of the OrganizationRequestSchema

  • organization – The organization object

Returns:

The updated host

Raises:
  • TypeError – If organization_id is not of type int

  • TypeError – If organization is not of type OrganizationRequestSchema

ansible_aap_api_client.async_inventory_management module

Async AAP API client for inventory management

class ansible_aap_api_client.async_inventory_management.AsyncInventoryBuilder(base_url: str, username: str, password: str, ssl_verify: bool | str, inventory: InventoryRequestSchema)[source]

Bases: AsyncRunable, AsyncAAPClient

Inventory builder class, this builds an inventory with groups and hosts

Parameters:
  • base_url – The base url to use

  • username – The username to use

  • password – The password to use

  • ssl_verify – The SSL verification True or False or a path to a certificate

  • inventory – The inventory request schema to use

Raises:

TypeError – If inventory is not an instance of InventoryRequestSchema

EOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'eos'}
IOSXR_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'iosxr'}
IOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'ios'}
NXOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'nxos'}
add_custom_group_to_inventory(group: InventoryGroupRequestSchema) None[source]

Add custom group to inventory

Parameters:

group – The group to add

Returns:

Adds the custom group to the inventory

Raises:

TypeError – If group is not an instance of InventoryGroupRequestSchema

add_custom_groups_to_inventory(groups: List[InventoryGroupRequestSchema]) None[source]

Add custom group to inventory

Parameters:

groups – The groups to add

Returns:

Adds the custom groups to the inventory

Raises:

TypeError – If groups is not a list of InventoryGroupRequestSchema

add_eos_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add EOS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_eos_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple EOS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_host_to_custom_group_to_inventory(group_name: str, host: InventoryHostRequestSchema) None[source]

Add host to custom group to inventory

Parameters:
  • group_name – The group name to add the host to

  • host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If group_name is not a string or host is not an instance of InventoryHostRequestSchema

add_hosts_to_custom_group_to_inventory(group_name: str, hosts: List[InventoryHostRequestSchema]) None[source]

Add hosts to custom group to inventory

Parameters:
  • group_name – The group name to add the hosts to

  • hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If group_name is not a string or hosts is not a list of InventoryHostRequestSchema

add_ios_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add IOS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_ios_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple IOS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_iosxr_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add IOS-XR host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_iosxr_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple IOS-XR hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_nxos_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add NX-OS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_nxos_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple NX-OS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

async run() None[source]

Run the inventory builder

Return type:

None

Returns:

Runs the inventory builder

ansible_aap_api_client.async_job_management module

Async AAP Job Management

class ansible_aap_api_client.async_job_management.AsyncJobManagement(base_url: str, username: str, password: str, ssl_verify: bool | str, job_template_name: str, inventory_name: str)[source]

Bases: AsyncRunable, AsyncAAPClient

Job management class, to run a job template against an inventory

Parameters:
  • base_url – The base url to use

  • username – The username to use

  • password – The password to use

  • ssl_verify – The SSL verification True or False or a path to a certificate

  • job_template_name – The name of the job template

  • inventory_name – The name of the inventory

Raises:
  • TypeError – If job_template_name is not of type str

  • TypeError – If inventory_name is not of type str

async poll_completion(print_status: bool | None = False, **kwargs) JobManagementRunStatus[source]

Run the job and poll the completion of a job

Parameters:
  • print_status – Print the status of the job

  • kwargs – The keyword arguments to pass to the launch_job_template method

Returns:

The completed status of the job

Raises:

TypeError – If print_status is not of type bool

async run(**kwargs) None[source]

Run the job management

Parameters:

kwargs – The keyword arguments to pass to the launch_job_template method

Returns:

Runs the inventory builder

ansible_aap_api_client.common_client_needs module

Common needs for integrations

ansible_aap_api_client.enumerations module

Enumerations

class ansible_aap_api_client.enumerations.OrganizationDataEnum(*values)[source]

Bases: str, Enum

Enumeration for Organization Data

INVENTORIES = 'inventories'
JOB_TEMPLATES = 'job_templates'
PROJECTS = 'projects'

ansible_aap_api_client.inventory_management module

AAP API client for inventory management

class ansible_aap_api_client.inventory_management.InventoryBuilder(base_url: str, username: str, password: str, ssl_verify: bool | str, inventory: InventoryRequestSchema)[source]

Bases: Runable, AAPClient

Inventory builder class, this builds an inventory with groups and hosts

Parameters:
  • base_url – The base url to use

  • username – The username to use

  • password – The password to use

  • ssl_verify – The SSL verification True or False or a path to a certificate

  • inventory – The inventory request schema to use

Raises:

TypeError – If inventory is not an instance of InventoryRequestSchema

EOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'eos'}
IOSXR_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'iosxr'}
IOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'ios'}
NXOS_GROUP_VARS = {'ansible_become': True, 'ansible_become_method': 'enable', 'ansible_connection': 'ansible.netcommon.network_cli', 'ansible_network_os': 'nxos'}
add_custom_group_to_inventory(group: InventoryGroupRequestSchema) None[source]

Add custom group to inventory

Parameters:

group – The group to add

Returns:

Adds the custom group to the inventory

Raises:

TypeError – If group is not an instance of InventoryGroupRequestSchema

add_custom_groups_to_inventory(groups: List[InventoryGroupRequestSchema]) None[source]

Add custom group to inventory

Parameters:

groups – The groups to add

Returns:

Adds the custom groups to the inventory

Raises:

TypeError – If groups is not a list of InventoryGroupRequestSchema

add_eos_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add EOS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_eos_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple EOS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_host_to_custom_group_to_inventory(group_name: str, host: InventoryHostRequestSchema) None[source]

Add host to custom group to inventory

Parameters:
  • group_name – The group name to add the host to

  • host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If group_name is not a string or host is not an instance of InventoryHostRequestSchema

add_hosts_to_custom_group_to_inventory(group_name: str, hosts: List[InventoryHostRequestSchema]) None[source]

Add hosts to custom group to inventory

Parameters:
  • group_name – The group name to add the hosts to

  • hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If group_name is not a string or hosts is not a list of InventoryHostRequestSchema

add_ios_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add IOS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_ios_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple IOS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_iosxr_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add IOS-XR host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_iosxr_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple IOS-XR hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

add_nxos_host_to_inventory(host: InventoryHostRequestSchema) None[source]

Add NX-OS host to inventory

Parameters:

host – The host to add

Returns:

Adds the host to the inventory

Raises:

TypeError – If host is not an instance of InventoryHostRequestSchema

add_nxos_hosts_to_inventory(hosts: List[InventoryHostRequestSchema]) None[source]

Add multiple NX-OS hosts to inventory

Parameters:

hosts – The hosts to add

Returns:

Adds the hosts to the inventory

Raises:

TypeError – If hosts is not a list of InventoryHostRequestSchema

run() None[source]

Run the inventory builder

Returns:

Runs the inventory builder

ansible_aap_api_client.job_management module

AAP Job Management

class ansible_aap_api_client.job_management.JobManagement(base_url: str, username: str, password: str, ssl_verify: bool | str, job_template_name: str, inventory_name: str)[source]

Bases: Runable, AAPClient

Job management class, to run a job template against an inventory

Parameters:
  • base_url – The base url to use

  • username – The username to use

  • password – The password to use

  • ssl_verify – The SSL verification True or False or a path to a certificate

  • job_template_name – The name of the job template

  • inventory_name – The name of the inventory

Raises:
  • TypeError – If job_template_name is not of type str

  • TypeError – If inventory_name is not of type str

poll_completion(print_status: bool | None = False, **kwargs) JobManagementRunStatus[source]

Run the job and poll the completion of a job

Parameters:
  • print_status – Print the status of the job

  • kwargs – The keyword arguments to pass to the launch_job_template method

Returns:

The completed status of the job

Raises:

TypeError – If print_status is not of type bool

run(**kwargs) None[source]

Run the job management

Parameters:

kwargs – The keyword arguments to pass to the launch_job_template method

Returns:

Runs the inventory builder

ansible_aap_api_client.schemas module

Data schemas

class ansible_aap_api_client.schemas.InventoryGroupRequestSchema(name: str, description: str, variables: str | dict | None = '---')[source]

Bases: _BaseSchema

Inventory Group Request Schema

Variables:
  • name – Name of the Group

  • description – Description of the Group

  • variables – Variables of the group in JSON or YAML format

description: str
name: str
variables: str | dict | None = '---'
class ansible_aap_api_client.schemas.InventoryHostRequestSchema(name: str, description: str, enabled: bool | None = True, instance_id: str | None = '', variables: str | dict | None = '---')[source]

Bases: _BaseSchema

Inventory Host Request Schema

Variables:
  • name – Name of the Host

  • description – Description of the Host

  • enabled – Whether to enable the Host

  • instance_id – Instance ID of the Host

  • variables – Variables of the host in JSON or YAML format

description: str
enabled: bool | None = True
instance_id: str | None = ''
name: str
variables: str | dict | None = '---'
class ansible_aap_api_client.schemas.InventoryRequestSchema(name: str, description: str, organization: int, kind: str | None = '', host_filter: str | None = None, variables: str | dict | None = '---', prevent_instance_group_fallback: bool | None = False)[source]

Bases: _BaseSchema

Inventory Request Schema

Variables:
  • name – Name of the Inventory

  • description – Description of the Inventory

  • organization – Organization the Inventory belongs to

  • kind – Kind of the Inventory

  • host_filter – Host filter of the Inventory

  • variables – Variables of the all group of the Inventory in JSON or YAML format

  • prevent_instance_group_fallback – Whether to prevent fallback

description: str
host_filter: str | None = None
kind: str | None = ''
name: str
organization: int
prevent_instance_group_fallback: bool | None = False
variables: str | dict | None = '---'
class ansible_aap_api_client.schemas.JobManagementRunStatus(status: str, job_id: int)[source]

Bases: _BaseSchema

Job run status schema

Variables:
  • status – The job status

  • job_id – The Job ID

job_id: int
status: str
class ansible_aap_api_client.schemas.JobTemplateRequestSchema(name: str | None = '', description: str | None = '', job_type: Literal['run', 'check'] | None = 'run', inventory: int | None = None, project: int | None = None, playbook: str | None = '', scm_branch: str | None = '', forks: int | None = 0, limit: str | None = '', verbosity: Literal[0, 1, 2, 3, 4, 5] | None = 0, extra_vars: str | None = '', job_tags: str | None = '', force_handlers: bool | None = False, skip_tags: str | None = '', start_at_task: str | None = '', timeout: int | None = 0, use_fact_cache: bool | None = False, execution_environment: int | None = None, host_config_key: str | None = '', ask_scm_branch_on_launch: bool | None = False, ask_diff_mode_on_launch: bool | None = False, ask_variables_on_launch: bool | None = False, ask_limit_on_launch: bool | None = False, ask_tags_on_launch: bool | None = False, ask_skip_tags_on_launch: bool | None = False, ask_job_type_on_launch: bool | None = False, ask_verbosity_on_launch: bool | None = False, ask_inventory_on_launch: bool | None = False, ask_credential_on_launch: bool | None = False, ask_execution_environment_on_launch: bool | None = False, ask_labels_on_launch: bool | None = False, ask_forks_on_launch: bool | None = False, ask_job_slice_count_on_launch: bool | None = False, ask_timeout_on_launch: bool | None = False, ask_instance_groups_on_launch: bool | None = False, survey_enabled: bool | None = False, become_enabled: bool | None = False, diff_mode: bool | None = False, allow_simultaneous: bool | None = False, job_slice_count: int | None = 1, webhook_service: Literal['', 'github', 'gitlab', 'bitbucket_dc'] | None = None, webhook_credential: int | None = None, prevent_instance_group_fallback: bool | None = False)[source]

Bases: _BaseSchema

Job Template Request Schema

allow_simultaneous: bool | None = False
ask_credential_on_launch: bool | None = False
ask_diff_mode_on_launch: bool | None = False
ask_execution_environment_on_launch: bool | None = False
ask_forks_on_launch: bool | None = False
ask_instance_groups_on_launch: bool | None = False
ask_inventory_on_launch: bool | None = False
ask_job_slice_count_on_launch: bool | None = False
ask_job_type_on_launch: bool | None = False
ask_labels_on_launch: bool | None = False
ask_limit_on_launch: bool | None = False
ask_scm_branch_on_launch: bool | None = False
ask_skip_tags_on_launch: bool | None = False
ask_tags_on_launch: bool | None = False
ask_timeout_on_launch: bool | None = False
ask_variables_on_launch: bool | None = False
ask_verbosity_on_launch: bool | None = False
become_enabled: bool | None = False
description: str | None = ''
diff_mode: bool | None = False
execution_environment: int | None = None
extra_vars: str | None = ''
force_handlers: bool | None = False
forks: int | None = 0
host_config_key: str | None = ''
inventory: int | None = None
job_slice_count: int | None = 1
job_tags: str | None = ''
job_type: Literal['run', 'check'] | None = 'run'
limit: str | None = ''
name: str | None = ''
playbook: str | None = ''
prevent_instance_group_fallback: bool | None = False
project: int | None = None
scm_branch: str | None = ''
skip_tags: str | None = ''
start_at_task: str | None = ''
survey_enabled: bool | None = False
timeout: int | None = 0
use_fact_cache: bool | None = False
verbosity: Literal[0, 1, 2, 3, 4, 5] | None = 0
webhook_credential: int | None = None
webhook_service: Literal['', 'github', 'gitlab', 'bitbucket_dc'] | None = None
class ansible_aap_api_client.schemas.OrganizationRequestSchema(name: str, description: str, max_hosts: int | None = 0, default_environment: int | None = None)[source]

Bases: _BaseSchema

Organization Request Schema

Variables:
  • name – Name of the Group

  • description – Description of the Group

  • max_hosts – The maximum hosts 0 means unlimited

  • default_environment – The id of the execution environment

default_environment: int | None = None
description: str
max_hosts: int | None = 0
name: str

Module contents

init for ansible_aap_api_client