diff --git a/guide/03-the-gis/administering-your-gis.ipynb b/guide/03-the-gis/administering-your-gis.ipynb index 99c901d60e..552febad9a 100644 --- a/guide/03-the-gis/administering-your-gis.ipynb +++ b/guide/03-the-gis/administering-your-gis.ipynb @@ -1 +1,2405 @@ -{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Administering your GIS\n", "\n", "ArcGIS administrators can leverage the `gis.admin` module of **ArcGIS API for Python** to assist with and automate their administrative tasks. These tasks can include anything from checking the status of servers, assigning licenses to named user accounts to modifying the GIS's look and feel.\n", "\n", "ArcGIS Online Organizations (AGOL) and ArcGIS Enterprise instances vary on the amount of customization you can make. Enterprise organizations can be customized much more than ArcGIS Online organizations as Enterprise allows administrations full access. No matter what your organization is, the API and usage is identical. The table below illustrates the extent to which each can be customized and administered."]}, {"cell_type": "markdown", "metadata": {}, "source": ["
| Function | ArcGIS Online | ArcGIS Enterprise |
|---|---|---|
| collaborations | X | X |
| credits | X | |
| federation | X | |
| license | X | X |
| logs | X | |
| machines | X | |
| metadata | X | X |
| password_policy | X | X |
| security | X | |
| server | X | |
| site | X | |
| system | X | |
| ux | X | X |
Note: You need to log in using a named user account with administrator privileges. When you login, the API detects if you are an organizational administrator, then, the GIS object will ensure you gain access to the admin module.\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["**Table of Contents**\n", " - [Managing named user licenses and entitlements](#Managing-named-user-licenses-and-entitlements)\n", " - [Listing apps licensed through the organization](#Listing-apps-licensed-through-the-organization)\n", " - [Getting available licenses for an app](#Getting-available-licenses-for-an-app)\n", " - [Querying extensions assigned to a named user account](#Querying-extensions-assigned-to-a-named-user-account)\n", " - [Assigning licenses and entitlements to a named user account](#Assigning-licenses-and-entitlements-to-a-named-user-account)\n", " - [Revoking licenses from a named user account](#Revoking-licenses-from-a-named-used-account)\n", " - [Managing ArcGIS Online credits](#Managing-ArcGIS-Online-credits)\n", " - [Viewing available credits](#Viewing-available-credits:)\n", " - [Managing credits through credit budgeting](#Managing-credits-through-credit-budgeting)\n", " - [Allocating credits to a user](#Allocating-credits-to-a-user)\n", " - [Checking credits assigned and available to a user](#Checking-credits-assigned-and-available-to-a-user)\n", " - [Attaching and removing servers from your GIS](#Attaching-and-removing-ArcGIS-Servers-from-your-GIS)\n", " - [Validating your servers](#Validating-your-servers)\n", " - [Unfederating a server](#Unfederating-a-server)\n", " - [Querying Portal logs](#Querying-Portal-logs)\n", " - [Filtering and querying Portal logs](#Filtering-and-querying-Portal-logs)\n", " - [Clearing logs](#Clearing-logs)\n", " - [Managing GIS security](#Managing-GIS-security)\n", " - [Working with password policies](#Working-with-password-policies)\n", " - [Inspecting password policy](#Inspecting-password-policy)\n", " - [Updating password policy](#Updating-password-policy)\n", " - [Resetting password policy](#Resetting-password-policy)\n", " - [Working with security configurations](#Working-with-security-configurations)\n", " - [Working with certificates](#SSL-certificates)\n", " - [Enterprise identity store](#Enterprise-identity-store)\n", " - [Managing Enterprise licenses and system settings](#Managing-Enterprise-licenses-and-system-settings)\n", " - [Inspecting licenses for Portal for ArcGIS](#Inspecting-licenses-for-Portal-for-ArcGIS)\n", " - [Releasing ArcGIS Pro licenses checked out for offline use](#Releasing-ArcGIS-Pro-licenses-checked-out-for-offline-use)\n", " - [Inspecting the machines powering your Portal for ArcGIS](#Inspecting-the-machines-powering-your-Portal-for-ArcGIS)\n", " - [Inspecting system directories](#Inspecting-system-directories)\n", " - [Inspecting web adaptors](#Inspecting-web-adaptors)\n", " - [Inspecting other system properties](#Inspecting-other-system-properties)"]}, {"cell_type": "code", "execution_count": null, "metadata": {"collapsed": true}, "outputs": [], "source": ["from arcgis.gis import GIS\n", "gis = GIS(\"https://portalname.domain.com/webadaptor\", \"username\", \"password\")"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Managing named user licenses and entitlements\n", "ArcGIS Online and Enterprise support assigning licenses for Esri premium apps such as ArcGIS Pro, Navigator for ArcGIS, AppStudio for ArcGIS Standard, Drone2Map for ArcGIS, ArcGIS Business Analyst web app, ArcGIS Community Analyst, GeoPlanner for ArcGIS, and other apps sold through ArcGIS Marketplace that use a per-member license type. \n", "\n", "As an administrator, you use the `gis.admin.license` class of Python API to view, manage and specify which members have licenses for these apps. To learn more about named user licensing model visit [manage licenses help](http://doc.arcgis.com/en/arcgis-online/administer/manage-licenses.htm)."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Listing apps licensed through the organization\n", "To list all the apps currently licensed through your organization, use the `all()` method:"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["[
| \n", " | Entitlement | \n", "Total | \n", "Assigned | \n", "Remaining | \n", "
|---|---|---|---|---|
| 0 | \n", "smpNAmericaN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 1 | \n", "airportsN | \n", "100 | \n", "0 | \n", "100 | \n", "
| 2 | \n", "dataInteropN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 3 | \n", "networkAnalystN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 4 | \n", "defenseN | \n", "100 | \n", "0 | \n", "100 | \n", "
| 5 | \n", "workflowMgrN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 6 | \n", "LocRefDesktopN | \n", "100 | \n", "0 | \n", "100 | \n", "
| 7 | \n", "spatialAnalystN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 8 | \n", "3DAnalystN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 9 | \n", "dataReviewerN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 10 | \n", "smpEuropeN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 11 | \n", "desktopStdN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 12 | \n", "smpLAmericaN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 13 | \n", "geostatAnalystN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 14 | \n", "desktopBasicN | \n", "50 | \n", "1 | \n", "49 | \n", "
| 15 | \n", "smpMidEAfricaN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 16 | \n", "desktopAdvN | \n", "50 | \n", "0 | \n", "50 | \n", "
| 17 | \n", "publisherN | \n", "100 | \n", "1 | \n", "99 | \n", "
Note: ArcGIS Enterprises do not support the concept of credits. Hence if your GIS is an instance of Enterprise, you would not see the `credits` property.\n", "\n", "### Viewing available credits:"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["80404.89"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.credits.credits"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Managing credits through credit budgeting\n", "The credit budgeting feature of ArcGIS Online allows administrators to view, limit and allocate credits to its users. Learn more about [credit budgeting here](http://doc.arcgis.com/en/arcgis-online/administer/configure-credits.htm).\n", "\n", "You can use the `enable()` method to turn on credit budgeting."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.credits.enable()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["You can use the `is_enabled()` property to verify if credit budgeting is turned on."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.credits.is_enabled"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Once you turn on credit budgeting, you can set a default limit for the number of credits for each user. In addition to this, you can set custom limits to users as well. Default limit applies when you create a new user and do not set a custom limit."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["8000"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.credits.default_limit"]}, {"cell_type": "markdown", "metadata": {}, "source": ["#### Allocating credits to a user\n", "You can use the `allocate()` and `deallocate()` methods to allocate custom number of credits or remove credits from a named user."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["#assign one tenth of the available credits to arcgis_python account\n", "api_acc_credits = gis.admin.credits.credits / 10\n", "gis.admin.credits.allocate(username='arcgis_python', credits=api_acc_credits)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["#### Checking credits assigned and available to a user"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/html": ["
Note: Federation only applies to ArcGIS Enterprise orgs. If your GIS is an org on ArcGIS Online, you cannot perform these tasks\n", "\n", "The `Federation` class of the `admin` module allows GIS administrators to script and automate tasks such as listing the servers in a GIS, identifying their role and function, federating new servers, unfederating servers under maintenance, validating the list of servers etc."]}, {"cell_type": "markdown", "metadata": {}, "source": ["Get the list of servers federated to the GIS:"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["{'servers': [{'adminUrl': 'https://Dev005223.esri.com:6443/arcgis',\n", " 'id': 'COgNhKlPsIjGrCLV',\n", " 'isHosted': True,\n", " 'name': 'Dev005223.esri.com:6443',\n", " 'serverFunction': '',\n", " 'serverRole': 'HOSTING_SERVER',\n", " 'url': 'https://Dev005223.esri.com/server',\n", " 'webgisServerTrustKey': ''},\n", " {'adminUrl': 'https://dev005331.esri.com:6443/arcgis',\n", " 'id': 'GFyaVzJXiogsxKxH',\n", " 'isHosted': False,\n", " 'name': 'dev005331.esri.com:6443',\n", " 'serverFunction': 'RasterAnalytics',\n", " 'serverRole': 'FEDERATED_SERVER',\n", " 'url': 'https://dev005331.esri.com/server',\n", " 'webgisServerTrustKey': ''}]}"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.federation.servers"]}, {"cell_type": "markdown", "metadata": {}, "source": ["There are 2 servers federated to this GIS, the first is a `HOSTING_SERVER` and the second a `FEDERATED_SERVER`. The `serverFunction` of the second server is set to `RasterAnalytics`."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Validating your servers\n", "To validate all the servers attached to your GIS, call the `validate_all()` method. To validate a particular server, call `validate()` and pass the server info."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["{'serversStatus': [{'messages': [\"ArcGIS Server administration URL 'https://Dev005223.esri.com:6443/arcgis' is accessible.\",\n", " 'Validating hosting server.',\n", " \"ArcGIS Server 'https://Dev005223.esri.com:6443/arcgis' version matches with Portal for ArcGIS.\",\n", " \"Verified that server has a registered managed database '/enterpriseDatabases/AGSDataStore_ds_7jq2u67r'.\",\n", " \"The server managed database '/enterpriseDatabases/AGSDataStore_ds_7jq2u67r' validated successfully.\",\n", " 'Validated that the ArcGIS Server site is not in read-only mode.',\n", " 'Validated that the publishing tools service of ArcGIS Server site is started.'],\n", " 'serverId': 'COgNhKlPsIjGrCLV',\n", " 'status': 'success'},\n", " {'messages': [\"ArcGIS Server services URL 'https://dev005331.esri.com/server' cannot be validated against 'https://dev005331.esri.com/server/rest/info'. If the service URL is a proxy URL verify it is accessible to clients.\",\n", " 'Error: java.net.UnknownHostException: dev005331.esri.com. '],\n", " 'serverId': 'GFyaVzJXiogsxKxH',\n", " 'status': 'failure'}],\n", " 'status': 'failure'}"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.federation.validate_all()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The second server reports a failure as the Enterprise is unable to reach or ping it. This server requires maintenance."]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Unfederating a server\n", "You remove a server from the GIS by calling the `unfederate()` method and passing the `serverId`."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["'GFyaVzJXiogsxKxH'"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.federation.servers['servers'][1]['id']"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.federation.unfederate('GFyaVzJXiogsxKxH')"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Querying Portal logs\n", "Portal for ArcGIS records events that occur, and any errors associated with those events, to logs. Logs are an important tool for monitoring and troubleshooting problems with your portal. Information in the logs will help you identify errors and provide context on how to address problems. The logs also comprise a history of the events that occur over time.\n", "\n", "For example, the following events are recorded in the logs:\n", "\n", " - Installation and upgrade events, such as authorizing the software and creating the portal website\n", " - Publishing of services and items, such as hosted services, web maps, and data items\n", " - Content management events, such as sharing items, changing item ownership, and adding, updating, moving, and deleting items\n", " - Security events, such as users logging in to the portal, creating, deleting, and disabling users, creating and changing user roles, updating HTTP and HTTPS settings, import and export of security certificates, and updating the portal's identity store\n", " - Organization management events, such as adding and configuring groups, adding or removing users from a group, configuration of the gallery, basemaps, utility services, and federated servers, and configuring log settings and deleting logs\n", " - General events, such as updating the portal's search index and restarting the portal\n", "\n", "Understanding log messages is important to maintain your GIS. Refer [here](http://server.arcgis.com/en/portal/latest/administer/windows/about-portal-logs.htm) to learn more about logging in general and [here](http://server.arcgis.com/en/portal/latest/administer/windows/work-with-portal-logs.htm#ESRI_SECTION2_F96B4BDF7FBD4EFC865E316C1DFB460C) to understand what gets logged and what the messages mean.\n", "\n", "Using the `Logs` class of the `admin` module, administrators can query and work with Portal log messages. You can query the logging level and other settings from the `settings` property:"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["{'logDir': 'C:\\\\arcgisportal\\\\logs\\\\',\n", " 'logLevel': 'WARNING',\n", " 'maxErrorReportsCount': 10,\n", " 'maxLogFileAge': 90,\n", " 'usageMeteringEnabled': False}"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["gis.admin.logs.settings"]}, {"cell_type": "markdown", "metadata": {}, "source": ["### Filtering and querying Portal logs\n", "Using the `query()` method, you can filter and search for Portal logs. Refer to the [query API ref doc](http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.admin.html#arcgis.gis.admin.Logs.query) for all the arguments supported. In the example below, logs for the previous 10 days is searched."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["datetime.datetime(2017, 8, 1, 15, 5, 32, 941945)"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["import datetime\n", "import pandas as pd\n", "now = datetime.datetime.now()\n", "start_time = now - datetime.timedelta(days=10)\n", "start_time"]}, {"cell_type": "markdown", "metadata": {}, "source": ["You can pass a Python `Datetime` object to the time arguments."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/plain": ["{'code': 207051,\n", " 'elapsed': '',\n", " 'machine': 'DEV005223.ESRI.COM',\n", " 'message': \"Validation failed for federated server 'https://dev005331.esri.com:6443/arcgis'.\",\n", " 'methodName': '',\n", " 'process': '1956',\n", " 'source': 'Portal Admin',\n", " 'thread': '14',\n", " 'time': 1502486731894,\n", " 'type': 'WARNING',\n", " 'user': ''}"]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["recent_logs = gis.admin.logs.query(start_time = start_time)\n", "\n", "#print a message as a sample\n", "recent_logs['logMessages'][0]"]}, {"cell_type": "markdown", "metadata": {}, "source": ["You can construct a Pandas `DataFrame` from the query result and visualize the logs as a table:"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"data": {"text/html": ["
| \n", " | endTime | \n", "hasMore | \n", "logMessages | \n", "startTime | \n", "
|---|---|---|---|---|
| 0 | \n", "1501718081748 | \n", "False | \n", "{'elapsed': '', 'message': 'Validation failed ... | \n", "1502486731894 | \n", "
| 1 | \n", "1501718081748 | \n", "False | \n", "{'elapsed': '', 'message': ' Failed to update ... | \n", "1502486731894 | \n", "
| 2 | \n", "1501718081748 | \n", "False | \n", "{'elapsed': '', 'message': 'Validation failed ... | \n", "1502486731894 | \n", "
| 3 | \n", "1501718081748 | \n", "False | \n", "{'elapsed': '', 'message': 'Validation failed ... | \n", "1502486731894 | \n", "
| 4 | \n", "1501718081748 | \n", "False | \n", "{'elapsed': '', 'message': ' Failed to accept ... | \n", "1502486731894 | \n", "
| Function | ArcGIS Online | ArcGIS Enterprise |
|---|---|---|
| collaborations | X | X |
| credits | X | |
| federation | X | |
| license | X | X |
| logs | X | |
| machines | X | |
| metadata | X | X |
| password_policy | X | X |
| security | X | |
| server | X | |
| site | X | |
| system | X | |
| ux | X | X |
Note: You need to log in using a named user account with administrator privileges. The API automatically detects your role; if you are an organizational administrator, the GIS object will grant you access to the admin module.\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Table of Contents**\n", + " - [Managing named user licenses and entitlements](#Managing-named-user-licenses-and-entitlements)\n", + " - [Listing apps licensed through the organization](#Listing-apps-licensed-through-the-organization)\n", + " - [Getting available licenses for an app](#Getting-available-licenses-for-an-app)\n", + " - [Querying extensions assigned to a named user account](#Querying-extensions-assigned-to-a-named-user-account)\n", + " - [Assigning licenses and entitlements to a named user account](#Assigning-licenses-and-entitlements-to-a-named-user-account)\n", + " - [Revoking licenses from a named user account](#Revoking-licenses-from-a-named-used-account)\n", + " - [Managing ArcGIS Online credits](#Managing-ArcGIS-Online-credits)\n", + " - [Viewing available credits](#Viewing-available-credits:)\n", + " - [Managing credits through credit budgeting](#Managing-credits-through-credit-budgeting)\n", + " - [Allocating credits to a user](#Allocating-credits-to-a-user)\n", + " - [Checking credits assigned and available to a user](#Checking-credits-assigned-and-available-to-a-user)\n", + " - [Attaching and removing servers from your GIS](#Attaching-and-removing-ArcGIS-Servers-from-your-GIS)\n", + " - [Validating your servers](#Validating-your-servers)\n", + " - [Unfederating a server](#Unfederating-a-server)\n", + " - [Querying Portal logs](#Querying-Portal-logs)\n", + " - [Filtering and querying Portal logs](#Filtering-and-querying-Portal-logs)\n", + " - [Clearing logs](#Clearing-logs)\n", + " - [Managing GIS security](#Managing-GIS-security)\n", + " - [Working with password policies](#Working-with-password-policies)\n", + " - [Inspecting password policy](#Inspecting-password-policy)\n", + " - [Updating password policy](#Updating-password-policy)\n", + " - [Resetting password policy](#Resetting-password-policy)\n", + " - [Working with security configurations](#Working-with-security-configurations)\n", + " - [Working with certificates](#SSL-certificates)\n", + " - [Enterprise identity store](#Enterprise-identity-store)\n", + " - [Managing Enterprise licenses and system settings](#Managing-Enterprise-licenses-and-system-settings)\n", + " - [Inspecting licenses for Portal for ArcGIS](#Inspecting-licenses-for-Portal-for-ArcGIS)\n", + " - [Releasing ArcGIS Pro licenses checked out for offline use](#Releasing-ArcGIS-Pro-licenses-checked-out-for-offline-use)\n", + " - [Inspecting the machines powering your Portal for ArcGIS](#Inspecting-the-machines-powering-your-Portal-for-ArcGIS)\n", + " - [Inspecting system directories](#Inspecting-system-directories)\n", + " - [Inspecting web adaptors](#Inspecting-web-adaptors)\n", + " - [Inspecting other system properties](#Inspecting-other-system-properties)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [], + "source": [ + "from arcgis.gis import GIS\n", + "gis = GIS(profile=
| \n", + " | Entitlement | \n", + "Total | \n", + "Assigned | \n", + "Remaining | \n", + "Users | \n", + "
|---|---|---|---|---|---|
| 0 | \n", + "3DAnalystN | \n", + "500 | \n", + "7 | \n", + "493 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 1 | \n", + "airportsN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_11', 'lastUsed': Non... | \n", + "
| 2 | \n", + "aviationN | \n", + "500 | \n", + "4 | \n", + "496 | \n", + "[{'user': 'test_create_2', 'lastUsed': 'Octobe... | \n", + "
| 3 | \n", + "bathymetryN | \n", + "500 | \n", + "4 | \n", + "496 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 4 | \n", + "businessStdN | \n", + "500 | \n", + "11 | \n", + "489 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 5 | \n", + "dataInteropN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 6 | \n", + "dataReviewerN | \n", + "500 | \n", + "4 | \n", + "496 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 7 | \n", + "defenseN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_11', 'lastUsed': Non... | \n", + "
| 8 | \n", + "desktopAdvN | \n", + "500 | \n", + "13 | \n", + "487 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 9 | \n", + "desktopStdN | \n", + "500 | \n", + "1 | \n", + "499 | \n", + "[{'user': 'test_create_2', 'lastUsed': 'Octobe... | \n", + "
| 10 | \n", + "geostatAnalystN | \n", + "500 | \n", + "4 | \n", + "496 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 11 | \n", + "imageAnalystN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 12 | \n", + "indoorsN | \n", + "500 | \n", + "1 | \n", + "499 | \n", + "[{'user': 'test_create_5', 'lastUsed': 'Marc... | \n", + "
| 13 | \n", + "locateXTN | \n", + "500 | \n", + "2 | \n", + "498 | \n", + "[{'user': 'pythondemo', 'lastUsed': None}, {'u... | \n", + "
| 14 | \n", + "LocRefDesktopN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_11', 'lastUsed': Non... | \n", + "
| 15 | \n", + "maritimeN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_11', 'lastUsed': Non... | \n", + "
| 16 | \n", + "networkAnalystN | \n", + "500 | \n", + "5 | \n", + "495 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 17 | \n", + "productionMapN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_11', 'lastUsed': Non... | \n", + "
| 18 | \n", + "publisherN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 19 | \n", + "smpAsiaPacificN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 20 | \n", + "smpEuropeN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 21 | \n", + "smpLAmericaN | \n", + "500 | \n", + "3 | \n", + "497 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 22 | \n", + "smpMidEAfricaN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 23 | \n", + "smpNAmericaN | \n", + "500 | \n", + "7 | \n", + "493 | \n", + "[{'user': 'test_create_4', 'lastUsed': 'April 18, 2... | \n", + "
| 24 | \n", + "spatialAnalystN | \n", + "500 | \n", + "6 | \n", + "494 | \n", + "[{'user': 'test_create_10', 'lastUsed': 'July ... | \n", + "
| 25 | \n", + "workflowMgrN | \n", + "500 | \n", + "4 | \n", + "496 | \n", + "[{'user': 'test_create_2', 'lastUse... | \n", + "
Note: ArcGIS Enterprises do not support the concept of credits. Hence if your GIS is an instance of Enterprise, you would not see the credits property.\n", + "\n", + "### Viewing available credits:" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3171304" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.credits.credits" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Managing credits through credit budgeting\n", + "The credit budgeting feature of ArcGIS Online allows administrators to view, limit, and allocate credits to their users. Learn more about [credit budgeting here](http://doc.arcgis.com/en/arcgis-online/administer/configure-credits.htm).\n", + "\n", + "You can use the `enable()` method to turn on credit budgeting." + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.credits.enable()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can use the `is_enabled` property to verify if credit budgeting is turned on." + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.credits.is_enabled" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once you turn on credit budgeting, you can set a **default limit** for the number of credits **per user**. In addition, you can set **custom limits** for individual users. The default limit applies when you create a new user **unless a custom limit is specified**." + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "601" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.credits.default_limit" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Allocating credits to a user\n", + "You can use the `allocate()` and `deallocate()` methods to allocate custom number of credits or remove credits from a named user." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#assign one tenth of the available credits to test_create_f0d9 account\n", + "api_acc_credits = gis.admin.credits.credits / 10\n", + "gis.admin.credits.allocate(username='test_create_f0d9', credits=api_acc_credits)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Checking credits assigned and available to a user" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Note: Federation only applies to ArcGIS Enterprise organizations. If your GIS is an organization on ArcGIS Online, you cannot perform these tasks.\n", + "\n", + "The `Federation` class of the `admin` module allows GIS administrators to script and automate tasks such as listing the servers in a GIS, identifying their role and function, federating new servers, unfederating servers under maintenance, and validating the server list." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get the list of servers federated to the GIS:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'servers': [{'adminUrl': 'https://Dev005223.esri.com:6443/arcgis',\n", + " 'id': 'COgNhKlPsIjGrCLV',\n", + " 'isHosted': True,\n", + " 'name': 'Dev005223.esri.com:6443',\n", + " 'serverFunction': '',\n", + " 'serverRole': 'HOSTING_SERVER',\n", + " 'url': 'https://Dev005223.esri.com/server',\n", + " 'webgisServerTrustKey': ''},\n", + " {'adminUrl': 'https://dev005331.esri.com:6443/arcgis',\n", + " 'id': 'GFyaVzJXiogsxKxH',\n", + " 'isHosted': False,\n", + " 'name': 'dev005331.esri.com:6443',\n", + " 'serverFunction': 'RasterAnalytics',\n", + " 'serverRole': 'FEDERATED_SERVER',\n", + " 'url': 'https://dev005331.esri.com/server',\n", + " 'webgisServerTrustKey': ''}]}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.federation.servers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There are 2 servers federated to this GIS, the first is a `HOSTING_SERVER` and the second a `FEDERATED_SERVER`. The `serverFunction` of the second server is set to `RasterAnalytics`." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Validating your servers\n", + "To validate all the servers attached to your GIS, call the `validate_all()` method. To validate a particular server, call `validate()` and pass the server's **name or ID**." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'serversStatus': [{'messages': [\"ArcGIS Server administration URL 'https://Dev005223.esri.com:6443/arcgis' is accessible.\",\n", + " 'Validating hosting server.',\n", + " \"ArcGIS Server 'https://Dev005223.esri.com:6443/arcgis' version matches with Portal for ArcGIS.\",\n", + " \"Verified that server has a registered managed database '/enterpriseDatabases/AGSDataStore_ds_7jq2u67r'.\",\n", + " \"The server managed database '/enterpriseDatabases/AGSDataStore_ds_7jq2u67r' validated successfully.\",\n", + " 'Validated that the ArcGIS Server site is not in read-only mode.',\n", + " 'Validated that the publishing tools service of ArcGIS Server site is started.'],\n", + " 'serverId': 'COgNhKlPsIjGrCLV',\n", + " 'status': 'success'},\n", + " {'messages': [\"ArcGIS Server services URL 'https://dev005331.esri.com/server' cannot be validated against 'https://dev005331.esri.com/server/rest/info'. If the service URL is a proxy URL verify it is accessible to clients.\",\n", + " 'Error: java.net.UnknownHostException: dev005331.esri.com. '],\n", + " 'serverId': 'GFyaVzJXiogsxKxH',\n", + " 'status': 'failure'}],\n", + " 'status': 'failure'}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.federation.validate_all()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The second server reports a failure as the Enterprise is unable to reach or ping it. This server requires maintenance." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Unfederating a server\n", + "You remove a server from the GIS by calling the `unfederate()` method and passing the `serverId`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'GFyaVzJXiogsxKxH'" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.federation.servers['servers'][1]['id']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.federation.unfederate('GFyaVzJXiogsxKxH')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Querying Portal logs\n", + "\n", + "Portal for ArcGIS records events that occur, as well as any associated errors, in its logs. Logs are an important tool for monitoring and troubleshooting problems with your portal. Information in the logs will help you identify errors and provide context on how to address problems. The logs also comprise a history of the events that occur over time.\n", + "\n", + "For example, the following events are recorded in the logs:\n", + "\n", + " - Installation and upgrade events, such as authorizing the software and creating the portal website\n", + " - Publishing of services and items, such as hosted services, web maps, and data items\n", + " - Content management events, such as sharing items, changing item ownership, and adding, updating, moving, and deleting items\n", + " - Security events, such as users logging in to the portal, creating, deleting, and disabling users, creating and changing user roles, updating HTTP and HTTPS settings, import and export of security certificates, and updating the portal's identity store\n", + " - Organization management events, such as adding and configuring groups, adding or removing users from a group, configuration of the gallery, basemaps, utility services, and federated servers, and configuring log settings and deleting logs\n", + " - General events, such as updating the portal's search index and restarting the portal\n", + "\n", + "Understanding log messages is important to maintain your GIS. Refer [here](http://server.arcgis.com/en/portal/latest/administer/windows/about-portal-logs.htm) to learn more about logging in general and [here](http://server.arcgis.com/en/portal/latest/administer/windows/work-with-portal-logs.htm#ESRI_SECTION2_F96B4BDF7FBD4EFC865E316C1DFB460C) to understand what gets logged and what the messages mean.\n", + "\n", + "Using the `Logs` class of the `admin` module, administrators can query and work with Portal log messages. You can query the logging level and other settings from the `settings` property:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'logDir': 'C:\\\\arcgisportal\\\\logs\\\\',\n", + " 'logLevel': 'WARNING',\n", + " 'maxErrorReportsCount': 10,\n", + " 'maxLogFileAge': 90,\n", + " 'usageMeteringEnabled': False}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gis.admin.logs.settings" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Filtering and querying Portal logs\n", + "Using the `query()` method, you can filter and search for Portal logs. Refer to the [query API ref doc](http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.admin.html#arcgis.gis.admin.Logs.query) for all the arguments supported. In the example below, logs for the previous 10 days is searched." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "datetime.datetime(2017, 8, 1, 15, 5, 32, 941945)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import datetime\n", + "import pandas as pd\n", + "now = datetime.datetime.now()\n", + "start_time = now - datetime.timedelta(days=10)\n", + "start_time" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can pass a Python `Datetime` object to the time arguments." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'code': 207051,\n", + " 'elapsed': '',\n", + " 'machine': 'DEV005223.ESRI.COM',\n", + " 'message': \"Validation failed for federated server 'https://dev005331.esri.com:6443/arcgis'.\",\n", + " 'methodName': '',\n", + " 'process': '1956',\n", + " 'source': 'Portal Admin',\n", + " 'thread': '14',\n", + " 'time': 1502486731894,\n", + " 'type': 'WARNING',\n", + " 'user': ''}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "recent_logs = gis.admin.logs.query(start_time = start_time)\n", + "\n", + "#print a message as a sample\n", + "recent_logs['logMessages'][0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can construct a Pandas `DataFrame` from the query result and visualize the logs as a table:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
| \n", + " | endTime | \n", + "hasMore | \n", + "logMessages | \n", + "startTime | \n", + "
|---|---|---|---|---|
| 0 | \n", + "1501718081748 | \n", + "False | \n", + "{'elapsed': '', 'message': 'Validation failed ... | \n", + "1502486731894 | \n", + "
| 1 | \n", + "1501718081748 | \n", + "False | \n", + "{'elapsed': '', 'message': ' Failed to update ... | \n", + "1502486731894 | \n", + "
| 2 | \n", + "1501718081748 | \n", + "False | \n", + "{'elapsed': '', 'message': 'Validation failed ... | \n", + "1502486731894 | \n", + "
| 3 | \n", + "1501718081748 | \n", + "False | \n", + "{'elapsed': '', 'message': 'Validation failed ... | \n", + "1502486731894 | \n", + "
| 4 | \n", + "1501718081748 | \n", + "False | \n", + "{'elapsed': '', 'message': ' Failed to accept ... | \n", + "1502486731894 | \n", + "