コード例 #1
0
class ToolsScanagentsApi(object):
    """ Tools Scanagents Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'type': 'type',
        'description': 'description',
        'code': 'code'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_scanagents(self):
        """ get scanagents list """
        uri = 'tools/scanagents/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_scanagent(self, scanagent_id=''):
        """ get scanagent """
        uri = 'tools/scanagents/' + str(scanagent_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_scanagent(self, name='', **kwargs):
        """ add new scanagent """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/scanagents/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_scanagent(self, scanagent_id='', **kwargs):
        """ update scanagent """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/scanagents/' + str(scanagent_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_scanagent(self, scanagent_id=''):
        """ get scanagent """
        uri = 'tools/scanagents/' + str(scanagent_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #2
0
class ToolsNameserversApi(object):
    """ Tools Tags Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'namesrv1': 'namesrv1',
        'description': 'description',
        'sections': 'sections'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_nameservers(self):
        """ get nameserver list """
        uri = 'tools/nameservers/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_nameserver(self, nameserver_id=''):
        """ get nameserver """
        uri = 'tools/nameservers/' + str(nameserver_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_nameserver(self, name='', **kwargs):
        """ add new nameserver """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/nameservers/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_nameserver(self, nameserver_id='', **kwargs):
        """ update nameserver """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/nameservers/' + str(nameserver_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_nameserver(self, nameserver_id=''):
        """ delete nameserver """
        uri = 'tools/nameservers/' + str(nameserver_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #3
0
ファイル: toolsvrfs_api.py プロジェクト: xyrik/phpipamsdk
class ToolsVRFsApi(object):
    """ Tools VRFs Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'rd': 'rd',
        'description': 'description',
        'sections': 'sections'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_vrfs(self):
        """ get vrf list """
        uri = 'tools/vrfs/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_vrf(self, vrf_id=''):
        """ get vrf list """
        uri = 'tools/vrfs/' + str(vrf_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_vrf_subnets(self, vrf_id=''):
        """ get vrf subnet list """
        uri = 'tools/vrfs/' + str(vrf_id) + '/subnets/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_vrf(self, name='', **kwargs):
        """ add new tools vrf """
        payload = {'name': name}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/vrfs/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_vrf(self, vrf_id='', **kwargs):
        """ update tools vrf """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/vrfs/' + str(vrf_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_vrf(self, vrf_id=''):
        """ delete tools vrf """
        uri = 'tools/vrfs/' + str(vrf_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #4
0
class ToolsVlansApi(object):
    """ Tools Vlans Api Class """

    _objmap = {
        'id': 'id',
        'domain_id': 'domainId',
        'name': 'name',
        'number': 'number',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_vlans(self):
        """ get vlan list """
        uri = 'tools/vlans/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_vlan(self, vlan_id=''):
        """ get vlan """
        uri = 'tools/vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_vlan_subnets(self, vlan_id=''):
        """ get vlan subnet list """
        uri = 'tools/vlans/' + str(vlan_id) + '/subnets/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_vlan(self, name='', number='', **kwargs):
        """ add new tools vlan """
        payload = {'name': name, 'number': str(number)}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/vlans/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_vlan(self, vlan_id='', **kwargs):
        """ update tools vlan """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_vlan(self, vlan_id=''):
        """ delete tools vlan """
        uri = 'tools/vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #5
0
class ToolsDeviceTypesApi(object):
    """ Tools Devices Api Class """

    _objmap = {'id': 'id', 'name': 'tname', 'description': 'tdescription'}

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_devicetypes(self):
        """ get device type list """
        uri = 'tools/device_types/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_devicetype_devices(self, devicetype_id=''):
        """ get device type devices """
        uri = 'tools/device_types/' + str(devicetype_id) + '/devices/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_devicetype(self, devicetype_id=''):
        """ get device type """
        uri = 'tools/device_types/' + str(devicetype_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_devicetype(self, name='', **kwargs):
        """ add new devicetype """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/device_types/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_devicetype(self, devicetype_id='', **kwargs):
        """ update devicetype """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/device_types/' + str(devicetype_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_devicetype(self, devicetype_id=''):
        """ delete devicetype """
        uri = 'tools/device_types/' + str(devicetype_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #6
0
class SubnetsApi(object):
    """ Subnets Api Class """

    _objmap = {
        'id': 'id',
        'subnet': 'subnet',
        'mask': 'mask',
        'description': 'description',
        'section_id': 'sectionId',
        'linked_subnet_id': 'linked_subnet',
        'device_id': 'deviceId',
        'vlan_id': 'vlanId',
        'vrf_id': 'vrfId',
        'master_subnet_id': 'masterSubnetId',
        'nameserver_id': 'nameserverId',
        'show_name': 'showName',
        'permissions': 'permissions',
        'resolve_dns': 'resolveDNS',
        'dns_recursive': 'DNSrecursive',
        'dns_records': 'DNSrecords',
        'allow_requests': 'allowRequests',
        'scan_agent_id': 'scanAgent',
        'ping_subnet': 'pingSubnet',
        'discover_subnet': 'discoverSubnet',
        'is_folder': 'isFolder',
        'is_full': 'isFull',
        'tag_id': 'tag',
        'state_id': 'state',
        'threshold': 'threshold',
        'firewall_address_object': 'firewallAddressObject',
        'location_id': 'location'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def get_subnet(self, subnet_id=''):
        """ get subnet details based on ID """
        uri = 'subnets/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_subnet_usage(self, subnet_id=''):
        """ get subnet usage details based on ID """
        uri = 'subnets/' + str(subnet_id) + '/usage/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnet_slaves(self, subnet_id=''):
        """ get subnet slave details based on ID """
        uri = 'subnets/' + str(subnet_id) + '/slaves/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnet_slaves_recursive(self, subnet_id=''):
        """ get subnet recursive salves details based on ID """
        uri = 'subnets/' + str(subnet_id) + '/slaves_recursive/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnet_addresses(self, subnet_id=''):
        """ get list of addresses in subnet """
        uri = 'subnets/' + str(subnet_id) + '/addresses/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_subnet_address(self, subnet_id='', address=''):
        """ get list of addresses in subnet """
        uri = 'subnets/' + str(subnet_id) + '/addresses/' + str(address) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_subnet_first_free_address(self, subnet_id=''):
        """ get first available addresss in subnet """
        uri = 'subnets/' + str(subnet_id) + '/first_free/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_subnet_first_free_subnet(self, subnet_id='', mask=''):
        """ get first available subnet in parent subnet """
        uri = 'subnets/' + str(subnet_id) + '/first_subnet/' + str(mask) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_subnet_last_free_subnet(self, subnet_id='', mask=''):
        """ get last available subnet in parent subnet """
        uri = 'subnets/' + str(subnet_id) + '/last_subnet/' + str(mask) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnet_free_subnets(self, subnet_id='', mask=''):
        """ list available subnet in parent subnet """
        uri = 'subnets/' + str(subnet_id) + '/all_subnets/' + str(mask) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnet_custom_fields(self):
        """ list subnet custom fields """
        uri = 'subnets/custom_fields/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_subnets_cidr(self, subnet_cidr=''):
        """ lists subnets based on CIDR notation """
        uri = 'subnets/cidr/' + subnet_cidr + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_subnets_cidr(self, subnet_cidr=''):
        """ searches for subnets based on CIDR notation """
        uri = 'subnets/search/' + subnet_cidr + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_subnets_overlapping(self, subnet_cidr=''):
        """ searches for overlapping subnets based on CIDR notation """
        uri = 'subnets/overlapping/' + subnet_cidr + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_subnet(self, subnet='', mask='', **kwargs):
        """ add new subnet """
        payload = {'subnet': subnet, 'mask': mask}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'subnets/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def add_subnet_first_free(self, subnet_id='', mask='', **kwargs):
        """ add first free subnet under parent subnet """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'subnets/' + str(subnet_id) + '/first_subnet/' + str(mask) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def add_subnet_last_free(self, subnet_id='', mask='', **kwargs):
        """ add last free subnet under parent subnet """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'subnets/' + str(subnet_id) + '/last_subnet/' + str(mask) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_subnet(self, subnet_id='', **kwargs):
        """ update subnet """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'subnets/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def resize_subnet(self, subnet_id='', mask=''):
        """ update subnet """
        payload = {'mask': mask}
        uri = 'subnets/' + str(subnet_id) + '/resize/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def split_subnet(self, subnet_id='', mask=''):
        """ update subnet """
        payload = {'mask': mask}
        uri = 'subnets/' + str(subnet_id) + '/split/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def update_subnet_permissions(self, subnet_id='', permissions=''):
        """ update subnet """
        payload = {'permissions': permissions}
        uri = 'subnets/' + str(subnet_id) + '/permissions/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_subnet(self, subnet_id=''):
        """ delete subnet """
        uri = 'subnets/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result

    def del_subnet_addresses(self, subnet_id=''):
        """ delete subnet addresses """
        uri = 'subnets/' + str(subnet_id) + '/truncate/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result

    def del_subnet_permissions(self, subnet_id=''):
        """ delete subnet permissions """
        uri = 'subnets/' + str(subnet_id) + '/permissions/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #7
0
class ToolsNATApi(object):
    """ Tools NAT Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'type': 'type',
        'device_id': 'device',
        'src': 'src',
        'src_port': 'src_port',
        'dst': 'dst',
        'dst_port': 'dst_port',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_nats(self):
        """ get nat list """
        uri = 'tools/nat/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_nat(self, nat_id=''):
        """ get nat """
        uri = 'tools/nat/' + str(nat_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_nat_objects(self, nat_id=''):
        """ get nats device list """
        uri = 'tools/nat/' + str(nat_id) + '/objects/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_nat_objects_full(self, nat_id=''):
        """ get nats device list """
        uri = 'tools/nat/' + str(nat_id) + '/objects_full/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_nat(self, name='', **kwargs):
        """ add new nat """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/nat/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_nat(self, nat_id='', **kwargs):
        """ update nat """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/nat/' + str(nat_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_nat(self, nat_id=''):
        """ delete nat """
        uri = 'tools/nat/' + str(nat_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #8
0
class ToolsCustomersApi(object):
    """ Tools Customers Api Class """

    _objmap = {
        'id': 'id',
        'title': 'title',
        'address': 'address',
        'postcode': 'postcode',
        'city': 'city',
        'tag': 'tag',
        'lat': 'lat',
        'long': 'long',
        'contact_person': 'contact_person',
        'contact_phone': 'contact_phone',
        'contact_mail': 'contact_mail',
        'note': 'note',
        'status': 'status'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_customers(self):
        """ get customers list """
        uri = 'tools/customers/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_customer(self, customer_id=''):
        """ get customer """
        uri = 'tools/customers/' + str(customer_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_customer(self, title='', **kwargs):
        """ add new customer """
        payload = {
            'title': title,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/customers/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_customer(self, customer_id='', **kwargs):
        """ update customer """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/customers/' + str(customer_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_customer(self, customer_id=''):
        """ delete customer """
        uri = 'tools/customers/' + str(customer_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #9
0
class AddressesApi(object):
    """ Addresses Api Class """

    _objmap = {
        'id': 'id',
        'subnet_id': 'subnetId',
        'ip': 'ip',
        'is_gateway': 'is_gateway',
        'description': 'description',
        'hostname': 'hostname',
        'mac': 'mac',
        'owner': 'owner',
        'tag_id': 'tag',
        'ptr_ignore': 'PTRignore',
        'ptr_id': 'PTR',
        'device_id': 'deviceId',
        'port': 'port',
        'note': 'note',
        'location_id': 'location_id',
        'firewall_address_object': 'firewallAddressObject',
        'exclude_ping': 'excludePing'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def get_address(self, address_id=''):
        """ get IP address """
        uri = 'addresses/' + str(address_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def ping_address(self, address_id=''):
        """ ping IP address """
        uri = 'addresses/' + str(address_id) + '/ping/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_address_from_subnet(self, address='', subnet_id=''):
        """ get IP address from subnet """
        uri = 'addresses/' + str(address) + '/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_address(self, address=''):
        """ search IP address """
        uri = 'addresses/search/' + str(address) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_address_mac(self, mac=''):
        """ search IP address by MAC """
        uri = 'addresses/search_mac/' + str(mac) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_address_linked(self, linked=''):
        """ search IP address by linked_field """
        uri = 'addresses/search_linked/' + str(linked) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_hostname(self, hostname=''):
        """ search for hostname """
        uri = 'addresses/search/' + str(hostname) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_address_first_free(self, subnet_id=''):
        """ get first available address from subnet """
        uri = 'addresses/first_free/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_address_custom_fields(self):
        """ list address custom fields """
        uri = 'addresses/custom_fields/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_address_tags(self):
        """ list address tags """
        uri = 'addresses/tags/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_address_tag(self, tag_id=''):
        """ get specific tag """
        uri = 'addresses/tags/' + str(tag_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_addresses_tag(self, tag_id=''):
        """ list addresses for tag """
        uri = 'addresses/tags/' + str(tag_id) + '/addresses/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_address(self, subnet_id='', ip_addr='', **kwargs):
        """ add IP address """
        payload = {'subnetId': str(subnet_id), 'ip': ip_addr}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'addresses/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def add_address_first_free(self, subnet_id='', **kwargs):
        """ add first free IP address """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'addresses/first_free/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_address(self, address_id='', **kwargs):
        """ update IP address """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'addresses/' + str(address_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_address(self, address_id='', **kwargs):
        """ delete IP address """
        payload = {}
        if 'remove_dns' in kwargs:
            payload['remove_dns'] = kwargs['remove_dns']
        uri = 'addresses/' + str(address_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='delete',
                                               payload=payload)
        return result

    def del_address_subnet(self, address='', subnet_id=''):
        """ delete IP address from subnet """
        uri = 'addresses/' + str(address) + '/' + str(subnet_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #10
0
class SectionsApi(object):
    """ Sections Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'description': 'description',
        'master_section_id': 'masterSection',
        'permissions': 'permissions',
        'strict_mode': 'strictMode',
        'subnet_ordering': 'subnetOrdering',
        'order': 'order',
        'show_vlan': 'showVLAN',
        'show_vrf': 'showVRF',
        'show_supernet_only': 'showSupernetOnly',
        'dns_id': 'DNS'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_sections(self):
        """ get section list """
        uri = 'sections/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_section_subnets(self, section_id=''):
        """ get section subnet list """
        uri = 'sections/' + section_id + '/subnets/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_section_custom_fields(self):
        """ get custom fields list """
        uri = 'sections/custom_fields/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_section(self, section=''):
        """ get section by name or id """
        uri = 'sections/' + str(section) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_section(self, name='', **kwargs):
        """ add new section """
        payload = {
            'name': name
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'sections/'
        result = self.phpipam.api_send_request(
            path=uri, method='post', payload=payload)
        return result

    def update_section(self, section_id='', **kwargs):
        """ update section """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'sections/' + str(section_id) + '/'
        result = self.phpipam.api_send_request(
            path=uri, method='patch', payload=payload)
        return result

    def del_section(self, section_id=''):
        """ delete section """
        uri = 'sections/' + str(section_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #11
0
 def __init__(self, phpipam=None):
     """ vlans constructor """
     if phpipam:
         self.phpipam = phpipam
     else:
         self.phpipam = PhpIpamApi()
コード例 #12
0
class ToolsLocationsApi(object):
    """ Tools Locations Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'address': 'address',
        'lat': 'lat',
        'long': 'long',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_locations(self):
        """ get locations list """
        uri = 'tools/locations/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_location(self, location_id=''):
        """ get location """
        uri = 'tools/locations/' + str(location_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_location_subnets(self, location_id=''):
        """ get locations subnets list """
        uri = 'tools/locations/' + str(location_id) + '/subnets/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_location_devices(self, location_id=''):
        """ get locations device list """
        uri = 'tools/locations/' + str(location_id) + '/devices/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_location_racks(self, location_id=''):
        """ get locations rack list """
        uri = 'tools/locations/' + str(location_id) + '/racks/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_location(self, name='', **kwargs):
        """ add new location """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/locations/'
        result = self.phpipam.api_send_request(
            path=uri, method='post', payload=payload)
        return result

    def update_tools_location(self, location_id='', **kwargs):
        """ update location """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/locations/' + str(location_id) + '/'
        result = self.phpipam.api_send_request(
            path=uri, method='patch', payload=payload)
        return result

    def del_tools_location(self, location_id=''):
        """ delete location """
        uri = 'tools/locations/' + str(location_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #13
0
class L2DomainsApi(object):
    """ L2Domains Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'description': 'description',
        'sections': 'sections'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_l2domains(self):
        """ get l2domain list """
        uri = 'l2domains/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_l2domain(self, domain_id=''):
        """ get l2domain """
        uri = 'l2domains/' + str(domain_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_l2domain_vlans(self, domain_id=''):
        """ get l2domain vlans """
        uri = 'l2domains/' + str(domain_id) + '/vlans/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_l2domain_custom_fields(self):
        """ get l2domain custom fields """
        uri = 'l2domains/custom_fields/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_l2domain(self, name='', **kwargs):
        """ add new l2domain """
        payload = {
            'name': name
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'l2domains/'
        result = self.phpipam.api_send_request(
            path=uri, method='post', payload=payload)
        return result

    def update_l2domain(self, domain_id='', **kwargs):
        """ update l2domain """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'l2domains/' + str(domain_id) + '/'
        result = self.phpipam.api_send_request(
            path=uri, method='patch', payload=payload)
        return result

    def del_l2domain(self, l2domain_id=''):
        """ delete l2domain """
        uri = 'l2domains/' + str(l2domain_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #14
0
ファイル: prefixes_api.py プロジェクト: xyrik/phpipamsdk
class PrefixesApi(object):
    """ Tools Prefixes Api Class """

    _objmap = {
        'id': 'id',
        'subnet': 'subnet',
        'mask': 'mask',
        'description': 'description',
        'section_id': 'sectionId',
        'linked_subnet_id': 'linked_subnet',
        'vlan_id': 'vlanId',
        'vrf_id': 'vrfId',
        'master_subnet_id': 'masterSubnetId',
        'nameserver_id': 'nameserverId',
        'show_name': 'showName',
        'permissions': 'permissions',
        'dns_recursive': 'DNSrecursive',
        'dns_records': 'DNSrecords',
        'allow_requests': 'allowRequests',
        'scan_agent_id': 'scanAgent',
        'ping_subnet': 'pingSubnet',
        'discover_subnet': 'discoverSubnet',
        'is_folder': 'isFolder',
        'is_full': 'isFull',
        'state_id': 'state',
        'threshold': 'threshold',
        'location_id': 'location',
        'subnet_id': 'subnetId',
        'ip': 'ip',
        'is_gateway': 'is_gateway',
        'mac': 'mac',
        'owner': 'owner',
        'tag_id': 'tag',
        'ptr_ignore': 'PTRignore',
        'ptr_id': 'PTR',
        'device_id': 'deviceId',
        'port': 'port',
        'note': 'note',
        'exclude_ping': 'excludePing'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_prefixes_subnets(self, customer_type=''):
        """ get subnets list used to deliver new subnets """
        uri = 'prefix/' + str(customer_type) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_prefixes_subnets_version(self, customer_type='', ip_version=''):
        """ get subnets list used to deliver new subnets by version """
        uri = ('prefix/' + str(customer_type) + '/' + str(ip_version) + '/')
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_prefixes_address(self, customer_type=''):
        """ get subnets list used to deliver new address """
        uri = 'prefix/' + str(customer_type) + '/address/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_prefixes_address_version(self, customer_type='', ip_version=''):
        """ get subnets list used to deliver new address by version """
        uri = ('prefix/' + str(customer_type) + '/address/' + str(ip_version) +
               '/')
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_prefixes_first_free_subnet(self,
                                       customer_type='',
                                       ip_version='',
                                       mask=''):
        """ get first available subnet """
        uri = ('prefix/' + str(customer_type) + '/' + str(ip_version) + '/' +
               str(mask) + '/')
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_prefixes_first_free_address(self, customer_type='', ip_version=''):
        """ get first available address """
        uri = ('prefix/' + str(customer_type) + '/' + str(ip_version) +
               '/address/')
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_prefixes_first_free_subnet(self,
                                       customer_type='',
                                       ip_version='',
                                       mask='',
                                       **kwargs):
        """ add first available subnet """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = ('prefix/' + str(customer_type) + '/' + str(ip_version) + '/' +
               str(mask) + '/')
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def add_prefixes_first_free_address(self,
                                        customer_type='',
                                        ip_version='',
                                        **kwargs):
        """ add first available subnet """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = ('prefix/' + str(customer_type) + '/' + str(ip_version) +
               '/address/')
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result
コード例 #15
0
 def __init__(self, phpipam=None):
     if phpipam:
         self.phpipam = phpipam
     else:
         self.phpipam = PhpIpamApi()
コード例 #16
0
class VlansApi(object):
    """ Vlans Api Class """

    _objmap = {
        'id': 'id',
        'domain_id': 'domainId',
        'name': 'name',
        'number': 'number',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        """ vlans constructor """
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_vlans(self):
        """ list vlans """
        uri = 'vlans/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_vlan(self, vlan_id=''):
        """ list vlans """
        uri = 'vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_vlan_subnets(self, vlan_id=''):
        """ list vlan subnets """
        uri = 'vlans/' + str(vlan_id) + '/subnets/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_vlan_subnets_section(self, vlan_id='', section_id=''):
        """ list vlan subnets section """
        uri = 'vlans/' + str(vlan_id) + '/subnets/' + str(section_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_vlan_custom_fields(self):
        """ list vlan custom fields """
        uri = 'vlans/custom_fields/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def search_vlans(self, vlan_id='', vlan=''):
        """ search vlans """
        uri = 'vlans/' + str(vlan_id) + '/search/' + str(vlan) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_vlan(self, name='', number='', **kwargs):
        """ add new vlan """
        payload = {'name': name, 'number': str(number)}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'vlans/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_vlan(self, vlan_id='', **kwargs):
        """ update vlan """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_vlan(self, vlan_id=''):
        """ delete vlan """
        uri = 'vlans/' + str(vlan_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #17
0
class ToolsRacksApi(object):
    """ Tools Racks Api Class """

    _objmap = {
        'id': 'id',
        'name': 'name',
        'location_id': 'location',
        'size': 'size',
        'row': 'row',
        'has_back': 'hasBack',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_racks(self):
        """ get racks list """
        uri = 'tools/racks/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_rack(self, rack_id=''):
        """ get racks list """
        uri = 'tools/racks/' + str(rack_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def list_tools_rack_devices(self, rack_id=''):
        """ get racks device list """
        uri = 'tools/racks/' + str(rack_id) + '/devices/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_rack(self, name='', **kwargs):
        """ add new rack """
        payload = {
            'name': name,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/racks/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='post',
                                               payload=payload)
        return result

    def update_tools_rack(self, rack_id='', **kwargs):
        """ update rack """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/racks/' + str(rack_id) + '/'
        result = self.phpipam.api_send_request(path=uri,
                                               method='patch',
                                               payload=payload)
        return result

    def del_tools_rack(self, rack_id=''):
        """ get rack """
        uri = 'tools/racks/' + str(rack_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result
コード例 #18
0
ファイル: toolsdevices_api.py プロジェクト: xyrik/phpipamsdk
class ToolsDevicesApi(object):
    """ Tools Devices Api Class """

    _objmap = {
        'id': 'id',
        'hostname': 'hostname',
        'ip_addr': 'ip_addr',
        'ip': 'ip',
        'type_id': 'type',
        'vendor': 'vendor',
        'model': 'model',
        'sections': 'sections',
        'location_id': 'location',
        'rack_id': 'rack',
        'rack_size': 'rack_size',
        'rack_start': 'rack_start',
        'snmp_community': 'snmp_community',
        'snmp_port': 'snmp_port',
        'snmp_queries': 'snmp_queries',
        'snmp_timeout': 'snmp_timeout',
        'snmp_version': 'snmp_version',
        'snmp_v3_auth_protocol': 'snmp_v3_auth_protocol',
        'snmp_v3_auth_pass': '******',
        'snmp_v3_priv_protocol': 'snmp_v3_priv_protocol',
        'snmp_v3_priv_pass': '******',
        'snmp_v3_ctx_name': 'snmp_v3_ctx_name',
        'snmp_v3_ctx_engine_id': 'snmp_v3_ctx_engine_id',
        'description': 'description'
    }

    def __init__(self, phpipam=None):
        if phpipam:
            self.phpipam = phpipam
        else:
            self.phpipam = PhpIpamApi()

    def list_tools_devices(self):
        """ get device list """
        uri = 'tools/devices/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def get_tools_device(self, device_id=''):
        """ get device  """
        uri = 'tools/devices/' + str(device_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='get')
        return result

    def add_tools_device(self, hostname='', **kwargs):
        """ add new device """
        payload = {
            'hostname': hostname,
        }
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/devices/'
        result = self.phpipam.api_send_request(
            path=uri, method='post', payload=payload)
        return result

    def update_tools_device(self, device_id='', **kwargs):
        """ update device """
        payload = {}
        payload.update(build_payload(self._objmap, **kwargs))
        uri = 'tools/devices/' + str(device_id) + '/'
        result = self.phpipam.api_send_request(
            path=uri, method='patch', payload=payload)
        return result

    def del_tools_device(self, device_id=''):
        """ delete device """
        uri = 'tools/devices/' + str(device_id) + '/'
        result = self.phpipam.api_send_request(path=uri, method='delete')
        return result