Skip to content

Commit 94ae9d6

Browse files
authored
v1.0.10 (#65)
# 1.0.10 [2022-02-19] ## Fixed * incorrect api endpoint for object.dynamicobject (#57, #64). thanks @dheule for providing a fix * missing refs in devicerecord for physicalinterface (#61) * incorrect api endpoint for object.continent (#60) * uuid check issues with object.applicationcategory (#59) * removed incorrect delete calls for device.devicerecord.redundantinterface * removed incorrect delete calls for device.devicerecord.subinterface * removed incorrect delete calls for device.devicerecord.virtualswitch * removed incorrect delete calls for device.devicerecord.virtualtunnelinterface * removed incorrect delete calls for device.devicerecord.vlaninterface
1 parent 01e3290 commit 94ae9d6

File tree

224 files changed

+925
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+925
-521
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 1.0.10 [2022-02-19]
2+
3+
## Fixed
4+
5+
* incorrect api endpoint for object.dynamicobject (#57, #64). thanks @dheule for providing a fix
6+
* missing refs in devicerecord for physicalinterface (#61)
7+
* incorrect api endpoint for object.continent (#60)
8+
* uuid check issues with object.applicationcategory (#59)
9+
* removed incorrect delete calls for device.devicerecord.redundantinterface
10+
* removed incorrect delete calls for device.devicerecord.subinterface
11+
* removed incorrect delete calls for device.devicerecord.virtualswitch
12+
* removed incorrect delete calls for device.devicerecord.virtualtunnelinterface
13+
* removed incorrect delete calls for device.devicerecord.vlaninterface
14+
115
# 1.0.9 [2021-10-19]
216

317
## Fixed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tox = ">=3.14.6"
3131
twine = ">=3.1.1"
3232

3333
[requires]
34-
python_version = "3.8"
34+
python_version = "3.10"
3535

3636
[pipenv]
3737
allow_prereleases = true

fireREST/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from fireREST.fmc.deployment import Deployment
1212
from fireREST.fmc.device import Device
1313
from fireREST.fmc.devicecluster import DeviceCluster
14-
from fireREST.fmc.devicehapair import DeviceHAPair
1514
from fireREST.fmc.devicegroup import DeviceGroup
15+
from fireREST.fmc.devicehapair import DeviceHAPair
1616
from fireREST.fmc.health import Health
1717
from fireREST.fmc.integration import Integration
1818
from fireREST.fmc.intelligence import Intelligence
@@ -23,7 +23,6 @@
2323
from fireREST.fmc.update import Update
2424
from fireREST.fmc.user import User
2525

26-
2726
logger = logging.getLogger(__name__)
2827
logger.addHandler(logging.NullHandler())
2928

fireREST/defaults.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
API_RELEASE_650 = '6.5.0'
5858
API_RELEASE_660 = '6.6.0'
5959
API_RELEASE_670 = '6.7.0'
60+
API_RELEASE_700 = '7.0.0'
61+
API_RELEASE_710 = '7.1.0'
6062

6163
# Execute PUT,POST and DELETE operations by default. Change this switch to only log and not execute requests
6264
DRY_RUN = False

fireREST/fmc/__init__.py

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import json
44
import logging
5-
import simplejson
65
from http.client import responses as http_responses
76
from typing import Dict, Union
87
from urllib.parse import urlencode
98

109
import requests
10+
import simplejson
1111
import urllib3
1212
from packaging import version
1313
from requests.auth import HTTPBasicAuth
@@ -476,7 +476,7 @@ def update(self, data: Dict, container_uuid=None, container_name=None, params=No
476476
:rtype: requests.Response
477477
"""
478478
url = self.url(self.PATH.format(container_uuid=container_uuid, uuid=data['id']))
479-
return self.conn.put(url, data, self.IGNORE_FOR_UPDATE)
479+
return self.conn.put(url, data, params, self.IGNORE_FOR_UPDATE)
480480

481481
@utils.resolve_by_name
482482
@utils.minimum_version_required
@@ -497,3 +497,121 @@ def delete(self, container_uuid=None, container_name=None, uuid=None, name=None)
497497
"""
498498
url = self.url(self.PATH.format(container_uuid=container_uuid, uuid=uuid))
499499
return self.conn.delete(url)
500+
501+
502+
class NestedChildResource(ChildResource):
503+
"""Base class for api resources located within a ChildResource"""
504+
505+
# name of container class that hosts the VrfResource
506+
CHILD_CONTAINER_NAME = ''
507+
508+
# path to container class that hosts the VrfResource
509+
CHILD_CONTAINER_PATH = ''
510+
511+
@utils.resolve_by_name
512+
@utils.minimum_version_required
513+
def create(self, data: Union[dict, list], container_uuid=None, container_name=None,
514+
child_container_name=None, child_container_uuid=None, params=None):
515+
"""Create api resource. Either name or uuid for container and child_container must be provided
516+
to create the resource within the provided scope
517+
518+
:param data: data that will be sent to the api endpoint
519+
:type data: Union[list, dict], optional
520+
:param container_uuid: uuid of container resource
521+
:type container_uuid: str, optional
522+
:param container_name: name of container resource
523+
:type container_name: str, optional
524+
:param child_container_uuid: uuid of child container resource
525+
:type child_container_uuid: str, optional
526+
:param child_container_name: name of child container resource
527+
:type child_container_name: str, optional
528+
:param params: dict of parameters for http request
529+
:type params: dict, optional
530+
:return: api response
531+
:rtype: requests.Response
532+
"""
533+
url = self.url(self.PATH.format(container_uuid=container_uuid, child_container_uuid=child_container_uuid,
534+
uuid=None))
535+
return self.conn.post(url, data, params, self.IGNORE_FOR_CREATE)
536+
537+
@utils.resolve_by_name
538+
@utils.minimum_version_required
539+
def get(self, container_uuid=None, container_name=None, child_container_name=None, child_container_uuid=None,
540+
uuid=None, name=None, params=None):
541+
"""Get api resource in json format. Either name or uuid of container resource must
542+
be provided to search for resources within the container scope
543+
If no name or uuid is provided a list of all available resources will be returned
544+
545+
:param container_uuid: uuid of container resource
546+
:type container_uuid: str, optional
547+
:param container_name: name of container resource
548+
:type container_name: str, optional
549+
:param child_container_uuid: uuid of child container resource
550+
:type child_container_uuid: str, optional
551+
:param child_container_name: name of child container resource
552+
:type child_container_name: str, optional
553+
:param uuid: id of resource
554+
:type uuid: str, optional
555+
:param name: name of resource
556+
:type name: str, optional
557+
:param params: dict of parameters for http request
558+
:type params: dict, optional
559+
:return: api response
560+
:rtype: Union[dict, list]
561+
"""
562+
url = self.url(self.PATH.format(container_uuid=container_uuid, child_container_uuid=child_container_uuid,
563+
uuid=uuid))
564+
return self.conn.get(url, params)
565+
566+
@utils.resolve_by_name
567+
@utils.minimum_version_required
568+
def update(self, data: Dict, container_uuid=None, container_name=None,
569+
child_container_name=None, child_container_uuid=None, params=None):
570+
"""Update existing api resource. Either name or uuid of container resource must be provided
571+
Existing data will be overridden with the provided payload. The request will be routed
572+
to the correct resource by extracting the `id` within the payload
573+
574+
:param data: data that will be sent to the api endpoint
575+
:type data: Union[list, dict], optional
576+
:param container_uuid: uuid of container resource
577+
:type container_uuid: str, optional
578+
:param container_name: name of container resource
579+
:type container_name: str, optional
580+
:param child_container_uuid: uuid of child container resource
581+
:type child_container_uuid: str, optional
582+
:param child_container_name: name of child container resource
583+
:type child_container_name: str, optional
584+
:param params: dict of parameters for http request
585+
:type params: dict, optional
586+
:return: api response
587+
:rtype: requests.Response
588+
"""
589+
url = self.url(self.PATH.format(container_uuid=container_uuid, child_container_uuid=child_container_uuid,
590+
uuid=data['id']))
591+
return self.conn.put(url, data, self.IGNORE_FOR_UPDATE)
592+
593+
@utils.resolve_by_name
594+
@utils.minimum_version_required
595+
def delete(self, container_uuid=None, container_name=None, child_container_name=None, child_container_uuid=None,
596+
uuid=None, name=None):
597+
"""Delete existing api resource. Either name or uuid of container resource must be provided
598+
Either `name` or `uuid` must be provided to delete an existing resource
599+
600+
:param container_uuid: uuid of container resource
601+
:type container_uuid: str, optional
602+
:param container_name: name of container resource
603+
:type container_name: str, optional
604+
:param child_container_uuid: uuid of child container resource
605+
:type child_container_uuid: str, optional
606+
:param child_container_name: name of child container resource
607+
:type child_container_name: str, optional
608+
:param uuid: id of resource
609+
:type uuid: str, optional
610+
:param name: name of resource
611+
:type name: str, optional
612+
:return: api response
613+
:rtype: requests.Response
614+
"""
615+
url = self.url(self.PATH.format(container_uuid=container_uuid, child_container_uuid=child_container_uuid,
616+
uuid=uuid))
617+
return self.conn.delete(url)
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import Resource
23

34

45
class PolicyAssignment(Resource):
56
PATH = '/assignment/policyassignments/{uuid}'
67
IGNORE_FOR_UPDATE = []
7-
MINIMUM_VERSION_REQUIRED_CREATE = '6.1.0'
8-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
9-
MINIMUM_VERSION_REQUIRED_UPDATE = '6.1.0'
10-
MINIMUM_VERSION_REQUIRED_DELETE = '6.1.0'
8+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_610
9+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610
10+
MINIMUM_VERSION_REQUIRED_UPDATE = API_RELEASE_610
11+
MINIMUM_VERSION_REQUIRED_DELETE = API_RELEASE_610
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import Resource
23

34

45
class AuditRecord(Resource):
56
PATH = '/audit/auditrecords/{uuid}'
67
IGNORE_FOR_UPDATE = []
7-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
8+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610

fireREST/fmc/deployment/deployabledevice/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import Connection, Resource
23
from fireREST.fmc.deployment.deployabledevice.deployment import Deployment
34
from fireREST.fmc.deployment.deployabledevice.pendingchanges import PendingChanges
@@ -7,7 +8,7 @@ class DeployableDevice(Resource):
78
PATH = '/deployment/deployabledevices/{uuid}'
89
SUPPORTED_PARAMS = ['group_dependency']
910
IGNORE_FOR_UPDATE = []
10-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
11+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610
1112

1213
def __init__(self, conn: Connection):
1314
self.deployment = Deployment(conn)
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from typing import Union
2-
3-
from fireREST import utils
1+
from fireREST.defaults import API_RELEASE_660
42
from fireREST.fmc import ChildResource
53

64

@@ -12,4 +10,4 @@ class Deployment(ChildResource):
1210
SUPPORTED_PARAMS = []
1311
IGNORE_FOR_CREATE = []
1412
IGNORE_FOR_UPDATE = []
15-
MINIMUM_VERSION_REQUIRED_GET = '6.6.0'
13+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_660

fireREST/fmc/deployment/deployabledevice/pendingchanges/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from fireREST.defaults import API_RELEASE_660
12
from fireREST.fmc import ChildResource
23

34

@@ -9,4 +10,4 @@ class PendingChanges(ChildResource):
910
SUPPORTED_PARAMS = []
1011
IGNORE_FOR_CREATE = []
1112
IGNORE_FOR_UPDATE = []
12-
MINIMUM_VERSION_REQUIRED_GET = '6.6.0'
13+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_660
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import Resource
23

34

45
class DeploymentRequest(Resource):
56
PATH = '/deployment/deploymentrequests/{uuid}'
6-
MINIMUM_VERSION_REQUIRED_CREATE = '6.1.0'
7+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_610
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from fireREST.defaults import API_RELEASE_670
12
from fireREST.fmc import Resource
23

34

45
class JobHistory(Resource):
56
PATH = '/deployment/jobhistories/{uuid}'
67
SUPPORTED_FILTERS = ['device_uuid']
78
IGNORE_FOR_UPDATE = []
8-
MINIMUM_VERSION_REQUIRED_GET = '6.7.0'
9+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_670
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from fireREST.defaults import API_RELEASE_670
12
from fireREST.fmc import Resource
23

34

45
class RollbackRequest(Resource):
56
PATH = '/deployment/rollbackrequests/{uuid}'
67
IGNORE_FOR_UPDATE = []
7-
MINIMUM_VERSION_REQUIRED_CREATE = '6.7.0'
8+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_670

fireREST/fmc/device/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Dict
22

33
from fireREST import utils
4+
from fireREST.defaults import API_RELEASE_630
45
from fireREST.fmc import Connection, Resource
56
from fireREST.fmc.device.devicerecord import DeviceRecord
67

@@ -11,7 +12,7 @@ def __init__(self, conn: Connection):
1112

1213
self.devicerecord = DeviceRecord(conn)
1314

14-
@utils.minimum_version_required(version='6.3.0')
15+
@utils.minimum_version_required(version=API_RELEASE_630)
1516
def copyconfigrequest(self, data: Dict):
1617
url = self.url(path='/devices/copyconfigrequests')
1718
return self.conn.post(url=url, data=data)

fireREST/fmc/device/devicerecord/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import Connection, Resource
23
from fireREST.fmc.device.devicerecord.bridgegroupinterface import BridgeGroupInterface
34
from fireREST.fmc.device.devicerecord.etherchannelinterface import EtherChannelInterface
@@ -7,6 +8,7 @@
78
from fireREST.fmc.device.devicerecord.inlineset import InlineSet
89
from fireREST.fmc.device.devicerecord.interfaceevent import InterfaceEvent
910
from fireREST.fmc.device.devicerecord.operational import Operational
11+
from fireREST.fmc.device.devicerecord.physicalinterface import PhysicalInterface
1012
from fireREST.fmc.device.devicerecord.redundantinterface import RedundantInterface
1113
from fireREST.fmc.device.devicerecord.routing import Routing
1214
from fireREST.fmc.device.devicerecord.subinterface import SubInterface
@@ -17,10 +19,10 @@
1719

1820
class DeviceRecord(Resource):
1921
PATH = '/devices/devicerecords/{uuid}'
20-
MINIMUM_VERSION_REQUIRED_CREATE = '6.1.0'
21-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
22-
MINIMUM_VERSION_REQUIRED_UPDATE = '6.1.0'
23-
MINIMUM_VERSION_REQUIRED_DELETE = '6.1.0'
22+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_610
23+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610
24+
MINIMUM_VERSION_REQUIRED_UPDATE = API_RELEASE_610
25+
MINIMUM_VERSION_REQUIRED_DELETE = API_RELEASE_610
2426
SUPPORTED_PARAMS = ['hostname']
2527

2628
def __init__(self, conn: Connection):
@@ -34,6 +36,7 @@ def __init__(self, conn: Connection):
3436
self.inlineset = InlineSet(conn)
3537
self.interfaceevent = InterfaceEvent(conn)
3638
self.operational = Operational(conn)
39+
self.physicalinterface = PhysicalInterface(conn)
3740
self.redundantinterface = RedundantInterface(conn)
3841
self.routing = Routing(conn)
3942
self.subinterface = SubInterface(conn)
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import ChildResource
23

34

45
class BridgeGroupInterface(ChildResource):
56
CONTAINER_NAME = 'DeviceRecord'
67
CONTAINER_PATH = '/devices/devicerecords/{uuid}'
78
PATH = '/devices/devicerecords/{container_uuid}/bridgegroupinterfaces/{uuid}'
8-
MINIMUM_VERSION_REQUIRED_CREATE = '6.1.0'
9-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
10-
MINIMUM_VERSION_REQUIRED_UPDATE = '6.1.0'
11-
MINIMUM_VERSION_REQUIRED_DELETE = '6.1.0'
9+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_610
10+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610
11+
MINIMUM_VERSION_REQUIRED_UPDATE = API_RELEASE_610
12+
MINIMUM_VERSION_REQUIRED_DELETE = API_RELEASE_610
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import ChildResource
23

34

45
class EtherChannelInterface(ChildResource):
56
CONTAINER_NAME = 'DeviceRecord'
67
CONTAINER_PATH = '/devices/devicerecords/{uuid}'
78
PATH = '/devices/devicerecords/{container_uuid}/etherchannelinterfaces/{uuid}'
8-
MINIMUM_VERSION_REQUIRED_CREATE = '6.1.0'
9-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
10-
MINIMUM_VERSION_REQUIRED_UPDATE = '6.1.0'
11-
MINIMUM_VERSION_REQUIRED_DELETE = '6.1.0'
9+
MINIMUM_VERSION_REQUIRED_CREATE = API_RELEASE_610
10+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610
11+
MINIMUM_VERSION_REQUIRED_UPDATE = API_RELEASE_610
12+
MINIMUM_VERSION_REQUIRED_DELETE = API_RELEASE_610
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from fireREST.defaults import API_RELEASE_610
12
from fireREST.fmc import ChildResource
23

34

45
class FpInterfaceStatistics(ChildResource):
56
CONTAINER_NAME = 'DeviceRecord'
67
CONTAINER_PATH = '/devices/devicerecords/{uuid}'
78
PATH = '/devices/devicerecords/{container_uuid}/fpinterfacestatistics/{uuid}'
8-
MINIMUM_VERSION_REQUIRED_GET = '6.1.0'
9+
MINIMUM_VERSION_REQUIRED_GET = API_RELEASE_610

0 commit comments

Comments
 (0)