{ "cells": [ { "cell_type": "markdown", "source": [ "## Imports" ], "metadata": {} }, { "cell_type": "code", "execution_count": 4, "source": [ "from suds.client import Client\n", "import random\n", "import base64\n", "\n", "YF_BASE_URL = \"\" # Could be something like: \"http://localhost:9696\"" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Create Yellowfin Admin Service\n", "\n", "### With a function get_user_dashboards" ], "metadata": {} }, { "cell_type": "code", "execution_count": 11, "source": [ "class YellowfinAdminService(object):\n", " url = f'{YF_BASE_URL}/services/AdministrationService?wsdl'\n", " client = Client(url)\n", " ADMIN_USER = 'admin@yellowfin.com.au' # Change to ad admin account in your yellowfin instance\n", " ADMIN_PASS = 'test'\n", " \n", " def upload_licence(self, user):\n", " with open(\".lic\", \"rb\") as licence_file:\n", " encoded_string = base64.b64encode(licence_file.read()).decode('utf-8')\n", " admin_service_request = {\n", " \"function\": \"UPLOADLICENCE\",\n", " \"loginId\" : self.ADMIN_USER,\n", " \"password\": self.ADMIN_PASS,\n", " \"orgId\": 1,\n", " \"binaryData\": encoded_string\n", " }\n", " \n", " response = self.client.service.remoteAdministrationCall(admin_service_request)\n", "\n", " if response.statusCode == 'SUCCESS':\n", " print(f\"Call {admin_service_request['function']} Succeeded\")\n", " return response\n", " else: \n", " print(f\"Call {admin_service_request['function']} Failed: {response.errorCode}\")\n", " return None" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Call to upload Licence" ], "metadata": {} }, { "cell_type": "code", "execution_count": 12, "source": [ "yellowfin = YellowfinAdminService()\n", "yellowfin.upload_licence('admin@yellowfin.com.au')" ], "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Call UPLOADLICENCE Succeeded\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ "" ] }, "metadata": {}, "execution_count": 12 } ], "metadata": {} } ], "metadata": { "kernelspec": { "name": "python3", "display_name": "Python 3.9.6 64-bit" }, "language_info": { "name": "python", "version": "3.9.6", "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python", "file_extension": ".py" }, "interpreter": { "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" } }, "nbformat": 4, "nbformat_minor": 2 }