diff --git a/python/Pipfile.lock b/python/Pipfile.lock index 4f930de4..068d7c6f 100644 --- a/python/Pipfile.lock +++ b/python/Pipfile.lock @@ -61,10 +61,10 @@ }, "click": { "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + "sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc", + "sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a" ], - "version": "==7.0" + "version": "==7.1.1" }, "entrypoints": { "hashes": [ @@ -113,23 +113,23 @@ }, "mypy": { "hashes": [ - "sha256:0a9a45157e532da06fe56adcfef8a74629566b607fa2c1ac0122d1ff995c748a", - "sha256:2c35cae79ceb20d47facfad51f952df16c2ae9f45db6cb38405a3da1cf8fc0a7", - "sha256:4b9365ade157794cef9685791032521233729cb00ce76b0ddc78749abea463d2", - "sha256:53ea810ae3f83f9c9b452582261ea859828a9ed666f2e1ca840300b69322c474", - "sha256:634aef60b4ff0f650d3e59d4374626ca6153fcaff96ec075b215b568e6ee3cb0", - "sha256:7e396ce53cacd5596ff6d191b47ab0ea18f8e0ec04e15d69728d530e86d4c217", - "sha256:7eadc91af8270455e0d73565b8964da1642fe226665dd5c9560067cd64d56749", - "sha256:7f672d02fffcbace4db2b05369142e0506cdcde20cea0e07c7c2171c4fd11dd6", - "sha256:85baab8d74ec601e86134afe2bcccd87820f79d2f8d5798c889507d1088287bf", - "sha256:87c556fb85d709dacd4b4cb6167eecc5bbb4f0a9864b69136a0d4640fdc76a36", - "sha256:a6bd44efee4dc8c3324c13785a9dc3519b3ee3a92cada42d2b57762b7053b49b", - "sha256:c6d27bd20c3ba60d5b02f20bd28e20091d6286a699174dfad515636cb09b5a72", - "sha256:e2bb577d10d09a2d8822a042a23b8d62bc3b269667c9eb8e60a6edfa000211b1", - "sha256:f97a605d7c8bc2c6d1172c2f0d5a65b24142e11a58de689046e62c2d632ca8c1" + "sha256:15b948e1302682e3682f11f50208b726a246ab4e6c1b39f9264a8796bb416aa2", + "sha256:219a3116ecd015f8dca7b5d2c366c973509dfb9a8fc97ef044a36e3da66144a1", + "sha256:3b1fc683fb204c6b4403a1ef23f0b1fac8e4477091585e0c8c54cbdf7d7bb164", + "sha256:3beff56b453b6ef94ecb2996bea101a08f1f8a9771d3cbf4988a61e4d9973761", + "sha256:7687f6455ec3ed7649d1ae574136835a4272b65b3ddcf01ab8704ac65616c5ce", + "sha256:7ec45a70d40ede1ec7ad7f95b3c94c9cf4c186a32f6bacb1795b60abd2f9ef27", + "sha256:86c857510a9b7c3104cf4cde1568f4921762c8f9842e987bc03ed4f160925754", + "sha256:8a627507ef9b307b46a1fea9513d5c98680ba09591253082b4c48697ba05a4ae", + "sha256:8dfb69fbf9f3aeed18afffb15e319ca7f8da9642336348ddd6cab2713ddcf8f9", + "sha256:a34b577cdf6313bf24755f7a0e3f3c326d5c1f4fe7422d1d06498eb25ad0c600", + "sha256:a8ffcd53cb5dfc131850851cc09f1c44689c2812d0beb954d8138d4f5fc17f65", + "sha256:b90928f2d9eb2f33162405f32dde9f6dcead63a0971ca8a1b50eb4ca3e35ceb8", + "sha256:c56ffe22faa2e51054c5f7a3bc70a370939c2ed4de308c690e7949230c995913", + "sha256:f91c7ae919bbc3f96cd5e5b2e786b2b108343d1d7972ea130f7de27fdd547cf3" ], "index": "pypi", - "version": "==0.761" + "version": "==0.770" }, "mypy-extensions": { "hashes": [ diff --git a/python/README.md b/python/README.md index 22f596b9..ba39dcf8 100644 --- a/python/README.md +++ b/python/README.md @@ -2,20 +2,32 @@ You can find Python language examples in this folder. +### General examples + +|   Example Topic   | Discussion | +| ------------- | ---------- | +| [custom config reader](custom_config_reader.py) | Shows how to implement a custom method of reading your configuration settings, including API credentials | + ## Connection management +|   Example Topic   | Discussion | +| ------------- | ---------- | +| [Testing a connection](test_connection.py) | Shows how to obtain and run all supported tests for a given connection name.| -- [Test a specified connection](test_connection.py) ## Manage Dashboards +|   Example Topic   | Discussion | +| ------------- | ---------- | +| [Soft delete dashboard](soft_delete_dashboard.py)| Shows how to look up a dashboards by title and move them to the trash folder. | -- [Soft delete dashboard](soft_delete_dashboard.py) ## Manage Render Tasks - -- [Download dashboard tile in specified format](download_tile.py) -- [Download look in specified format](download_look.py) -- [Generate and download dashboard PDFs](download_dashboard_pdf.py) +|   Example Topic   | Discussion | +| ------------- | ---------- | +| [Download dashboard tile in specified format](download_tile.py) | Find the requested dashboard by name, then the requested tile by name. If either name matches, the list of all available items is display. Supported output formats are PNG, JPG, CSV, JSON, and anything else supported by the `run_query` endpoint. This sample shows progress during a render task. | +| [Download look in specified format](download_look.py) | Find the requested look by name, create a render task and write the binary result to file. | +| [Generate and download dashboard PDFs](download_dashboard_pdf.py) | Find the requested dashboard by name, create a render task and write the binary result to file. | ## User Management - -- [Disable all active user sessions](logout_all_users.py) +|   Example Topic   | Discussion | +| ------------- | ---------- | +| [Disable all active user sessions](logout_all_users.py) | Shows how to iterate through all users and terminate any active sessions they might have. | diff --git a/python/custom_config_reader.py b/python/custom_config_reader.py new file mode 100644 index 00000000..8602f488 --- /dev/null +++ b/python/custom_config_reader.py @@ -0,0 +1,48 @@ +import attr +from looker_sdk import ( + api_settings, + auth_session, + methods, + requests_transport, + serialize, +) +from looker_sdk.rtl import transport as tp + + +@attr.s(auto_attribs=True, kw_only=True) +class CustomConfigReader(tp.TransportSettings): + """ + A custom configuration reader that implements the PApiSettings protocol and allows + passing of config details as parameters. The get_client_id and get_cient_secret + methods can be modified to fetch credentials from anywhere. + """ + + @classmethod + def configure(cls, base_url: str, api_version: str) -> api_settings.PApiSettings: + settings = cls(base_url=base_url, api_version=api_version) + return settings + + def get_client_id(self) -> str: + return "client_id" + + def get_client_secret(self) -> str: + return "client_secret" + + +def main(): + settings = CustomConfigReader.configure( + base_url="https://:19999", api_version="3.1" + ) + transport = requests_transport.RequestsTransport.configure(settings) + sdk = methods.Looker31SDK( + auth_session.AuthSession(settings, transport, serialize.deserialize31), + serialize.deserialize31, + serialize.serialize, + transport, + ) + + me = sdk.me() + print(me) + + +main()