Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pynetbox/core/__pycache__/endpoint.cpython-39.pyc
Ðазад
a n�h�O � @ s\ d Z ddlmZmZ ddlmZmZ dZG dd� de�Z G dd� de�Z G d d � d e �ZdS )a" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. � )�Request�RequestError)�Record� RecordSet� c @ sd e Zd ZdZddd�Zdd� Zddd �Zd d� Zdd � Zdd� Z dd� Z dd� Zdd� Zdd� Z dS )�Endpointa� Represent actions available on endpoints in the Netbox API. Takes ``name`` and ``app`` passed from App() and builds the correct url to make queries to and the proper Response object to return results in. :arg obj api: Takes :py:class:`.Api` created at instantiation. :arg obj app: Takes :py:class:`.App`. :arg str name: Name of endpoint passed to App(). :arg obj,optional model: Custom model for given app. .. note:: In order to call NetBox endpoints with dashes in their names you should convert the dash to an underscore. (E.g. querying the ip-addresses endpoint is done with ``nb.ipam.ip_addresses.all()``.) Nc C s\ | � ||�| _|�dd�| _|| _|j| _|j| _|j| _dj| j|j| jd�| _ d | _ d S )N�_�-z{base_url}/{app}/{endpoint})�base_url�app�endpoint)�_lookup_ret_obj� return_obj�replace�name�apir �token�session_key�format�url�_choices)�selfr r r �modelr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pynetbox/core/endpoint.py�__init__+ s �zEndpoint.__init__c C s* |r"|� � �dd�}t||t�}nt}|S )aS Loads unique Response objects. This method loads a unique response object for an endpoint if it exists. Otherwise return a generic `Record` object. :arg str name: Endpoint name. :arg obj model: The application model that contains unique Record objects. :Returns: Record (obj) r � )�titler �getattrr )r r r �retr r r r 7 s zEndpoint._lookup_ret_objr c C sL |dkr|durt d��td�| j�| j| j| jj| jj||d�}t | |�S )a Queries the 'ListView' of a given endpoint. Returns all objects from an endpoint. :arg int,optional limit: Overrides the max page size on paginated returns. :arg int,optional offset: Overrides the offset on paginated returns. :Returns: A :py:class:`.RecordSet` object. :Examples: >>> devices = nb.dcim.devices.all() >>> for device in devices: ... print(device.name) ... test1-leaf1 test1-leaf2 test1-leaf3 >>> r N�&offset requires a positive limit valuez{}/)�baser r �http_session� threading�limit�offset) � ValueErrorr r r r r r r! r"