Comments (2)
This should do the trick.
`def _get_groups(self, url, filter: str = None):
"""
Get generic group lists.
:param url: Base URL for requesting lists
:return: result dictionary
"""
result = {
"success": False,
"response": "",
"error": "",
}
self.ise.headers.update(
{"Accept": "application/json", "Content-Type": "application/json"}
)
f = furl(url)
# Max resources per page cannot be more then 100 resources.
f.args["size"] = 100
# TODO add filter valication
if filter:
f.args["filter"] = filter
resp = self.ise.get(f.url, timeout=self.timeout)
if resp.status_code == 200:
result["success"] = True
result["total"] = resp.json()["SearchResult"]["total"]
result["response"] = []
for page in range(1, int((result["total"] / f.args["size"] + 1) + 1)):
f.args["page"] = page
resp = self.ise.get(f.url, timeout=self.timeout)
if resp.status_code == 200:
result["response"] += [
(i["name"], i["id"], i["description"])
for i in resp.json()["SearchResult"]["resources"]
]
return result
else:
return ERS._pass_ersresponse(result, resp)
def _get_objects(self, url, filter: str = None):
"""
Generic method for requesting objects lists.
:param url: Base URL for requesting lists
:param filter: argument side of a ERS filter string. Default: None
:return: result dictionary
"""
result = {
"success": False,
"response": "",
"error": "",
}
self.ise.headers.update(
{"Accept": "application/json", "Content-Type": "application/json"}
)
f = furl(url)
# Max resources per page cannot be more then 100 resources.
f.args["size"] = 100
# TODO add filter valication
if filter:
f.args["filter"] = filter
resp = self.ise.get(f.url, timeout=self.timeout)
if resp.status_code == 200:
json_res = resp.json()["SearchResult"]
if int(json_res["total"]) >= 1:
result["success"] = True
result["total"] = json_res["total"]
result["response"] = []
for page in range(1, int((result["total"] / f.args["size"] + 1) + 1)):
f.args["page"] = page
resp = self.ise.get(f.url, timeout=self.timeout)
if resp.status_code == 200:
json_res = resp.json()["SearchResult"]
result["response"] += [
(i["name"], i["id"]) for i in json_res["resources"]
]
return result
elif int(json_res["total"]) == 0:
result["success"] = True
result["response"] = []
result["total"] = json_res["total"]
return result
else:
return ERS._pass_ersresponse(result, resp)`
from pyise-ers.
Hi,
Thanks for the code!
Is it possible that you can and/or have the time to do a PR?
If not, I'll create a PR myself with the changes.
Again, thanks for the help :)
--
Kind Regards Falk
from pyise-ers.
Related Issues (20)
- add_devices - ISE 3.x HOT 8
- Library doesn't use timeout in all requests library function calls HOT 6
- Defork and namechange to get compliance against Cisco DevNet policies. HOT 11
- add get_endpoint_byname HOT 4
- Help with maintenance of this repo.
- Get codecov over 70% HOT 1
- On ISE 3.0 a faulty connection doesn't return "response": Unauthorized HOT 2
- Bulk support HOT 2
- replace pipenv with poetry HOT 2
- Update packets from pypi. HOT 1
- Do test for 2.7
- Do test for 3.0
- Do test for 3.1
- Do test for 3.2 HOT 1
- Release 0.3 to PyPI.
- Update documentation for 0.3.x HOT 1
- Change to f-strings in output HOT 1
- looking for some suggestion to implement some ISE commands HOT 2
- Add filter to get_device_groups HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyise-ers.