|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# How to Use:\n", |
| 8 | + "This Notebook should ease the use of the API for \"cleanup\" tasks. It includes some sample for specific use cases that can be adjusted.\n", |
| 9 | + "1. run first block to prepare excecutions by creating api connection\n", |
| 10 | + "2. run any following block to execute a specific function" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": null, |
| 16 | + "metadata": {}, |
| 17 | + "outputs": [], |
| 18 | + "source": [ |
| 19 | + "import logging\n", |
| 20 | + "from ChurchToolsApi import ChurchToolsApi\n", |
| 21 | + "\n", |
| 22 | + "logging.getLogger().setLevel(logging.INFO)\n", |
| 23 | + "logging.info(\"Started main\")\n", |
| 24 | + "\n", |
| 25 | + "# Create Session\n", |
| 26 | + "from secure.config import ct_domain\n", |
| 27 | + "from secure.config import ct_token\n", |
| 28 | + "api = ChurchToolsApi(ct_domain)\n", |
| 29 | + "api.login_ct_rest_api(ct_token=ct_token)" |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "markdown", |
| 34 | + "metadata": {}, |
| 35 | + "source": [ |
| 36 | + "## Song Tag - mass change\n", |
| 37 | + "Helper to append a tag to all songs - e.g. 51 is tag:\"in ChurchTools vor Skript Import\"" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "code", |
| 42 | + "execution_count": null, |
| 43 | + "metadata": {}, |
| 44 | + "outputs": [], |
| 45 | + "source": [ |
| 46 | + "songs = api.get_songs()\n", |
| 47 | + "all_song_ids = [value['id'] for value in songs]\n", |
| 48 | + "for id in all_song_ids:\n", |
| 49 | + " api.add_song_tag(id, 51)" |
| 50 | + ] |
| 51 | + } |
| 52 | + ], |
| 53 | + "metadata": { |
| 54 | + "language_info": { |
| 55 | + "name": "python" |
| 56 | + }, |
| 57 | + "orig_nbformat": 4 |
| 58 | + }, |
| 59 | + "nbformat": 4, |
| 60 | + "nbformat_minor": 2 |
| 61 | +} |
0 commit comments