{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Administration: Deploy automatic notifications\n", "\n", "> * ✏️ Needs Configuration\n", "* 🗄️ Administration\n", "* 🔔 Notifications\n", "\n", "To optimize your notebook's utility, consider configuring it to alert someone of a notable event. For example, a publisher could be notified that their web map contains a broken layer URL, or an admin could be notified when certain users haven't logged on in over a month. Notifications may arrive as an email or text message - or they could take the form of a tweet or a Slack post. There are many ways to use native Python libraries to send notifications through external services. This notebook will walk you through the technical details of how to configure these external services for your hosted notebooks and provide you the sample code needed to control these services." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Security\n", "\n", "Before writing code that connects to any external service, it is vital to keep security in mind. Notebooks are commonly shared and code is copied and pasted, sometimes leading to passwords and private keys landing in the wrong hands.\n", "\n", "**Passwords and private keys should NEVER be stored in plaintext in a notebook**. There are many paradigms to securely store passwords and private keys. We will be storing all 'secrets' in a [private CSV item](https://www.esri.com/arcgis-blog/products/arcgis-online/sharing-collaboration/managing-security-and-findability-of-items-with-the-arcgis-sharing-model/) that is only accessible by you and your GIS administrator. \n", "\n", "> __Note__: that although this is more secure than storing your passwords as a plain string in a notebook, this is __NOT__ a totally secure solution—items aren't encrypted in the underlying server where they are stored. Consider storing your secrets in an encrypted files in `/arcgis/home/`.\n", "\n", "Run the below cells to import necessary libraries, connect to our Organization, and create a new private blank CSV item." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# First, import some libraries we'll need, and connect to our GIS\n", "import csv\n", "import os\n", "import smtplib\n", "import requests\n", "import logging\n", "log = logging.getLogger()\n", "\n", "from arcgis.gis import GIS\n", "\n", "gis = GIS(\"home\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Secret CSV Item ID = '4fbaa460b3e347f09aea312a6d69b274'\n" ] }, { "data": { "text/html": [ "