Closed exitcode0 closed 1 year ago
some code u can run on your own (https://github.com/okta/okta-sdk-python/#call-other-api-endpoints)
import okta.client
import asyncio
async def main():
# `async with` reuses the session, so it's much faster.
async with Client() as client:
async for resource_set in client.list_resource_sets():
async for resource in client.list_resources(resource_set['id']):
print(resource_set['label'], resource['orn'])
class Client(okta.client.Client):
"""A thin wrapper around the Okta SDK."""
async def list_resource_sets(self):
# see https://developer.okta.com/docs/reference/api/roles
async for resource_set in self.get_iam_objects('/api/v1/iam/resource-sets', 'resource-sets'):
yield resource_set
async def list_resources(self, id):
# see https://developer.okta.com/docs/reference/api/roles
async for resource in self.get_iam_objects('/api/v1/iam/resource-sets/' + id + '/resources', 'resources'):
yield resource
async def get_iam_objects(self, url, key):
# see https://github.com/okta/okta-sdk-python/#call-other-api-endpoints
while url:
exec = self.get_request_executor()
req, _ = await exec.create_request('get', url)
resp, _ = await exec.execute(req)
page = resp.get_body()
for obj in page[key]:
yield obj
url = page.get('_links', {}).get('next', {}).get('href')
asyncio.run(main())
This endpoint was introduced in our Open API Spec v3. Currently, there are no plans to upgrade Python SDK to v3.
You can however use a tool such as openapi-generator.tech (our recommended OASv3 generator tooling) to build a custom SDK in Python.
Hey @bretterer.
there are no plans to upgrade Python SDK to v3.
Any chance you can expand upon this?
Is this limited to the Python SDK or are all Okta SDKs not planning to support the Open API Spec v3? Was the Open API Spec v3 not intended for use with the SDks was it created for consumption by a different audience?
Having this API available natively is more of a want rather than a need for me That said, If the Open API Spec v3 will be supported in other SDKs, i'm happy to switch to using another 😄
@exitcode0 currently, we have migrated our .NET, Java, and Golang SDK's to OASv3. As I mentioned, we do not have current plans to upgrade Python to this version.
We will be opening up the v3 spec into NPM in the future to allow for developers to build their own SDK with our spec. We recommend using openapi-generator.tech for doing this as this is the platform we use for our other languages.
the
api/v1/iam/resource-sets
API is a part of the Okta open API spec but has yet to be implemented into this SDK