From 4a9d8dcff39f39a4d1b68f5e1e3edc2d15701a6e Mon Sep 17 00:00:00 2001 From: kaio Guilherme Date: Fri, 19 Apr 2024 22:55:11 -0400 Subject: [PATCH] V 1.0.1 added support for netbox 3.7.5 or higher, code optimization and bug fixes. --- README.md | 19 +- netboxCli/circuits/circuit_types.py | 99 +++--- netboxCli/circuits/circuits.py | 99 +++--- netboxCli/circuits/provider_accounts.py | 99 +++--- netboxCli/circuits/provider_networks.py | 99 +++--- netboxCli/circuits/providers.py | 99 +++--- netboxCli/client.py | 13 +- netboxCli/compile.py | 314 +++++++++++++----- netboxCli/connections/__init__.py | 14 +- netboxCli/connections/cables.py | 99 +++--- netboxCli/connections/console_connections.py | 48 ++- .../connections/interface_connections.py | 99 +++--- netboxCli/connections/power_connections.py | 48 ++- netboxCli/connections/wireless_links.py | 99 +++--- netboxCli/core.py | 20 +- netboxCli/customization/__init__.py | 2 - .../customization/custom_field_choices.py | 68 ---- netboxCli/customization/custom_fields.py | 99 +++--- netboxCli/customization/custom_links.py | 99 +++--- netboxCli/customization/export_templates.py | 99 +++--- netboxCli/customization/image_attachments.py | 99 +++--- netboxCli/customization/reports.py | 99 +++--- netboxCli/customization/saved_filters.py | 99 +++--- netboxCli/customization/scripts.py | 99 +++--- netboxCli/customization/tags.py | 99 +++--- netboxCli/devices/__init__.py | 4 +- netboxCli/devices/console_ports.py | 99 +++--- netboxCli/devices/console_server_ports.py | 99 +++--- netboxCli/devices/device_types.py | 99 +++--- netboxCli/devices/devices.py | 99 +++--- netboxCli/devices/devices_roles.py | 99 +++--- netboxCli/devices/front_ports.py | 99 +++--- netboxCli/devices/interfaces.py | 99 +++--- netboxCli/devices/inventory_items.py | 99 +++--- netboxCli/devices/inventory_items_roles.py | 99 +++--- netboxCli/devices/manufacturers.py | 99 +++--- netboxCli/devices/modules.py | 99 +++--- netboxCli/devices/modules_bays.py | 99 +++--- netboxCli/devices/modules_types.py | 99 +++--- netboxCli/devices/platforms.py | 99 +++--- netboxCli/devices/power_outlets.py | 99 +++--- netboxCli/devices/power_ports.py | 99 +++--- netboxCli/devices/rear_ports.py | 99 +++--- netboxCli/devices/virtual_chassis.py | 99 +++--- netboxCli/devices/virtual_chassis_contexts.py | 99 +++--- netboxCli/ipam/__init__.py | 4 +- netboxCli/ipam/aggregates.py | 99 +++--- netboxCli/ipam/asn_ranges.py | 99 +++--- netboxCli/ipam/asns.py | 99 +++--- netboxCli/ipam/fhrp_groups.py | 99 +++--- netboxCli/ipam/ip_addresses.py | 99 +++--- netboxCli/ipam/ip_ranges.py | 99 +++--- netboxCli/ipam/prefix_roles.py | 99 +++--- netboxCli/ipam/prefixes.py | 99 +++--- netboxCli/ipam/rirs.py | 99 +++--- netboxCli/ipam/router_targets.py | 99 +++--- netboxCli/ipam/services.py | 99 +++--- netboxCli/ipam/services_templates.py | 99 +++--- netboxCli/ipam/vlan_groups.py | 99 +++--- netboxCli/ipam/vlans.py | 99 +++--- netboxCli/ipam/vrfs.py | 99 +++--- netboxCli/operations/__init__.py | 7 +- netboxCli/operations/change_log.py | 68 ---- netboxCli/operations/data_sources.py | 99 +++--- netboxCli/operations/jobs.py | 99 +++--- netboxCli/operations/journal_entries.py | 99 +++--- netboxCli/operations/webhooks.py | 99 +++--- netboxCli/organization/__init__.py | 7 +- netboxCli/organization/contact_assignment.py | 71 ++++ .../organization/contact_associations.py | 68 ---- netboxCli/organization/contact_groups.py | 99 +++--- netboxCli/organization/contact_roles.py | 99 +++--- netboxCli/organization/contacts.py | 99 +++--- netboxCli/organization/locations.py | 99 +++--- netboxCli/organization/racks.py | 99 +++--- netboxCli/organization/racks_roles.py | 99 +++--- netboxCli/organization/regions.py | 99 +++--- netboxCli/organization/reservations.py | 99 +++--- netboxCli/organization/site_groups.py | 99 +++--- netboxCli/organization/sites.py | 99 +++--- netboxCli/organization/tenant_groups.py | 99 +++--- netboxCli/organization/tenants.py | 99 +++--- netboxCli/overlay/__init__.py | 11 - netboxCli/overlay/l2vpns.py | 68 ---- netboxCli/overlay/terminations.py | 68 ---- netboxCli/power/power_feeds.py | 99 +++--- netboxCli/power/power_panels.py | 99 +++--- netboxCli/provisioning/config_contexts.py | 99 +++--- netboxCli/provisioning/config_templates.py | 99 +++--- netboxCli/virtualization/cluster_groups.py | 99 +++--- netboxCli/virtualization/cluster_types.py | 99 +++--- netboxCli/virtualization/clusters.py | 99 +++--- netboxCli/virtualization/interfaces.py | 99 +++--- netboxCli/virtualization/virtual_machines.py | 99 +++--- netboxCli/vpn/__init__.py | 26 ++ netboxCli/vpn/ike_policies.py | 71 ++++ netboxCli/vpn/ike_proposals.py | 71 ++++ netboxCli/vpn/ipsec_policies.py | 71 ++++ netboxCli/vpn/ipsec_profiles.py | 71 ++++ netboxCli/vpn/ipsec_proposals.py | 71 ++++ netboxCli/vpn/l2vpns.py | 71 ++++ netboxCli/vpn/terminations.py | 71 ++++ netboxCli/vpn/tunnel_grups.py | 71 ++++ netboxCli/vpn/tunnel_terminations.py | 71 ++++ netboxCli/vpn/tunnels.py | 71 ++++ netboxCli/wireless/wireless_lan_groups.py | 99 +++--- netboxCli/wireless/wireless_lans.py | 99 +++--- pyproject.toml | 2 +- setup.py | 6 +- test.py | 83 +++++ 110 files changed, 5179 insertions(+), 4193 deletions(-) delete mode 100644 netboxCli/customization/custom_field_choices.py delete mode 100644 netboxCli/operations/change_log.py create mode 100644 netboxCli/organization/contact_assignment.py delete mode 100644 netboxCli/organization/contact_associations.py delete mode 100644 netboxCli/overlay/__init__.py delete mode 100644 netboxCli/overlay/l2vpns.py delete mode 100644 netboxCli/overlay/terminations.py create mode 100644 netboxCli/vpn/__init__.py create mode 100644 netboxCli/vpn/ike_policies.py create mode 100644 netboxCli/vpn/ike_proposals.py create mode 100644 netboxCli/vpn/ipsec_policies.py create mode 100644 netboxCli/vpn/ipsec_profiles.py create mode 100644 netboxCli/vpn/ipsec_proposals.py create mode 100644 netboxCli/vpn/l2vpns.py create mode 100644 netboxCli/vpn/terminations.py create mode 100644 netboxCli/vpn/tunnel_grups.py create mode 100644 netboxCli/vpn/tunnel_terminations.py create mode 100644 netboxCli/vpn/tunnels.py create mode 100644 test.py diff --git a/README.md b/README.md index 2c44823..4def9d9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Lista as dependencias * requests * python 3.11 ou superior - * [netbox](https://github.com/netbox-community/netbox) + * [netbox >=3.7.5](https://github.com/netbox-community/netbox) ## 🔧Instalação @@ -130,7 +130,7 @@ Aqui está um checklist do que está atualmente disponível no NetboxCli e do qu - [x] **Connections:** Interaja com conexões físicas e lógicas entre dispositivos de rede. - [x] **Wireless:** Gerencie redes sem fio, pontos de acesso e configurações de Wi-Fi. - [x] **IPAM:** Simplifique a gestão de blocos de endereços IP, facilitando a adição, recuperação e atualização. -- [x] **Overlay:** Suporte para redes de sobreposição, como VPNs e túneis. +- [x] **Vpn:** Suporte para redes de sobreposição, como VPNs e túneis. - [x] **Virtualização:** Gerencie máquinas virtuais de maneira eficaz, desde a criação até a exclusão. - [x] **Circuits:** Gerencie circuitos de rede, como conexões de fibra óptica e links externos. - [x] **Power:** Acesse informações relacionadas ao fornecimento de energia e energia de seus dispositivos. @@ -142,18 +142,13 @@ Aqui está um checklist do que está atualmente disponível no NetboxCli e do qu Este checklist será atualizado à medida que novas funcionalidades forem implementadas. Agradecemos por seu interesse e paciência enquanto trabalhamos para tornar o NetboxCli mais abrangente e útil para suas necessidades de automação e gerenciamento de rede. -## 📌 Versão 1.0.0 +## 📌 Versão 1.0.1 -### **Adições na Versão 1.0.0** - -- **Connections:** Adicionado suporte para conexões físicas e lógicas entre dispositivos de rede. -- **Overlay:** Adicionado suporte para redes de sobreposição, como VPNs e túneis. -- **Circuits:** Adicionado suporte para circuitos de rede, como conexões de fibra óptica e links externos. -- **Power:** Adicionado suporte para informações relacionadas ao fornecimento de energia e energia de seus dispositivos. -- **Provisioning:** Adicionado suporte para provisionamento de rede, incluindo configurações de DHCP e DNS. -- **Customization:** Adicionado suporte para modelos e configurações personalizadas para seus dispositivos de rede. -- **Operations:** Adicionado suporte para informações sobre operações de rede, como manutenção e atualizações. +### **Adições na Versão 1.0.1** +- **Atualização do Overlay:** atualização do overlay atualmente tendo o nome de vpn com adicição de novos parametros +- **Correção de Bugs:** correção de bugs e melhorias no código +- **Criação de sistema de testes:** criação de testes para garantir a qualidade do código por enquanto openrando fazendo a validação dos metodos get() ## ✒️ Autores diff --git a/netboxCli/circuits/circuit_types.py b/netboxCli/circuits/circuit_types.py index 74ba064..4551414 100644 --- a/netboxCli/circuits/circuit_types.py +++ b/netboxCli/circuits/circuit_types.py @@ -8,61 +8,64 @@ class CircuitTypes: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/circuits/circuits.py b/netboxCli/circuits/circuits.py index cf303d5..af5b056 100644 --- a/netboxCli/circuits/circuits.py +++ b/netboxCli/circuits/circuits.py @@ -8,61 +8,64 @@ class CircuitsClass: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/circuits/provider_accounts.py b/netboxCli/circuits/provider_accounts.py index 5ed2d68..0b5769d 100644 --- a/netboxCli/circuits/provider_accounts.py +++ b/netboxCli/circuits/provider_accounts.py @@ -8,61 +8,64 @@ class ProviderAccounts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/circuits/provider_networks.py b/netboxCli/circuits/provider_networks.py index a2f0b91..a6b24bf 100644 --- a/netboxCli/circuits/provider_networks.py +++ b/netboxCli/circuits/provider_networks.py @@ -8,61 +8,64 @@ class ProviderNetworks: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/circuits/providers.py b/netboxCli/circuits/providers.py index 9dc647e..9635a5e 100644 --- a/netboxCli/circuits/providers.py +++ b/netboxCli/circuits/providers.py @@ -8,61 +8,64 @@ class Providers: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/client.py b/netboxCli/client.py index 3c0a9da..bcc8632 100644 --- a/netboxCli/client.py +++ b/netboxCli/client.py @@ -4,7 +4,7 @@ from .connections import Connections from .wireless import Wireless from .ipam import Ipam -from .overlay import Overlay +from .vpn import Vpn from .virtualization import Virtualization from .circuits import Circuits from .power import Power @@ -20,7 +20,7 @@ def __init__(self, API_IP, API_TOKEN): self.connections = Connections(self) self.wireless = Wireless(self) self.ipam = Ipam(self) - self.overlay = Overlay(self) + self.overlay = Vpn(self) self.virtualization = Virtualization(self) self.circuits = Circuits(self) self.power = Power(self) @@ -40,12 +40,15 @@ def _slug(self, text): def _request(self, method, endpoint, data=None): url = f'{self._base_url}{endpoint}' - response = requests.request(method, url, json=data, headers=self._headers) - + try: + response = requests.request(method, url, json=data, headers=self._headers) + except requests.exceptions.RequestException as e: + return ([111, e]) + + if response.status_code == 200: return response.json() else: - print(f'Status {response.status_code}: {response.text}') return [response.status_code, response.text] def _get_id(self, name, endpoint): diff --git a/netboxCli/compile.py b/netboxCli/compile.py index c8fa5a9..de3a48d 100644 --- a/netboxCli/compile.py +++ b/netboxCli/compile.py @@ -3,126 +3,214 @@ # Lista de dados de teste api = [ ['organization',[ - ['sites', 'Sites'], - ['regions', 'Regions'], - ['site_groups', 'SiteGroups'], - ['locations', 'Locations'], - ['racks', 'Racks'], - ['racks_roles', 'RacksRoles'], - ['reservations', 'Reservations'], - ['tenants', 'Tenants'], - ['tenant_groups', 'TenantGroups'], - ['contacts', 'Contacts'], - ['contact_groups', 'ContactGroups'], - ['contact_roles', 'ContactRoles'], - ['contact_associations', 'ContactAssociations'], + ['sites', 'Sites', ['GET', 'POST', 'PUT', 'DELETE']], + ['regions', 'Regions', ['GET', 'POST', 'PUT', 'DELETE']], + ['site_groups', 'SiteGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['locations', 'Locations', ['GET', 'POST', 'PUT', 'DELETE']], + ['racks', 'Racks', ['GET', 'POST', 'PUT', 'DELETE']], + ['racks_roles', 'RacksRoles', ['GET', 'POST', 'PUT', 'DELETE']], + ['reservations', 'Reservations', ['GET', 'POST', 'PUT', 'DELETE']], + ['tenants', 'Tenants', ['GET', 'POST', 'PUT', 'DELETE']], + ['tenant_groups', 'TenantGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['contacts', 'Contacts', ['GET', 'POST', 'PUT', 'DELETE']], + ['contact_groups', 'ContactGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['contact_roles', 'ContactRoles', ['GET', 'POST', 'PUT', 'DELETE']], + ['contact_assignment', 'ContactAssignment', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['devices',[ - ['devices', 'DevicesClass'], - ['modules', 'Modules'], - ['devices_roles', 'DevicesRoles'], - ['platforms', 'Platforms'], - ['virtual_chassis', 'VirtualChassis'], - ['virtual_chassis_contexts', 'VirtualChassisContexts'], - ['device_types', 'DeviceTypes'], - ['modules_types', 'ModulesTypes'], - ['manufacturers', 'Manufacturers'], - ['interfaces', 'Interfaces'], - ['front_ports', 'FrontPorts'], - ['rear_ports', 'RearPorts'], - ['console_ports', 'ConsolePorts'], - ['console_server_ports', 'ConsoleServerPorts'], - ['power_ports', 'PowerPorts'], - ['power_outlets', 'PowerOutlets'], - ['modules_bays', 'ModulesBays'], - ['inventory_items', 'InventoryItems'], - ['inventory_items_roles', 'InventoryItemsRoles'], + ['devices', 'DevicesClass', ['GET', 'POST', 'PUT', 'DELETE']], + ['modules', 'Modules', ['GET', 'POST', 'PUT', 'DELETE']], + ['devices_roles', 'DevicesRoles', ['GET', 'POST', 'PUT', 'DELETE']], + ['platforms', 'Platforms', ['GET', 'POST', 'PUT', 'DELETE']], + ['virtual_chassis', 'VirtualChassis', ['GET', 'POST', 'PUT', 'DELETE']], + ['virtual_chassis_contexts', 'VirtualChassisContexts', ['GET', 'POST', 'PUT', 'DELETE']], + ['device_types', 'DeviceTypes', ['GET', 'POST', 'PUT', 'DELETE']], + ['modules_types', 'ModulesTypes', ['GET', 'POST', 'PUT', 'DELETE']], + ['manufacturers', 'Manufacturers', ['GET', 'POST', 'PUT', 'DELETE']], + ['interfaces', 'Interfaces', ['GET', 'POST', 'PUT', 'DELETE']], + ['front_ports', 'FrontPorts', ['GET', 'POST', 'PUT', 'DELETE']], + ['rear_ports', 'RearPorts', ['GET', 'POST', 'PUT', 'DELETE']], + ['console_ports', 'ConsolePorts', ['GET', 'POST', 'PUT', 'DELETE']], + ['console_server_ports', 'ConsoleServerPorts', ['GET', 'POST', 'PUT', 'DELETE']], + ['power_ports', 'PowerPorts', ['GET', 'POST', 'PUT', 'DELETE']], + ['power_outlets', 'PowerOutlets', ['GET', 'POST', 'PUT', 'DELETE']], + ['modules_bays', 'ModulesBays', ['GET', 'POST', 'PUT', 'DELETE']], + ['inventory_items', 'InventoryItems', ['GET', 'POST', 'PUT', 'DELETE']], + ['inventory_items_roles', 'InventoryItemsRoles', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['connections',[ - ['cables', 'Cables'], - ['wireless_links', 'WirelessLinks'], - ['interface_connections', 'InterfaceConnections'], - ['console_connections', 'ConsoleConnections'], - ['power_connections', 'PowerConnections'], + ['cables', 'Cables', ['GET', 'POST', 'PUT', 'DELETE']], + ['wireless_links', 'WirelessLinks', ['GET', 'POST', 'PUT', 'DELETE']], + ['interface_connections', 'InterfaceConnections', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['wireless',[ - ['wireless_lans', 'WirelessLans'], - ['wireless_lan_groups', 'WirelessLanGroups'] + ['wireless_lans', 'WirelessLans', ['GET', 'POST', 'PUT', 'DELETE']], + ['wireless_lan_groups', 'WirelessLanGroups', ['GET', 'POST', 'PUT', 'DELETE']] ]], ['ipam',[ - ['ip_addresses', 'IpAddresses'], - ['ip_ranges', 'IpRanges'], - ['prefixes', 'Prefixes'], - ['prefix_roles', 'PrefixRoles'], - ['asn_ranges', 'AsnRanges'], - ['asns', 'Asns'], - ['aggregates', 'Aggregates'], - ['rirs', 'Rirs'], - ['vrfs', 'Vrfs'], - ['router_targets', 'RouterTargets'], - ['vlans', 'Vlans'], - ['vlan_groups', 'VlanGroups'], - ['fhrp_groups', 'FhrpGroups'], - ['services_templates', 'ServicesTemplates'], - ['services', 'Services'] + ['ip_addresses', 'IpAddresses', ['GET', 'POST', 'PUT', 'DELETE']], + ['ip_ranges', 'IpRanges', ['GET', 'POST', 'PUT', 'DELETE']], + ['prefixes', 'Prefixes', ['GET', 'POST', 'PUT', 'DELETE']], + ['prefix_roles', 'PrefixRoles', ['GET', 'POST', 'PUT', 'DELETE']], + ['asn_ranges', 'AsnRanges', ['GET', 'POST', 'PUT', 'DELETE']], + ['asns', 'Asns', ['GET', 'POST', 'PUT', 'DELETE']], + ['aggregates', 'Aggregates', ['GET', 'POST', 'PUT', 'DELETE']], + ['rirs', 'Rirs', ['GET', 'POST', 'PUT', 'DELETE']], + ['vrfs', 'Vrfs', ['GET', 'POST', 'PUT', 'DELETE']], + ['router_targets', 'RouterTargets', ['GET', 'POST', 'PUT', 'DELETE']], + ['vlans', 'Vlans', ['GET', 'POST', 'PUT', 'DELETE']], + ['vlan_groups', 'VlanGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['fhrp_groups', 'FhrpGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['services_templates', 'ServicesTemplates', ['GET', 'POST', 'PUT', 'DELETE']], + ['services', 'Services', ['GET', 'POST', 'PUT', 'DELETE']] ]], - ['overlay',[ - ['l2vpns', 'L2vpns'], - ['terminations', 'Terminations'], + ['vpn',[ + ['tunnels', 'Tunnels', ['GET', 'POST', 'PUT', 'DELETE']], + ['tunnel_terminations', 'TunnelTerminations', ['GET', 'POST', 'PUT', 'DELETE']], + ['tunnel_grups', 'TunnelGrups', ['GET', 'POST', 'PUT', 'DELETE']], + ['l2vpns', 'L2vpns', ['GET', 'POST', 'PUT', 'DELETE']], + ['terminations', 'Terminations', ['GET', 'POST', 'PUT', 'DELETE']], + ['ike_policies', 'IkePolicies', ['GET', 'POST', 'PUT', 'DELETE']], + ['ike_proposals', 'IkeProposals', ['GET', 'POST', 'PUT', 'DELETE']], + ['ipsec_policies', 'IpsecPolicies', ['GET', 'POST', 'PUT', 'DELETE']], + ['ipsec_profiles', 'IpsecProfiles', ['GET', 'POST', 'PUT', 'DELETE']], + ['ipsec_proposals', 'IpsecProposals', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['virtualization',[ - ['cluster_groups', 'ClusterGroups'], - ['cluster_types', 'ClusterTypes'], - ['clusters', 'Clusters'], - ['virtual_machines', 'VirtualMachines'], - ['interfaces', 'Interfaces'] + ['cluster_groups', 'ClusterGroups', ['GET', 'POST', 'PUT', 'DELETE']], + ['cluster_types', 'ClusterTypes', ['GET', 'POST', 'PUT', 'DELETE']], + ['clusters', 'Clusters', ['GET', 'POST', 'PUT', 'DELETE']], + ['virtual_machines', 'VirtualMachines', ['GET', 'POST', 'PUT', 'DELETE']], + ['interfaces', 'Interfaces', ['GET', 'POST', 'PUT', 'DELETE']] ]], ['Circuits',[ - ['circuits', 'CircuitsClass'], - ['circuit_types', 'CircuitTypes'], - ['providers', 'Providers'], - ['provider_accounts', 'ProviderAccounts'], - ['provider_networks', 'ProviderNetworks'], + ['circuits', 'CircuitsClass', ['GET', 'POST', 'PUT', 'DELETE']], + ['circuit_types', 'CircuitTypes', ['GET', 'POST', 'PUT', 'DELETE']], + ['providers', 'Providers', ['GET', 'POST', 'PUT', 'DELETE']], + ['provider_accounts', 'ProviderAccounts', ['GET', 'POST', 'PUT', 'DELETE']], + ['provider_networks', 'ProviderNetworks', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['power',[ - ['power_feeds', 'PowerFeeds'], - ['power_panels', 'PowerPanels'], + ['power_feeds', 'PowerFeeds', ['GET', 'POST', 'PUT', 'DELETE']], + ['power_panels', 'PowerPanels', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['Provisioning',[ - ['config_contexts', 'ConfigContexts'], - ['config_templates', 'ConfigTemplates'], + ['config_contexts', 'ConfigContexts', ['GET', 'POST', 'PUT', 'DELETE']], + ['config_templates', 'ConfigTemplates', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['Customization', [ - ['custom_fields', 'CustomFields'], - ['custom_field_choices', 'CustomFieldChoices'], - ['custom_links', 'CustomLinks'], - ['export_templates', 'ExportTemplates'], - ['saved_filters', 'SavedFilters'], - ['tags', 'Tags'], - ['image_attachments', 'ImageAttachments'], - ['reports', 'Reports'], - ['scripts', 'Scripts'], + ['custom_fields', 'CustomFields', ['GET', 'POST', 'PUT', 'DELETE']], + ['custom_links', 'CustomLinks', ['GET', 'POST', 'PUT', 'DELETE']], + ['export_templates', 'ExportTemplates', ['GET', 'POST', 'PUT', 'DELETE']], + ['saved_filters', 'SavedFilters', ['GET', 'POST', 'PUT', 'DELETE']], + ['tags', 'Tags', ['GET', 'POST', 'PUT', 'DELETE']], + ['image_attachments', 'ImageAttachments', ['GET', 'POST', 'PUT', 'DELETE']], + ['reports', 'Reports', ['GET', 'POST', 'PUT', 'DELETE']], + ['scripts', 'Scripts', ['GET', 'POST', 'PUT', 'DELETE']], ]], ['Operations', [ - ['data_sources', 'DataSources'], - ['webhooks', 'Webhooks'], - ['jobs', 'Jobs'], - ['journal_entries', 'JournalEntries'], - ['change_log', 'ChangeLog'], + ['data_sources', 'DataSources', ['GET', 'POST', 'PUT', 'DELETE']], + ['webhooks', 'Webhooks', ['GET', 'POST', 'PUT', 'DELETE']], + ['jobs', 'Jobs', ['GET', 'POST', 'PUT', 'DELETE']], + ['journal_entries', 'JournalEntries', ['GET', 'POST', 'PUT', 'DELETE']], + ]] ] + +class_header = ''' +class {class_name}: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core +''' + +metods = { + 'POST' : ''' + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + ''' + , + 'GET' : ''' + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + ''' + , + 'PUT' : ''' + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + ''' + , + 'DELETE' : ''' + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + ''' +} + # Conteúdo da classe base class_content = ''' class {class_name}: @@ -178,26 +266,71 @@ def __init__(self, core): self._core = core def create(self, data): - """Create a new resource using the provided data.""" + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ return self._core.create(data) def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) ''' + for folder in api: folder_name = folder[0] class_list = folder[1] - + metdos_list = folder[1][0][2] + class_content = class_header + for metod in metdos_list: + class_content += metods[metod] + if not os.path.exists(folder_name): os.makedirs(folder_name) @@ -213,4 +346,5 @@ def delete(self, id: int): with open(file_name, 'w') as file: file.write(class_content.format(class_name=class_name)) + print("Process completed.") diff --git a/netboxCli/connections/__init__.py b/netboxCli/connections/__init__.py index 938ad11..6ca4e0e 100644 --- a/netboxCli/connections/__init__.py +++ b/netboxCli/connections/__init__.py @@ -1,18 +1,18 @@ from netboxCli.core import Core from .cables import Cables from .wireless_links import WirelessLinks -from .interface_connections import InterfaceConnections -from .console_connections import ConsoleConnections -from .power_connections import PowerConnections +# from .interface_connections import InterfaceConnections +# from .console_connections import ConsoleConnections +# from .power_connections import PowerConnections class Connections: def __init__(self, netbox): self.cables = Cables(Core(netbox, '/api/dcim/cables/')) - self.wireless_links = WirelessLinks(Core(netbox, '/api/dcim/wireless-links/')) - self.interface_connections = InterfaceConnections(Core(netbox, '/api/dcim/interface-connections/')) - self.console_connections = ConsoleConnections(Core(netbox, '/api/dcim/console-connections/')) - self.power_connections = PowerConnections(Core(netbox, '/api/dcim/power-connections/')) + self.wireless_links = WirelessLinks(Core(netbox, '/api/wireless/wireless-links/')) + # self.interface_connections = InterfaceConnections(Core(netbox, '/api/dcim/interfaces/')) + # self.console_connections = ConsoleConnections(Core(netbox, '/api/dcim/console-connections/')) + # self.power_connections = PowerConnections(Core(netbox, '/api/dcim/power-connections/')) __all__ = ['Connections'] \ No newline at end of file diff --git a/netboxCli/connections/cables.py b/netboxCli/connections/cables.py index 48e04a7..a90178d 100644 --- a/netboxCli/connections/cables.py +++ b/netboxCli/connections/cables.py @@ -8,61 +8,64 @@ class Cables: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/connections/console_connections.py b/netboxCli/connections/console_connections.py index 9820d60..cf94610 100644 --- a/netboxCli/connections/console_connections.py +++ b/netboxCli/connections/console_connections.py @@ -52,17 +52,57 @@ def __init__(self, core): self._core = core def create(self, data): - """Create a new resource using the provided data.""" + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ return self._core.create(data) def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) diff --git a/netboxCli/connections/interface_connections.py b/netboxCli/connections/interface_connections.py index df91b34..25ee41a 100644 --- a/netboxCli/connections/interface_connections.py +++ b/netboxCli/connections/interface_connections.py @@ -8,61 +8,64 @@ class InterfaceConnections: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/connections/power_connections.py b/netboxCli/connections/power_connections.py index 4fe30c3..12efe5f 100644 --- a/netboxCli/connections/power_connections.py +++ b/netboxCli/connections/power_connections.py @@ -52,17 +52,57 @@ def __init__(self, core): self._core = core def create(self, data): - """Create a new resource using the provided data.""" + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ return self._core.create(data) def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) diff --git a/netboxCli/connections/wireless_links.py b/netboxCli/connections/wireless_links.py index 6595609..8ebe577 100644 --- a/netboxCli/connections/wireless_links.py +++ b/netboxCli/connections/wireless_links.py @@ -8,61 +8,64 @@ class WirelessLinks: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/core.py b/netboxCli/core.py index f8f9f81..a4bdc9c 100644 --- a/netboxCli/core.py +++ b/netboxCli/core.py @@ -9,9 +9,9 @@ def create(self, data): return self._netbox._request('post',f'{self._endpoint}', data) def get(self, id: int = None, name: str = None, tags: list = None, search: str = None , limit: int = 1000): - - self._netbox._request('get', f'{self._endpoint}')['results'] - + """ + + """ if not id and name: id = self._netbox._get_id(name,f'{self._endpoint}') @@ -23,10 +23,18 @@ def get(self, id: int = None, name: str = None, tags: list = None, search: str = else: if search: - response = self._netbox._request('get', f'{self._endpoint}?q={search}&?limit={limit}')['results'] + response = self._netbox._request('get', f'{self._endpoint}?q={search}&?limit={limit}') else: - response = self._netbox._request('get', f'{self._endpoint}?limit={limit}')['results'] - + response = self._netbox._request('get', f'{self._endpoint}?limit={limit}') + + if isinstance(response, list) and response[0] != 200: + return [response[0], response[1]] + + if isinstance(response, dict): + response = response['results'] + + + if tags: filtered_resources = [] slug_tags = [self._netbox._slug(tag) for tag in tags] diff --git a/netboxCli/customization/__init__.py b/netboxCli/customization/__init__.py index 994382b..8f2aafb 100644 --- a/netboxCli/customization/__init__.py +++ b/netboxCli/customization/__init__.py @@ -1,7 +1,6 @@ from netboxCli.core import Core from .custom_fields import CustomFields -from .custom_field_choices import CustomFieldChoices from .custom_links import CustomLinks from .export_templates import ExportTemplates from .saved_filters import SavedFilters @@ -15,7 +14,6 @@ class Customization: def __init__(self, netbox): # Customization self.custom_fields = CustomFields(Core(netbox, '/api/extras/custom-fields/')) - self.custom_field_choices = CustomFieldChoices(Core(netbox, '/api/extras/custom-field-choices/')) self.custom_links = CustomLinks(Core(netbox, '/api/extras/custom-links/')) self.export_templates = ExportTemplates(Core(netbox, '/api/extras/export-templates/')) self.saved_filters = SavedFilters(Core(netbox, '/api/extras/saved-filters/')) diff --git a/netboxCli/customization/custom_field_choices.py b/netboxCli/customization/custom_field_choices.py deleted file mode 100644 index 84dc385..0000000 --- a/netboxCli/customization/custom_field_choices.py +++ /dev/null @@ -1,68 +0,0 @@ - -class CustomFieldChoices: - """ - this class is used to create, retrieve, update, and delete resources of netbox api. - - Args: - core (obj): Core object for create, retrieve, update, and delete actions. - - Attributes: - core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. - """ - - def __init__(self, core): - self._core = core - - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" - return self._core.get(id, name, tags, search, limit) - - def update(self, data): - """Update an existing resource.""" - return self._core.update(data) - - def delete(self, id: int): - """Delete a resource based on its ID.""" - return self._core.delete(id) diff --git a/netboxCli/customization/custom_fields.py b/netboxCli/customization/custom_fields.py index c92915e..80859dc 100644 --- a/netboxCli/customization/custom_fields.py +++ b/netboxCli/customization/custom_fields.py @@ -8,61 +8,64 @@ class CustomFields: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/custom_links.py b/netboxCli/customization/custom_links.py index ca1ecc3..fc266ab 100644 --- a/netboxCli/customization/custom_links.py +++ b/netboxCli/customization/custom_links.py @@ -8,61 +8,64 @@ class CustomLinks: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/export_templates.py b/netboxCli/customization/export_templates.py index 4dfdad5..498d8b1 100644 --- a/netboxCli/customization/export_templates.py +++ b/netboxCli/customization/export_templates.py @@ -8,61 +8,64 @@ class ExportTemplates: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/image_attachments.py b/netboxCli/customization/image_attachments.py index 187995a..a311272 100644 --- a/netboxCli/customization/image_attachments.py +++ b/netboxCli/customization/image_attachments.py @@ -8,61 +8,64 @@ class ImageAttachments: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/reports.py b/netboxCli/customization/reports.py index 14debe0..f46b020 100644 --- a/netboxCli/customization/reports.py +++ b/netboxCli/customization/reports.py @@ -8,61 +8,64 @@ class Reports: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/saved_filters.py b/netboxCli/customization/saved_filters.py index 0b0f0f6..2f8f29b 100644 --- a/netboxCli/customization/saved_filters.py +++ b/netboxCli/customization/saved_filters.py @@ -8,61 +8,64 @@ class SavedFilters: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/scripts.py b/netboxCli/customization/scripts.py index de34be2..ce0c06b 100644 --- a/netboxCli/customization/scripts.py +++ b/netboxCli/customization/scripts.py @@ -8,61 +8,64 @@ class Scripts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/customization/tags.py b/netboxCli/customization/tags.py index c3724b6..b0ea9c1 100644 --- a/netboxCli/customization/tags.py +++ b/netboxCli/customization/tags.py @@ -8,61 +8,64 @@ class Tags: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/__init__.py b/netboxCli/devices/__init__.py index ef16985..b65e2c4 100644 --- a/netboxCli/devices/__init__.py +++ b/netboxCli/devices/__init__.py @@ -28,7 +28,7 @@ def __init__(self, netbox): self.devices_roles = DevicesRoles(Core(netbox, '/api/dcim/device-roles/')) self.platforms = Platforms(Core(netbox, '/api/dcim/platforms/')) self.virtual_chassis = VirtualChassis(Core(netbox, '/api/dcim/virtual-chassis/')) - self.virtual_chassis_contexts = VirtualChassisContexts(Core(netbox, '/api/dcim/virtual-chassis-contexts/')) + self.virtual_chassis_contexts = VirtualChassisContexts(Core(netbox, '/api/dcim/virtual-device-contexts/')) #Devices types self.device_types = DeviceTypes(Core(netbox, '/api/dcim/device-types/')) self.modules_types = ModulesTypes(Core(netbox, '/api/dcim/module-types/')) @@ -43,7 +43,7 @@ def __init__(self, netbox): self.power_outlets = PowerOutlets(Core(netbox, '/api/dcim/power-outlets/')) self.modules_bays = ModulesBays(Core(netbox, '/api/dcim/device-bays/')) self.inventory_items = InventoryItems(Core(netbox, '/api/dcim/inventory-items/')) - self.inventory_items_roles = InventoryItemsRoles(Core(netbox, '/api/dcim/inventory-items-roles/')) + self.inventory_items_roles = InventoryItemsRoles(Core(netbox, '/api/dcim/inventory-item-roles/')) __all__ = ['Devices'] diff --git a/netboxCli/devices/console_ports.py b/netboxCli/devices/console_ports.py index 90af1c2..692a442 100644 --- a/netboxCli/devices/console_ports.py +++ b/netboxCli/devices/console_ports.py @@ -8,61 +8,64 @@ class ConsolePorts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/console_server_ports.py b/netboxCli/devices/console_server_ports.py index bcf4c4e..912a308 100644 --- a/netboxCli/devices/console_server_ports.py +++ b/netboxCli/devices/console_server_ports.py @@ -8,61 +8,64 @@ class ConsoleServerPorts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/device_types.py b/netboxCli/devices/device_types.py index 75dc14f..38b46fb 100644 --- a/netboxCli/devices/device_types.py +++ b/netboxCli/devices/device_types.py @@ -8,61 +8,64 @@ class DeviceTypes: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/devices.py b/netboxCli/devices/devices.py index 2779a3b..d8be42c 100644 --- a/netboxCli/devices/devices.py +++ b/netboxCli/devices/devices.py @@ -8,61 +8,64 @@ class DevicesClass: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/devices_roles.py b/netboxCli/devices/devices_roles.py index 8c462db..80dc75c 100644 --- a/netboxCli/devices/devices_roles.py +++ b/netboxCli/devices/devices_roles.py @@ -8,61 +8,64 @@ class DevicesRoles: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/front_ports.py b/netboxCli/devices/front_ports.py index bceb583..a066de0 100644 --- a/netboxCli/devices/front_ports.py +++ b/netboxCli/devices/front_ports.py @@ -8,61 +8,64 @@ class FrontPorts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/interfaces.py b/netboxCli/devices/interfaces.py index 51744a0..4d83d05 100644 --- a/netboxCli/devices/interfaces.py +++ b/netboxCli/devices/interfaces.py @@ -8,61 +8,64 @@ class Interfaces: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/inventory_items.py b/netboxCli/devices/inventory_items.py index 9d3a3ff..c46ab75 100644 --- a/netboxCli/devices/inventory_items.py +++ b/netboxCli/devices/inventory_items.py @@ -8,61 +8,64 @@ class InventoryItems: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/inventory_items_roles.py b/netboxCli/devices/inventory_items_roles.py index 1d70851..c5eb72b 100644 --- a/netboxCli/devices/inventory_items_roles.py +++ b/netboxCli/devices/inventory_items_roles.py @@ -8,61 +8,64 @@ class InventoryItemsRoles: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/manufacturers.py b/netboxCli/devices/manufacturers.py index bbb9049..e986e83 100644 --- a/netboxCli/devices/manufacturers.py +++ b/netboxCli/devices/manufacturers.py @@ -8,61 +8,64 @@ class Manufacturers: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/modules.py b/netboxCli/devices/modules.py index a13d671..8549311 100644 --- a/netboxCli/devices/modules.py +++ b/netboxCli/devices/modules.py @@ -8,61 +8,64 @@ class Modules: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/modules_bays.py b/netboxCli/devices/modules_bays.py index 6857b4c..77006aa 100644 --- a/netboxCli/devices/modules_bays.py +++ b/netboxCli/devices/modules_bays.py @@ -8,61 +8,64 @@ class ModulesBays: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/modules_types.py b/netboxCli/devices/modules_types.py index 1f7f6c4..26742d5 100644 --- a/netboxCli/devices/modules_types.py +++ b/netboxCli/devices/modules_types.py @@ -8,61 +8,64 @@ class ModulesTypes: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/platforms.py b/netboxCli/devices/platforms.py index 2ab019a..0a336f2 100644 --- a/netboxCli/devices/platforms.py +++ b/netboxCli/devices/platforms.py @@ -8,61 +8,64 @@ class Platforms: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/power_outlets.py b/netboxCli/devices/power_outlets.py index 82a3a1c..b0ed636 100644 --- a/netboxCli/devices/power_outlets.py +++ b/netboxCli/devices/power_outlets.py @@ -8,61 +8,64 @@ class PowerOutlets: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/power_ports.py b/netboxCli/devices/power_ports.py index e82e9fb..99f1a44 100644 --- a/netboxCli/devices/power_ports.py +++ b/netboxCli/devices/power_ports.py @@ -8,61 +8,64 @@ class PowerPorts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/rear_ports.py b/netboxCli/devices/rear_ports.py index a97b0bd..e598dfd 100644 --- a/netboxCli/devices/rear_ports.py +++ b/netboxCli/devices/rear_ports.py @@ -8,61 +8,64 @@ class RearPorts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/virtual_chassis.py b/netboxCli/devices/virtual_chassis.py index f27cc4a..0f976f0 100644 --- a/netboxCli/devices/virtual_chassis.py +++ b/netboxCli/devices/virtual_chassis.py @@ -8,61 +8,64 @@ class VirtualChassis: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/devices/virtual_chassis_contexts.py b/netboxCli/devices/virtual_chassis_contexts.py index ae92e98..63a9429 100644 --- a/netboxCli/devices/virtual_chassis_contexts.py +++ b/netboxCli/devices/virtual_chassis_contexts.py @@ -8,61 +8,64 @@ class VirtualChassisContexts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/__init__.py b/netboxCli/ipam/__init__.py index d0bf3ef..9fdd304 100644 --- a/netboxCli/ipam/__init__.py +++ b/netboxCli/ipam/__init__.py @@ -31,13 +31,13 @@ def __init__(self, netbox): self.rirs = Rirs(Core(netbox, '/api/ipam/rirs/')) self.vrfs = Vrfs(Core(netbox, '/api/ipam/vrfs/')) - self.router_targets = RouterTargets(Core(netbox, '/api/ipam/router-targets/')) + self.router_targets = RouterTargets(Core(netbox, '/api/ipam/route-targets/')) self.vlans = Vlans(Core(netbox, '/api/ipam/vlans/')) self.vlan_groups = VlanGroups(Core(netbox, '/api/ipam/vlan-groups/')) self.fhrp_groups = FhrpGroups(Core(netbox, '/api/ipam/fhrp-groups/')) - self.services_templates = ServicesTemplates(Core(netbox, '/api/ipam/services-templates/')) + self.services_templates = ServicesTemplates(Core(netbox, '/api/ipam/service-templates/')) self.services = Services(Core(netbox, '/api/ipam/services/')) diff --git a/netboxCli/ipam/aggregates.py b/netboxCli/ipam/aggregates.py index 3a2b3d2..3d11efc 100644 --- a/netboxCli/ipam/aggregates.py +++ b/netboxCli/ipam/aggregates.py @@ -8,61 +8,64 @@ class Aggregates: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/asn_ranges.py b/netboxCli/ipam/asn_ranges.py index bbe496d..a82e2ef 100644 --- a/netboxCli/ipam/asn_ranges.py +++ b/netboxCli/ipam/asn_ranges.py @@ -8,61 +8,64 @@ class AsnRanges: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/asns.py b/netboxCli/ipam/asns.py index 32210ea..96e5b6d 100644 --- a/netboxCli/ipam/asns.py +++ b/netboxCli/ipam/asns.py @@ -8,61 +8,64 @@ class Asns: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/fhrp_groups.py b/netboxCli/ipam/fhrp_groups.py index 607060e..01b0ae4 100644 --- a/netboxCli/ipam/fhrp_groups.py +++ b/netboxCli/ipam/fhrp_groups.py @@ -8,61 +8,64 @@ class FhrpGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/ip_addresses.py b/netboxCli/ipam/ip_addresses.py index 4d7cb2f..8980467 100644 --- a/netboxCli/ipam/ip_addresses.py +++ b/netboxCli/ipam/ip_addresses.py @@ -8,61 +8,64 @@ class IpAddresses: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/ip_ranges.py b/netboxCli/ipam/ip_ranges.py index f31b364..9ceca12 100644 --- a/netboxCli/ipam/ip_ranges.py +++ b/netboxCli/ipam/ip_ranges.py @@ -8,61 +8,64 @@ class IpRanges: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/prefix_roles.py b/netboxCli/ipam/prefix_roles.py index 2a33257..99a9203 100644 --- a/netboxCli/ipam/prefix_roles.py +++ b/netboxCli/ipam/prefix_roles.py @@ -8,61 +8,64 @@ class PrefixRoles: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/prefixes.py b/netboxCli/ipam/prefixes.py index f2701f3..9974a93 100644 --- a/netboxCli/ipam/prefixes.py +++ b/netboxCli/ipam/prefixes.py @@ -8,61 +8,64 @@ class Prefixes: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/rirs.py b/netboxCli/ipam/rirs.py index 2fbd77c..91709e5 100644 --- a/netboxCli/ipam/rirs.py +++ b/netboxCli/ipam/rirs.py @@ -8,61 +8,64 @@ class Rirs: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/router_targets.py b/netboxCli/ipam/router_targets.py index 1857453..566d1ab 100644 --- a/netboxCli/ipam/router_targets.py +++ b/netboxCli/ipam/router_targets.py @@ -8,61 +8,64 @@ class RouterTargets: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/services.py b/netboxCli/ipam/services.py index 054ba12..c586966 100644 --- a/netboxCli/ipam/services.py +++ b/netboxCli/ipam/services.py @@ -8,61 +8,64 @@ class Services: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/services_templates.py b/netboxCli/ipam/services_templates.py index e519140..375bf7e 100644 --- a/netboxCli/ipam/services_templates.py +++ b/netboxCli/ipam/services_templates.py @@ -8,61 +8,64 @@ class ServicesTemplates: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/vlan_groups.py b/netboxCli/ipam/vlan_groups.py index 2aa27d2..cd76933 100644 --- a/netboxCli/ipam/vlan_groups.py +++ b/netboxCli/ipam/vlan_groups.py @@ -8,61 +8,64 @@ class VlanGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/vlans.py b/netboxCli/ipam/vlans.py index 8b76bfb..ff328ec 100644 --- a/netboxCli/ipam/vlans.py +++ b/netboxCli/ipam/vlans.py @@ -8,61 +8,64 @@ class Vlans: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/ipam/vrfs.py b/netboxCli/ipam/vrfs.py index 498e2c2..5b58a5f 100644 --- a/netboxCli/ipam/vrfs.py +++ b/netboxCli/ipam/vrfs.py @@ -8,61 +8,64 @@ class Vrfs: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/operations/__init__.py b/netboxCli/operations/__init__.py index ca4b9c1..5c81f5e 100644 --- a/netboxCli/operations/__init__.py +++ b/netboxCli/operations/__init__.py @@ -4,17 +4,16 @@ from .webhooks import Webhooks from .jobs import Jobs from .journal_entries import JournalEntries -from .change_log import ChangeLog + class Operations: def __init__(self, netbox): # Integrations - self.data_sources = DataSources(Core(netbox, '/api/extras/data-sources/')) + self.data_sources = DataSources(Core(netbox, '/api/core/data-sources/')) self.webhooks = Webhooks(Core(netbox, '/api/extras/webhooks/')) # Jobs - self.jobs = Jobs(Core(netbox, '/api/extras/jobs/')) + self.jobs = Jobs(Core(netbox, '/api/core/jobs/')) # logging self.journal_entries = JournalEntries(Core(netbox, '/api/extras/journal-entries/')) - self.change_log = ChangeLog(Core(netbox, '/api/extras/changelog/')) __all__ = ['Operations'] diff --git a/netboxCli/operations/change_log.py b/netboxCli/operations/change_log.py deleted file mode 100644 index b96dc92..0000000 --- a/netboxCli/operations/change_log.py +++ /dev/null @@ -1,68 +0,0 @@ - -class ChangeLog: - """ - this class is used to create, retrieve, update, and delete resources of netbox api. - - Args: - core (obj): Core object for create, retrieve, update, and delete actions. - - Attributes: - core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. - """ - - def __init__(self, core): - self._core = core - - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" - return self._core.get(id, name, tags, search, limit) - - def update(self, data): - """Update an existing resource.""" - return self._core.update(data) - - def delete(self, id: int): - """Delete a resource based on its ID.""" - return self._core.delete(id) diff --git a/netboxCli/operations/data_sources.py b/netboxCli/operations/data_sources.py index b8ca3cd..8f6635e 100644 --- a/netboxCli/operations/data_sources.py +++ b/netboxCli/operations/data_sources.py @@ -8,61 +8,64 @@ class DataSources: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/operations/jobs.py b/netboxCli/operations/jobs.py index 06fe74b..f101756 100644 --- a/netboxCli/operations/jobs.py +++ b/netboxCli/operations/jobs.py @@ -8,61 +8,64 @@ class Jobs: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/operations/journal_entries.py b/netboxCli/operations/journal_entries.py index 352a6fc..585bf7a 100644 --- a/netboxCli/operations/journal_entries.py +++ b/netboxCli/operations/journal_entries.py @@ -8,61 +8,64 @@ class JournalEntries: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/operations/webhooks.py b/netboxCli/operations/webhooks.py index d409034..aa91413 100644 --- a/netboxCli/operations/webhooks.py +++ b/netboxCli/operations/webhooks.py @@ -8,61 +8,64 @@ class Webhooks: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/__init__.py b/netboxCli/organization/__init__.py index 047895b..b8719ff 100644 --- a/netboxCli/organization/__init__.py +++ b/netboxCli/organization/__init__.py @@ -12,7 +12,7 @@ from .contacts import Contacts from .contact_groups import ContactGroups from .contact_roles import ContactRoles -from .contact_associations import ContactAssociations +from .contact_assignment import ContactAssignments class Organization: @@ -26,7 +26,7 @@ def __init__(self, netbox): # racks self.racks = Racks(Core(netbox, '/api/dcim/racks/')) self.racks_roles = RacksRoles(Core(netbox, '/api/dcim/rack-roles/')) - self.reservations = Reservations(Core(netbox, '/api/dcim/reservations/')) + self.reservations = Reservations(Core(netbox, '/api/dcim/rack-reservations/')) # Tenancy self.tenants = Tenants(Core(netbox, '/api/tenancy/tenants/')) self.tenant_groups = TenantGroups(Core(netbox, '/api/tenancy/tenant-groups/')) @@ -34,7 +34,6 @@ def __init__(self, netbox): self.contacts = Contacts(Core(netbox, '/api/tenancy/contacts/')) self.contact_groups = ContactGroups(Core(netbox, '/api/tenancy/contact-groups/')) self.contact_roles = ContactRoles(Core(netbox, '/api/tenancy/contact-roles/')) - self.contact_associations = ContactAssociations(Core(netbox, '/api/tenancy/contact-associations/')) - + self.contact_assignments = ContactAssignments(Core(netbox, '/api/tenancy/contact-assignments/')) __all__ = ['Organization'] diff --git a/netboxCli/organization/contact_assignment.py b/netboxCli/organization/contact_assignment.py new file mode 100644 index 0000000..9383592 --- /dev/null +++ b/netboxCli/organization/contact_assignment.py @@ -0,0 +1,71 @@ + +class ContactAssignments: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/contact_associations.py b/netboxCli/organization/contact_associations.py deleted file mode 100644 index fdd6983..0000000 --- a/netboxCli/organization/contact_associations.py +++ /dev/null @@ -1,68 +0,0 @@ - -class ContactAssociations: - """ - this class is used to create, retrieve, update, and delete resources of netbox api. - - Args: - core (obj): Core object for create, retrieve, update, and delete actions. - - Attributes: - core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. - """ - - def __init__(self, core): - self._core = core - - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" - return self._core.get(id, name, tags, search, limit) - - def update(self, data): - """Update an existing resource.""" - return self._core.update(data) - - def delete(self, id: int): - """Delete a resource based on its ID.""" - return self._core.delete(id) diff --git a/netboxCli/organization/contact_groups.py b/netboxCli/organization/contact_groups.py index c519172..3ae2f46 100644 --- a/netboxCli/organization/contact_groups.py +++ b/netboxCli/organization/contact_groups.py @@ -8,61 +8,64 @@ class ContactGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/contact_roles.py b/netboxCli/organization/contact_roles.py index 87dca85..587c5c9 100644 --- a/netboxCli/organization/contact_roles.py +++ b/netboxCli/organization/contact_roles.py @@ -8,61 +8,64 @@ class ContactRoles: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/contacts.py b/netboxCli/organization/contacts.py index 969a11d..2d00cd0 100644 --- a/netboxCli/organization/contacts.py +++ b/netboxCli/organization/contacts.py @@ -8,61 +8,64 @@ class Contacts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/locations.py b/netboxCli/organization/locations.py index eedbc7a..ca6cc9e 100644 --- a/netboxCli/organization/locations.py +++ b/netboxCli/organization/locations.py @@ -8,61 +8,64 @@ class Locations: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/racks.py b/netboxCli/organization/racks.py index aad91ac..a42b19b 100644 --- a/netboxCli/organization/racks.py +++ b/netboxCli/organization/racks.py @@ -8,61 +8,64 @@ class Racks: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/racks_roles.py b/netboxCli/organization/racks_roles.py index 55c64b8..2629f33 100644 --- a/netboxCli/organization/racks_roles.py +++ b/netboxCli/organization/racks_roles.py @@ -8,61 +8,64 @@ class RacksRoles: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/regions.py b/netboxCli/organization/regions.py index c547465..8eb2dd7 100644 --- a/netboxCli/organization/regions.py +++ b/netboxCli/organization/regions.py @@ -8,61 +8,64 @@ class Regions: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/reservations.py b/netboxCli/organization/reservations.py index 7b4e298..038d4ee 100644 --- a/netboxCli/organization/reservations.py +++ b/netboxCli/organization/reservations.py @@ -8,61 +8,64 @@ class Reservations: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/site_groups.py b/netboxCli/organization/site_groups.py index 3b9b15a..02f1970 100644 --- a/netboxCli/organization/site_groups.py +++ b/netboxCli/organization/site_groups.py @@ -8,61 +8,64 @@ class SiteGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/sites.py b/netboxCli/organization/sites.py index 0c5c3e7..995a2c6 100644 --- a/netboxCli/organization/sites.py +++ b/netboxCli/organization/sites.py @@ -8,61 +8,64 @@ class Sites: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/tenant_groups.py b/netboxCli/organization/tenant_groups.py index 8d16c48..4cb3c2e 100644 --- a/netboxCli/organization/tenant_groups.py +++ b/netboxCli/organization/tenant_groups.py @@ -8,61 +8,64 @@ class TenantGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/organization/tenants.py b/netboxCli/organization/tenants.py index f092d3d..ed2d91d 100644 --- a/netboxCli/organization/tenants.py +++ b/netboxCli/organization/tenants.py @@ -8,61 +8,64 @@ class Tenants: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/overlay/__init__.py b/netboxCli/overlay/__init__.py deleted file mode 100644 index 82fba3f..0000000 --- a/netboxCli/overlay/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from netboxCli.core import Core - -from .l2vpns import L2vpns -from .terminations import Terminations - -class Overlay: - def __init__(self, netbox): - self.l2vpns = L2vpns(Core(netbox, '/api/ipam/l2vpns/')) - self.terminations = Terminations(Core(netbox, '/api/ipam/l2vpn-terminations/')) - -__all__ = ['Overlay'] diff --git a/netboxCli/overlay/l2vpns.py b/netboxCli/overlay/l2vpns.py deleted file mode 100644 index 9604d7a..0000000 --- a/netboxCli/overlay/l2vpns.py +++ /dev/null @@ -1,68 +0,0 @@ - -class L2vpns: - """ - this class is used to create, retrieve, update, and delete resources of netbox api. - - Args: - core (obj): Core object for create, retrieve, update, and delete actions. - - Attributes: - core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. - """ - - def __init__(self, core): - self._core = core - - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" - return self._core.get(id, name, tags, search, limit) - - def update(self, data): - """Update an existing resource.""" - return self._core.update(data) - - def delete(self, id: int): - """Delete a resource based on its ID.""" - return self._core.delete(id) diff --git a/netboxCli/overlay/terminations.py b/netboxCli/overlay/terminations.py deleted file mode 100644 index 6b21b3a..0000000 --- a/netboxCli/overlay/terminations.py +++ /dev/null @@ -1,68 +0,0 @@ - -class Terminations: - """ - this class is used to create, retrieve, update, and delete resources of netbox api. - - Args: - core (obj): Core object for create, retrieve, update, and delete actions. - - Attributes: - core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. - """ - - def __init__(self, core): - self._core = core - - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" - return self._core.get(id, name, tags, search, limit) - - def update(self, data): - """Update an existing resource.""" - return self._core.update(data) - - def delete(self, id: int): - """Delete a resource based on its ID.""" - return self._core.delete(id) diff --git a/netboxCli/power/power_feeds.py b/netboxCli/power/power_feeds.py index 8bf24da..ec60e92 100644 --- a/netboxCli/power/power_feeds.py +++ b/netboxCli/power/power_feeds.py @@ -8,61 +8,64 @@ class PowerFeeds: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/power/power_panels.py b/netboxCli/power/power_panels.py index 5ae9450..23d2805 100644 --- a/netboxCli/power/power_panels.py +++ b/netboxCli/power/power_panels.py @@ -8,61 +8,64 @@ class PowerPanels: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/provisioning/config_contexts.py b/netboxCli/provisioning/config_contexts.py index 8e4aa93..d280ae5 100644 --- a/netboxCli/provisioning/config_contexts.py +++ b/netboxCli/provisioning/config_contexts.py @@ -8,61 +8,64 @@ class ConfigContexts: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/provisioning/config_templates.py b/netboxCli/provisioning/config_templates.py index 86469e4..dc0511e 100644 --- a/netboxCli/provisioning/config_templates.py +++ b/netboxCli/provisioning/config_templates.py @@ -8,61 +8,64 @@ class ConfigTemplates: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/virtualization/cluster_groups.py b/netboxCli/virtualization/cluster_groups.py index 0dfe6c9..d8561ba 100644 --- a/netboxCli/virtualization/cluster_groups.py +++ b/netboxCli/virtualization/cluster_groups.py @@ -8,61 +8,64 @@ class ClusterGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/virtualization/cluster_types.py b/netboxCli/virtualization/cluster_types.py index e51a2a5..5671a84 100644 --- a/netboxCli/virtualization/cluster_types.py +++ b/netboxCli/virtualization/cluster_types.py @@ -8,61 +8,64 @@ class ClusterTypes: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/virtualization/clusters.py b/netboxCli/virtualization/clusters.py index aedfa1c..6e06b33 100644 --- a/netboxCli/virtualization/clusters.py +++ b/netboxCli/virtualization/clusters.py @@ -8,61 +8,64 @@ class Clusters: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/virtualization/interfaces.py b/netboxCli/virtualization/interfaces.py index 51744a0..4d83d05 100644 --- a/netboxCli/virtualization/interfaces.py +++ b/netboxCli/virtualization/interfaces.py @@ -8,61 +8,64 @@ class Interfaces: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/virtualization/virtual_machines.py b/netboxCli/virtualization/virtual_machines.py index 1f037fb..e8f6a92 100644 --- a/netboxCli/virtualization/virtual_machines.py +++ b/netboxCli/virtualization/virtual_machines.py @@ -8,61 +8,64 @@ class VirtualMachines: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/__init__.py b/netboxCli/vpn/__init__.py new file mode 100644 index 0000000..051960f --- /dev/null +++ b/netboxCli/vpn/__init__.py @@ -0,0 +1,26 @@ +from netboxCli.core import Core +from .ike_policies import IkePolicies +from .ike_proposals import IkeProposals +from .ipsec_policies import IpsecPolicies +from .ipsec_profiles import IpsecProfiles +from .ipsec_proposals import IpsecProposals +from .tunnel_grups import TunnelGrups +from .tunnel_terminations import TunnelTerminations +from .tunnels import Tunnels +from .l2vpns import L2vpns +from .terminations import Terminations + +class Vpn: + def __init__(self, netbox): + self.ike_policies = Core(netbox, '/api/vpn/ike-policies/') + self.ike_proposals = Core(netbox, '/api/vpn/ike-proposals/') + self.ipsec_policies = Core(netbox, '/api/vpn/ipsec-policies/') + self.ipsec_profiles = Core(netbox, '/api/vpn/ipsec-profiles/') + self.ipsec_proposals = Core(netbox, '/api/vpn/ipsec-proposals/') + self.tunnel_groups = Core(netbox, '/api/vpn/tunnel-groups/') + self.tunnel_terminations = Core(netbox, '/api/vpn/tunnel-terminations/') + self.tunnels = Core(netbox, '/api/vpn/tunnels/') + self.l2vpns = L2vpns(Core(netbox, '/api/vpn/l2vpns/')) + self.terminations = Terminations(Core(netbox, '/api/vpn/l2vpn-terminations/')) + +__all__ = ['Vpn'] diff --git a/netboxCli/vpn/ike_policies.py b/netboxCli/vpn/ike_policies.py new file mode 100644 index 0000000..fb9966c --- /dev/null +++ b/netboxCli/vpn/ike_policies.py @@ -0,0 +1,71 @@ + +class IkePolicies: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/ike_proposals.py b/netboxCli/vpn/ike_proposals.py new file mode 100644 index 0000000..741a118 --- /dev/null +++ b/netboxCli/vpn/ike_proposals.py @@ -0,0 +1,71 @@ + +class IkeProposals: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/ipsec_policies.py b/netboxCli/vpn/ipsec_policies.py new file mode 100644 index 0000000..a1d2c88 --- /dev/null +++ b/netboxCli/vpn/ipsec_policies.py @@ -0,0 +1,71 @@ + +class IpsecPolicies: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/ipsec_profiles.py b/netboxCli/vpn/ipsec_profiles.py new file mode 100644 index 0000000..78369b2 --- /dev/null +++ b/netboxCli/vpn/ipsec_profiles.py @@ -0,0 +1,71 @@ + +class IpsecProfiles: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/ipsec_proposals.py b/netboxCli/vpn/ipsec_proposals.py new file mode 100644 index 0000000..486a087 --- /dev/null +++ b/netboxCli/vpn/ipsec_proposals.py @@ -0,0 +1,71 @@ + +class IpsecProposals: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/l2vpns.py b/netboxCli/vpn/l2vpns.py new file mode 100644 index 0000000..68c3dcd --- /dev/null +++ b/netboxCli/vpn/l2vpns.py @@ -0,0 +1,71 @@ + +class L2vpns: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/terminations.py b/netboxCli/vpn/terminations.py new file mode 100644 index 0000000..0014321 --- /dev/null +++ b/netboxCli/vpn/terminations.py @@ -0,0 +1,71 @@ + +class Terminations: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/tunnel_grups.py b/netboxCli/vpn/tunnel_grups.py new file mode 100644 index 0000000..b5623fa --- /dev/null +++ b/netboxCli/vpn/tunnel_grups.py @@ -0,0 +1,71 @@ + +class TunnelGrups: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/tunnel_terminations.py b/netboxCli/vpn/tunnel_terminations.py new file mode 100644 index 0000000..d081e35 --- /dev/null +++ b/netboxCli/vpn/tunnel_terminations.py @@ -0,0 +1,71 @@ + +class TunnelTerminations: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/vpn/tunnels.py b/netboxCli/vpn/tunnels.py new file mode 100644 index 0000000..07d1d24 --- /dev/null +++ b/netboxCli/vpn/tunnels.py @@ -0,0 +1,71 @@ + +class Tunnels: + """ + this class is used to create, retrieve, update, and delete resources of netbox api. + + Args: + core (obj): Core object for create, retrieve, update, and delete actions. + + Attributes: + core (obj): Core object for create, retrieve, update, and delete actions. + """ + + def __init__(self, core): + self._core = core + + def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ + return self._core.get(id, name, tags, search, limit) + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + + def update(self, data): + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ + return self._core.update(data) + + def delete(self, id: int): + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ + return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/wireless/wireless_lan_groups.py b/netboxCli/wireless/wireless_lan_groups.py index 5d87d40..024f7ee 100644 --- a/netboxCli/wireless/wireless_lan_groups.py +++ b/netboxCli/wireless/wireless_lan_groups.py @@ -8,61 +8,64 @@ class WirelessLanGroups: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/netboxCli/wireless/wireless_lans.py b/netboxCli/wireless/wireless_lans.py index 3739727..f151390 100644 --- a/netboxCli/wireless/wireless_lans.py +++ b/netboxCli/wireless/wireless_lans.py @@ -8,61 +8,64 @@ class WirelessLans: Attributes: core (obj): Core object for create, retrieve, update, and delete actions. - - Methods: - create(data): - Create a new resource using the provided data. - - Args: - data (dict): Data to create the resource. - - Returns: - dict: Data of the created resource. - - get(id=None, name=None, tags=None): - Retrieve a resource based on ID or name. - - Args: - id (int, optional): ID of the resource to retrieve. - name (str, optional): Name of the resource to retrieve. - - Returns: - dict: Data of the retrieved resource. - - update(data): - Update an existing resource. - - Args: - data (dict): Updated data for the resource. - - Returns: - dict: Data of the resource after the update. - - delete(id): - Delete a resource based on its ID. - - Args: - id (int): ID of the resource to delete. - - Returns: - bool: True if deletion is successful, False otherwise. """ - + def __init__(self, core): self._core = core - def create(self, data): - """Create a new resource using the provided data.""" - return self._core.create(data) - def get(self, id: int = None, name: str = None, tags: list = None, search: str = None, limit: int = 1000): - """Retrieve a resource based on ID or name.""" + """ + Retrieve a resource from the NetBox API based on ID, name, tags, or search query. + + Args: + id (int, optional): The ID of the resource to retrieve. + name (str, optional): The name of the resource to retrieve. + tags (list, optional): List of tags to filter resources. + search (str, optional): Search query to filter resources. + limit (int, optional): Maximum number of results to return. Defaults to 1000. + + Returns: + dict or list: If a single resource is found, returns a dictionary containing the data of the retrieved resource. + If multiple resources are found, returns a list of dictionaries containing the data of the retrieved resources. + If no resources are found, returns an empty list. + """ return self._core.get(id, name, tags, search, limit) - + + def create(self, data): + """ + Create a new resource using the provided data. + + Args: + data (dict): Data to create the resource. It should contain all the necessary information to create the resource. + + Returns: + dict: Data of the created resource if successful. + If the creation fails or if the data is invalid, returns None. + """ + return self._core.create(data) + def update(self, data): - """Update an existing resource.""" + """ + Update an existing resource with the provided data. + + Args: + data (dict): Updated data for the resource. It should contain all the necessary information to update the resource. + + Returns: + dict: Data of the resource after the update if successful. + If the update fails or if the data is invalid, returns None. + """ return self._core.update(data) - + def delete(self, id: int): - """Delete a resource based on its ID.""" + """ + Delete a resource based on its ID. + + Args: + id (int): ID of the resource to delete. + + Returns: + bool: True if deletion is successful, False otherwise. + """ return self._core.delete(id) + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index a05d7b9..1a3e08a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netboxcli" -version = "1.0.0" +version = "1.0.1" authors = [ { name="kaio Guilherme", email="kaioguilherme444@outlook.com" }, ] diff --git a/setup.py b/setup.py index c2a1f6a..2626137 100644 --- a/setup.py +++ b/setup.py @@ -3,14 +3,14 @@ # Description of your package DESCRIPTION = ( '''A Python package to interact with the NetBox API. - Version 1.0.0 + Version 1.0.1 - Resources: * organizations * devices * connections * wireless * ipam - * overlay + * vpn * virtualization * circuits * power @@ -21,7 +21,7 @@ setup( name='netboxCli', - version='1.0.0', + version='1.0.1', description=DESCRIPTION, packages=find_packages(), install_requires=[ diff --git a/test.py b/test.py new file mode 100644 index 0000000..77ee367 --- /dev/null +++ b/test.py @@ -0,0 +1,83 @@ +import time +import logging +import netboxCli as nb + +client = nb.Client('http://localhost:8000', 'token') + +log_debug = logging.getLogger('debug') +log_debug.setLevel(logging.DEBUG) +log_debug.addHandler(logging.FileHandler('test_passed.log')) + +log_error = logging.getLogger('error') +log_error.setLevel(logging.ERROR) +log_error.addHandler(logging.FileHandler('test_failed.log')) + + +def get_modules(obj): + modules = [] + for module in dir(obj): + if not module.startswith('__') and not module.startswith('_'): + attr = getattr(obj, module) + for sub_module in dir(attr): + if not sub_module.startswith('__') and not sub_module.startswith('_'): + modules.append(f"{module}.{sub_module}") + + return modules + + +def validation(module, result): + if isinstance(result, list) and result and result[0] == 404: + print(f"Module: {module} - failed - Page not found") + log_error.error(f"Module: {module} pege not found- {result}") + return False + + elif isinstance(result, list): + print(f"Module: {module} - passed") + log_debug.info(f"Module: {module} - Result: {result}") + return True + elif isinstance(result, dict): + print(f"Module: {module} - passed") + log_debug.info(f"Module: {module} - Result: {result}") + + return True + + else: + print(f"Module: {module} - failed") + log_error.error(f"Module: {module} - Error: {result}") + return False + + +# test get method of all modules using the pytest +def test_get(obj, modules): + for module in modules: + try: + module_list = module.split('.') + module_obj1 = getattr(obj, module_list[0]) + module_obj2 = getattr(module_obj1, module_list[1]) + except Exception as e: + log_error.error(f"Error: {e}") + continue + + try: + try: + result = module_obj2.get() + time.sleep(1) + except Exception as e: + print(f"Module: {module} - request failed") + log_error.error(f"{e}") + continue + + if isinstance(result, list) and result and result[0] == 111: + print("Conenction Error") + log_error.error(f"{result}") + break + + validation(module, result) + + except Exception as e: + print(f"Module: {module} - failed") + log_error.error(f"Module: {module} execution - Error: {e}") + + +modules = get_modules(client) +test_get(client, modules)