Pular para conteúdo

Custom fields

CustomFields

Responsable for managing custom fields

Parameters:

Name Type Description Default
core obj

Core object for create, retrieve, update, and delete actions.

required

create(data) -> dict

Create a new resource in custom_fields using the provided data.

Parameters:

Name Type Description Default
data list or dict

Data it can be a dictionary or a list of dictionaries containing the information to create the resource.

required

Examples:

Create a new client:

>>> from netboxcli import Client
>>> nb = Client('http://localhost:8000', 'token')

Create a new resource:

>>> data = {'name': 'resource_name'}
>>> result = nb.customization.custom_fields.create(data)

Returns:

Name Type Description
dict dict

{'status': 200, 'data': {'result': custom_fields]}}

delete(id: int) -> dict

Delete a resource based on its ID.

Parameters:

Name Type Description Default
id int

ID of the resource in custom_fields to delete.

required

Examples:

Create a new client:

>>> from netboxcli import Client
>>> nb = Client('http://localhost:8000', 'token')

Delete a resource by ID:

>>> result = nb.customization.custom_fields.delete(id=1)

Returns:

Type Description
dict

[status_code, response]

get(id: int = None, name: str = None, tags: list = None, search: str = None, filter: str = None, limit: int = 1000) -> dict

Get a resource from the custom_fields on ID, name, tags, or search query.

Parameters:

Name Type Description Default
id int

The ID of the resource to retrieve.

None
name str

The name of the resource to retrieve.

None
tags list

List of tags to filter resources.

None
search str

Search query to filter resources.

None
filter str

Filter query especified by the user in to filter resources.

None
limit int

Maximum number of results to return. Defaults to 1000.

1000

Examples:

Create a new client:

>>> from netboxcli import Client
>>> nb = Client('http://localhost:8000', 'token')

Get a resource by ID:

>>> result = nb.customization.custom_fields.get(id=1)

Get a resource by name:

>>> result = nb.customization.custom_fields.get(name="resource_name")

Get resources by tags:

>>> result = nb.customization.custom_fields.get(tags=["tag1", "tag2"])

Get resources by search query:

>>> result = nb.customization.custom_fields.get(search="query")

Get resources by filter query:

result = nb.customization.custom_fields.get(filter="assigned_to_interface=True")

Get all resources:

>>> result = nb.customization.custom_fields.get()

Returns:

Type Description
dict

Returns a list with a status code and the request data in JSON format: {status: 200, data: {result: [list of custom_fields]}}

update(data: list) -> dict

Update an existing resource in custom_fields with the provided data.

Parameters:

Name Type Description Default
data list

List of dictionaries containing the updated data for the resources.

required

Examples:

Create a new client:

>>> from netboxcli import Client
>>> nb = Client('http://localhost:8000', 'token')

Update a resource by ID:

>>> data = [{'id': 1, 'name': 'new_name'}]
>>> result = nb.customization.custom_fields.update(data)