Skip to content

Commit

Permalink
Linted & formatted visual_rf file
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik Satheesh Kumar committed Sep 2, 2023
1 parent cd0d766 commit a0821d2
Showing 1 changed file with 97 additions and 53 deletions.
150 changes: 97 additions & 53 deletions pycentral/visualrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -25,24 +25,30 @@

urls = VisualrfUrl()


class ClientLocation(object):
"""A python class to obtain client location based on visualRF floor map.
"""
def get_client_location(self, conn, macaddr: str, offset=0, limit=100, units="FEET"):
"""Get location of a client. This function provides output only when visualRF is
configured in Aruba Central.

:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
def get_client_location(self, conn, macaddr: str, offset=0, limit=100,
units="FEET"):
"""Get location of a client. This function provides output only when\
visualRF is configured in Aruba Central.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param macaddr: Provide a macaddr of a client. For example "ac:bb:cc:dd:ec:10"
:param macaddr: Provide a macaddr of a client. For example\
"ac:bb:cc:dd:ec:10"
:type macaddr: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.CLIENT_LOCATION["GET_CLIENT_LOC"], macaddr)
Expand All @@ -54,24 +60,30 @@ def get_client_location(self, conn, macaddr: str, offset=0, limit=100, units="FE
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp

def get_floor_clients(self, conn, floor_id: str, offset=0, limit=100, units="FEET"):
def get_floor_clients(self, conn, floor_id: str, offset=0, limit=100,
units="FEET"):
"""Get location of clients within a floormap in Aruba Central visualRF.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param floor_id: Provide floor_id returned by `get_building_floors()` function in
class:`FloorPlan`
:param floor_id: Provide floor_id returned by `get_building_floors()`\
function in class:`FloorPlan`
:type floor_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.CLIENT_LOCATION["GET_FLOOR_CLIENTS"], floor_id, "client_location")
path = urlJoin(
urls.CLIENT_LOCATION["GET_FLOOR_CLIENTS"],
floor_id,
"client_location")
params = {
"offset": offset,
"limit": limit,
Expand All @@ -80,13 +92,17 @@ def get_floor_clients(self, conn, floor_id: str, offset=0, limit=100, units="FEE
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp


class RougueLocation(object):
"""A python class to obtain location of rogue access points
"""
def get_rogueap_location(self, conn, macaddr: str, offset=0, limit=100, units="FEET"):

def get_rogueap_location(self, conn, macaddr: str, offset=0, limit=100,
units="FEET"):
"""Get location of rogue a access point based on its Mac Address
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param macaddr: Provide Mac Address of an Access Point
:type macaddr: str
Expand All @@ -96,7 +112,8 @@ def get_rogueap_location(self, conn, macaddr: str, offset=0, limit=100, units="F
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.ROGUE_LOCATION["GET_AP_LOC"], macaddr)
Expand All @@ -108,21 +125,24 @@ def get_rogueap_location(self, conn, macaddr: str, offset=0, limit=100, units="F
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp

def get_floor_rogueaps(self, conn, floor_id: str, offset=0, limit=100, units="FEET"):
def get_floor_rogueaps(self, conn, floor_id: str, offset=0, limit=100,
units="FEET"):
"""Get rogue access points within a floor
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param floor_id: Provide floor id. Can be obtained from `get_building_floors()` within
class:`FloorPlan`
:param floor_id: Provide floor id. Can be obtained from\
`get_building_floors()` within class:`FloorPlan`
:type floor_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.ROGUE_LOCATION["GET_FLOOR_APS"], floor_id)
Expand All @@ -134,19 +154,24 @@ def get_floor_rogueaps(self, conn, floor_id: str, offset=0, limit=100, units="FE
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp


class FloorPlan(object):
"""A Python class to obtain information of floorplan in Aruba Central visualRF.
"""A Python class to obtain information of floorplan in Aruba Central\
visualRF.
"""

def get_campus_list(self, conn, offset=0, limit=100):
"""Get list of campuses in visualRF floorplan
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urls.FLOOR_PLAN["GET_CAMPUS_LIST"]
Expand All @@ -160,16 +185,18 @@ def get_campus_list(self, conn, offset=0, limit=100):
def get_campus_buildings(self, conn, campus_id: str, offset=0, limit=100):
"""Get campus info and buildings within the campus
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param campus_id: Provide campus id. Can be obtained from `get_campus_list` function in
class:`FloorPlan`
:param campus_id: Provide campus id. Can be obtained from\
`get_campus_list` function in class:`FloorPlan`
:type campus_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_CAMPUS_INFO"], campus_id)
Expand All @@ -180,21 +207,24 @@ def get_campus_buildings(self, conn, campus_id: str, offset=0, limit=100):
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp

def get_building_floors(self, conn, building_id: str, offset=0, limit=100, units="FEET"):
def get_building_floors(self, conn, building_id: str, offset=0, limit=100,
units="FEET"):
"""Get building info and floors within the building
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param building_id: Provide building id. Can be obtained from `get_campus_buildings` within
class:`FloorPlan`
:param building_id: Provide building id. Can be obtained from\
`get_campus_buildings` within class:`FloorPlan`
:type building_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_BUILDING_INFO"], building_id)
Expand All @@ -206,21 +236,24 @@ def get_building_floors(self, conn, building_id: str, offset=0, limit=100, units
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp

def get_floor_info(self, conn, floor_id: str, offset=0, limit=100, units="FEET"):
def get_floor_info(self, conn, floor_id: str, offset=0, limit=100,
units="FEET"):
"""Get floor information
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param floor_id: Provide floor id. Can be obtained from `get_building_floors()` within
class:`FloorPlan`
:param floor_id: Provide floor id. Can be obtained from\
`get_building_floors()` within class:`FloorPlan`
:type floor_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_FLOOR_INFO"], floor_id)
Expand All @@ -235,16 +268,18 @@ def get_floor_info(self, conn, floor_id: str, offset=0, limit=100, units="FEET")
def get_floor_image(self, conn, floor_id, offset=0, limit=100):
"""Get Floor's background image in base64 format
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param floor_id: Provide floor id. Can be obtained from `get_building_floors()` within
class:`FloorPlan`
:param floor_id: Provide floor id. Can be obtained from\
`get_building_floors()` within class:`FloorPlan`
:type floor_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_FLOOR_IMG"], floor_id, "image")
Expand All @@ -258,21 +293,26 @@ def get_floor_image(self, conn, floor_id, offset=0, limit=100):
def get_floor_aps(self, conn, floor_id, offset=0, limit=100, units="FEET"):
"""Get access points within a floor
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param floor_id: Provide floor id. Can be obtained from `get_building_floors()` within
class:`FloorPlan`
:param floor_id: Provide floor id. Can be obtained from\
`get_building_floors()` within class:`FloorPlan`
:type floor_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_FLOOR_APS"], floor_id, "access_point_location")
path = urlJoin(
urls.FLOOR_PLAN["GET_FLOOR_APS"],
floor_id,
"access_point_location")
params = {
"offset": offset,
"limit": limit,
Expand All @@ -281,20 +321,24 @@ def get_floor_aps(self, conn, floor_id, offset=0, limit=100, units="FEET"):
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp

def get_ap_location(self, conn, ap_id: str, offset=0, limit=100, units="FEET"):
def get_ap_location(self, conn, ap_id: str, offset=0, limit=100,
units="FEET"):
"""Get location of an access point within a floorplan
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an API call.
:param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
API call.
:type conn: class:`pycentral.ArubaCentralBase`
:param ap_id: Provide ap_id returned by `get_floor_aps()` within class:`FloorPlan`
:param ap_id: Provide ap_id returned by `get_floor_aps()` within\
class:`FloorPlan`
:type ap_id: str
:param offset: Pagination start index., defaults to 0
:type offset: int, optional
:param limit: Pagination size. Default 100 Max 100, defaults to 100
:type limit: int, optional
:param units: METERS or FEET, defaults to "FEET"
:type units: str, optional
:return: Response as provided by 'command' function in class:`pycentral.ArubaCentralBase`
:return: Response as provided by 'command' function in\
class:`pycentral.ArubaCentralBase`
:rtype: dict
"""
path = urlJoin(urls.FLOOR_PLAN["GET_AP_LOC"], ap_id)
Expand All @@ -304,4 +348,4 @@ def get_ap_location(self, conn, ap_id: str, offset=0, limit=100, units="FEET"):
"units": units
}
resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
return resp
return resp

0 comments on commit a0821d2

Please sign in to comment.