├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── requst-an-example.md └── workflows │ ├── links-pr-check.yaml │ └── links-scheduled-check.yml ├── .gitignore ├── .lycheeignore ├── .template └── README.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── REUSE.toml ├── advanced-availability-check ├── README.md ├── assets │ ├── access-tokens.png │ ├── graph-line.png │ ├── new-token.png │ ├── pie.png │ ├── stacked-column.png │ └── stacked.png └── catalog.json ├── assets └── autopi.svg ├── auto-scale-neo-app ├── README.md └── catalog.json ├── backup-catalog ├── README.md ├── assets │ ├── empty-repository.png │ ├── file-repository.png │ ├── finished-execution.png │ ├── github-token.png │ └── root-repository.png └── catalog.json ├── cf-apps-insights ├── README.md └── catalog.json ├── check-cf-space-quota-utilization ├── README.md ├── alert_notification_configuration.json ├── assets │ ├── ans-email.png │ ├── ans-subscription.png │ ├── applications-view.png │ ├── command-execution.png │ ├── org-quota.png │ ├── space-instances-view.png │ └── space-quota.png └── catalog.json ├── check-hana-cloud-audit-logs ├── README.md ├── assets │ └── audit-logs-error-message.png └── catalog.json ├── check-hana-cloud-availability ├── README.md ├── assets │ ├── ans-action-email.png │ ├── ans-custom-event.png │ ├── check-hana-availability-1.png │ ├── check-hana-availability-2.png │ ├── hana-executed-command-1-1.png │ ├── hana-executed-command-1.png │ ├── hana-executed-command-2.png │ ├── hana-started.png │ ├── hana-starting-AutoPi.png │ ├── hana-starting.png │ └── hana-stopped.png └── catalog.json ├── check-hana-cloud-backup ├── README.md ├── assets │ └── backup-error-message.png └── catalog.json ├── convert-json-to-html-table ├── README.md └── catalog.json ├── execute-script-via-k8s-job ├── README.md ├── assets │ ├── kubernetes-events.png │ ├── script-output.png │ └── successful-execution.png └── catalog.json ├── grant-privileges ├── README.md ├── assets │ ├── administrator-pipeline.png │ ├── developer-pipeline.png │ ├── finished-execution.png │ ├── mass-pipeline.png │ └── output-results.png └── catalog.json ├── http-cloud-connector ├── README.md ├── assets │ ├── automation-pilot-setup.png │ ├── btp-cockpit-cloud-connector.png │ ├── cloud-connector-admin-console.png │ ├── increase-timeout-screenshot.png │ └── ping-response.png └── catalog.json ├── http-oauth-client-credentials ├── README.md ├── assets │ ├── autoretry-setup-example.png │ └── oauth-setup-example.png └── catalog.json ├── mass-restart-cf-apps ├── README.md └── catalog.json ├── mass-stop-start-cf-apps ├── README.md ├── assets │ ├── mass-start-org.png │ ├── mass-stop-org.png │ └── mass-stop-summary.png └── catalog.json ├── mass-stop-start-hana-cloud ├── README.md ├── assets │ └── list-parameters.png └── catalog.json ├── patch-update-hana-cloud ├── README.md ├── assets │ ├── btp-cloud-foundry-env.png │ ├── confirmation-dialog.png │ ├── finished-update.png │ ├── hana-with-available-versions.png │ ├── paused-execution.png │ ├── running-update.png │ ├── update-summary.png │ └── updated-hana.png └── catalog.json ├── prepare-btp-environment ├── README.md ├── assets │ ├── finished-execution.png │ ├── output-results.png │ ├── pipeline.png │ ├── running-execution.png │ ├── service-instance.png │ └── subaccount-overview.png └── catalog.json ├── prepare-btp-subaccount ├── README.md ├── assets │ ├── btp-cockpit.png │ ├── btp-entitlements.png │ ├── cloud-management-authorization.png │ ├── finished-execution.png │ ├── pipeline.png │ ├── running-execution.png │ ├── service-instances.png │ └── subaccount-overview.png └── catalog.json ├── pretty-print-xml ├── README.md └── catalog.json ├── reassign-identity-provider ├── README.md ├── assets │ ├── finished-execution.png │ ├── output-results.png │ ├── reassign-all.png │ └── reassign-single.png └── catalog.json ├── remove-inactive-subaccount-users ├── README.md └── catalog.json ├── rotate-hana-cloud-db-credentials ├── README.md ├── assets │ ├── sap-btp-cockpit.png │ └── successful-rotation.png └── catalog.json ├── run-hana-cloud-stored-procedure ├── README.md └── catalog.json ├── script-http-request ├── README.md ├── assets │ ├── execution-output.png │ └── finished-execution.png └── catalog.json ├── transform-data ├── README.md └── catalog.json ├── trigger-and-collect-outputs-batching ├── README.md └── catalog.json ├── update-hana-cloud ├── README.md ├── assets │ ├── btp-cloud-foundry-env.png │ ├── confirmation-dialog.png │ ├── finished-update.png │ ├── hana-with-available-versions.png │ ├── paused-execution.png │ ├── running-update.png │ ├── update-summary.png │ └── updated-hana.png └── catalog.json ├── use-custom-npm-package ├── README.md └── catalog.json ├── use-custom-python-package ├── README.md └── catalog.json └── use-make-and-helm ├── README.md ├── catalog.json └── helm-example ├── Makefile └── chart ├── Chart.yaml ├── templates └── deployment.yaml └── values.yaml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: bisinho, kloyan 7 | 8 | --- 9 | 10 | **Affected Example** 11 | Example which is affected the by the bug. 12 | 13 | **Describe the bug** 14 | A clear and concise description of what the bug is. 15 | 16 | **To Reproduce** 17 | Steps to reproduce the behavior: 18 | 1. Go to command '...' 19 | 2. Click on '....' 20 | 3. Enter values '....' 21 | 4. See error 22 | 23 | **Expected behavior** 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Screenshots** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Tenant (please complete the following information):** 30 | - Automation Pilot Region: [e.g. cf-eu10] 31 | - Execution ID [e.g. T000000R4-0000000000000000000-0-0] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/requst-an-example.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Requst an Example 3 | about: Suggest a new example 4 | title: '' 5 | labels: enhancement 6 | assignees: bisinho, kloyan 7 | 8 | --- 9 | 10 | **Is your example request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context, screenshots or links about the example request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/links-pr-check.yaml: -------------------------------------------------------------------------------- 1 | name: Links PR Check 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, synchronize, reopened] 6 | 7 | jobs: 8 | linkChecker: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | 13 | - name: Restore lychee cache 14 | uses: actions/cache@v3 15 | with: 16 | path: .lycheecache 17 | key: cache-lychee-${{ github.sha }} 18 | restore-keys: cache-lychee- 19 | 20 | - name: Link Checker 21 | uses: lycheeverse/lychee-action@v1.9.3 22 | with: 23 | args: --cache --max-cache-age 1d --verbose --exclude-mail --no-progress './**/*.md' 24 | fail: true 25 | env: 26 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 27 | -------------------------------------------------------------------------------- /.github/workflows/links-scheduled-check.yml: -------------------------------------------------------------------------------- 1 | name: Links Scheduled Check 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: '35 14 * * *' 8 | 9 | jobs: 10 | linkChecker: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Restore lychee cache 16 | uses: actions/cache@v3 17 | with: 18 | path: .lycheecache 19 | key: cache-lychee-${{ github.sha }} 20 | restore-keys: cache-lychee- 21 | 22 | - name: Link Checker 23 | id: lychee 24 | uses: lycheeverse/lychee-action@v1.9.3 25 | with: 26 | args: --cache --max-cache-age 1d --verbose --exclude-mail --no-progress './**/*.md' 27 | env: 28 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 29 | 30 | - name: Create Issue From File 31 | if: env.lychee_exit_code != 0 32 | uses: peter-evans/create-issue-from-file@v4 33 | with: 34 | title: Link Checker Report 35 | content-filepath: ./lychee/out.md 36 | labels: report, automated issue 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # MacOS 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Visual Studio Code 7 | .vscode/ 8 | .history/ 9 | -------------------------------------------------------------------------------- /.lycheeignore: -------------------------------------------------------------------------------- 1 | developers.sap.com 2 | -------------------------------------------------------------------------------- /.template/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # [Title Example] 4 | 5 | Table of Contents 6 | 7 | * [Description](#description) 8 | * [Requirements](#requirements) 9 | * [How to use](#how-to-use) 10 | * [Expected result](#expected-result) 11 | 12 | ## Description 13 | 14 | 15 | 16 | ## Requirements 17 | 18 | To use this example you'll need the following: 19 | 20 | 21 | 22 | ## How to use 23 | 24 | 25 | 26 | ## Expected result 27 | 28 | 29 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, caste, color, religion, or sexual 11 | identity and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the overall 27 | community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or advances of 32 | any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email address, 36 | without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at ospo@sap.com (SAP Open Source Program Office). 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [Mozilla CoC]: https://github.com/mozilla/diversity 131 | [FAQ]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-PackageName = "automation-pilot-examples" 3 | SPDX-PackageSupplier = "support.autopilot@groups.sap.com" 4 | SPDX-PackageDownloadLocation = "https://github.com/sap-samples/automation-pilot-examples" 5 | SPDX-PackageComment = "The code in this project may include calls to APIs (\"API Calls\") of\n SAP or third-party products or services developed outside of this project\n (\"External Products\").\n \"APIs\" means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project's code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls." 6 | 7 | [[annotations]] 8 | path = "**" 9 | precedence = "aggregate" 10 | SPDX-FileCopyrightText = "2023 SAP SE or an SAP affiliate company and automation-pilot-examples contributors" 11 | SPDX-License-Identifier = "Apache-2.0" 12 | -------------------------------------------------------------------------------- /advanced-availability-check/README.md: -------------------------------------------------------------------------------- 1 | # Advanced Availability Check 2 | 3 | Table of Contents 4 | * [Description](#description) 5 | * [Requirements](#requirements) 6 | * [How to use](#how-to-use) 7 | 8 | ## Description 9 | 10 | **Advanced Availability Check** is designed to assess the availability of a given service and subsequently report the results to Dynatrace. This enables comprehensive monitoring, tracking of Service Level Agreements (SLAs) and data visualization within the Dynatrace platform. 11 | 12 | For demonstration and testing purposes, this example utilizes the HTTP Bin service. It is a simple HTTP request and response service, which allows for easy testing and exploration of HTTP requests and responses. However, this example can be readily adapted to fit specific customer requirements and use cases with different services. 13 | 14 | By following this documentation, can be implement an advanced and reliable mechanism to monitor the availability of services thereby enhancing the operational efficiency and service reliability. 15 | 16 | On top of that, availability checks can easily be performed on regular intervals (e.g. every 5 minutes or every hour) by using the [Scheduled Executions](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html) functionality in Automation Pilot. 17 | 18 | ## Requirements 19 | To use this example you’ll need the following: 20 | * Dynatrace setup with access token and environment url 21 | 22 | :information_source: How to setup your Dynatrace 23 | 24 | * From the left panel click on **Manage** and navigate to **Access Tokens** 25 | ![access-token](./assets/access-tokens.png) 26 | 27 | * Go to **Geneterate new token** 28 | * Chose a *token name* and *expiration date* 29 | * Add the *scopes* shown in the picture 30 | ![new-token](./assets/new-token.png) 31 | * Click on **Generate Token** and save your access token securely 32 | * The **environment url** can be cound in the *Dynatrace Environment API Documentation* 33 | 34 | :information_source: Result of the **Dynatrace** setup can be viewed in the **Data explorer** where different **Dashboards** can be configured. 35 | * *Stacked column chart for 2 metrics and 2 applications* 36 | ![stacked](./assets/stacked.png) 37 | * *Single value chart presenting the availability of an application* 38 | ![pie](./assets/pie.png) 39 | * *Graph chart for 2 metrics and 2 applications individually* 40 | ![graph-line](./assets/graph-line.png) 41 | 42 | :information_source: How to setup your Dynatrace Dashboards 43 | * Go to **Data Explorer** under **Observe and explore** 44 | * Chose the *type of chart* you want and use the values pushed with **PushDynatraceMetric** command in *dataPoints* 45 | * Select the *metric* 46 | * Split by the *category* 47 | * Filter by the *name* 48 | * Configure the Settings and Timeframes 49 | * Finally **Pin to dashboard** 50 | 51 | Check out the following resource for more information 52 | * [Dynatrace Documentation](https://docs.dynatrace.com/docs) 53 | * [Dynatrace Environment API Documentation](https://live.eu10.apm.services.cloud.sap/e/60049331-b187-4a09-8a99-be150740f608/rest-api-doc/index.jsp) 54 | 55 | ## How to use 56 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to AdvancedAvailabilityCheck command and trigger it. 57 | 58 | You’ll need to provide values for the following input keys: 59 | * *dynatraceApiToken* - Generated Dynatrace API Token 60 | * *dataPoints* - Custom data points 61 | * *dynatraceEnvironmentUrl* - Environment url for Dynatrace 62 | 63 | > :information_source: For the *dataPoints* follow this template 64 | > {metric},{category}={name} {payload} 65 | > 66 | > example: metricName, app=appA 1 -------------------------------------------------------------------------------- /advanced-availability-check/assets/access-tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/access-tokens.png -------------------------------------------------------------------------------- /advanced-availability-check/assets/graph-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/graph-line.png -------------------------------------------------------------------------------- /advanced-availability-check/assets/new-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/new-token.png -------------------------------------------------------------------------------- /advanced-availability-check/assets/pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/pie.png -------------------------------------------------------------------------------- /advanced-availability-check/assets/stacked-column.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/stacked-column.png -------------------------------------------------------------------------------- /advanced-availability-check/assets/stacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/advanced-availability-check/assets/stacked.png -------------------------------------------------------------------------------- /advanced-availability-check/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.tools.sap/sl-autopilot/community-commands", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": {}, 13 | "executors": [ 14 | { 15 | "execute": "http-sapcp:HttpRequest:1", 16 | "input": { 17 | "method": "GET", 18 | "url": "https://httpbin.org/delay/5", 19 | "timeout": "10" 20 | }, 21 | "alias": "getDelayEndpoint", 22 | "description": null, 23 | "progressMessage": null, 24 | "initialDelay": null, 25 | "pause": null, 26 | "when": null, 27 | "validate": null, 28 | "autoRetry": null, 29 | "repeat": null, 30 | "errorMessages": [], 31 | "dryRun": null 32 | }, 33 | { 34 | "execute": "http-sapcp:HttpRequest:1", 35 | "input": { 36 | "method": "POST", 37 | "url": "https://httpbin.org/delay/5", 38 | "timeout": "10" 39 | }, 40 | "alias": "postDelayEndpoint", 41 | "description": null, 42 | "progressMessage": null, 43 | "initialDelay": null, 44 | "pause": null, 45 | "when": null, 46 | "validate": null, 47 | "autoRetry": null, 48 | "repeat": null, 49 | "errorMessages": [], 50 | "dryRun": null 51 | }, 52 | { 53 | "execute": "http-sapcp:HttpRequest:1", 54 | "input": { 55 | "method": "GET", 56 | "url": "https://httpbin.org/stream/5", 57 | "timeout": "10" 58 | }, 59 | "alias": "streamJsonResponse", 60 | "description": null, 61 | "progressMessage": null, 62 | "initialDelay": null, 63 | "pause": null, 64 | "when": null, 65 | "validate": null, 66 | "autoRetry": null, 67 | "repeat": null, 68 | "errorMessages": [], 69 | "dryRun": null 70 | }, 71 | { 72 | "execute": "http-sapcp:HttpRequest:1", 73 | "input": { 74 | "method": "GET", 75 | "url": "https://httpbin.org/stream-bytes/100", 76 | "timeout": "10" 77 | }, 78 | "alias": "getRandomBytes", 79 | "description": null, 80 | "progressMessage": null, 81 | "initialDelay": null, 82 | "pause": null, 83 | "when": null, 84 | "validate": null, 85 | "autoRetry": null, 86 | "repeat": null, 87 | "errorMessages": [], 88 | "dryRun": null 89 | } 90 | ], 91 | "listeners": [ 92 | { 93 | "status": "FAILED", 94 | "execute": "dynatrace-sapcp:PushDynatraceMetric:1", 95 | "input": { 96 | "apiToken": "$(.execution.input.dynatraceApiToken)", 97 | "dataPoints": "$(.execution.inut.dynatraceDataPoints)", 98 | "environmentUrl": "$(.execution.input.dynatraceEnvironmentUrl)" 99 | }, 100 | "when": null 101 | }, 102 | { 103 | "status": "FINISHED", 104 | "execute": "dynatrace-sapcp:PushDynatraceMetric:1", 105 | "input": { 106 | "apiToken": "$(.execution.input.dynatraceApiToken)", 107 | "dataPoints": "$(.execution.inut.dynatraceDataPoints)", 108 | "environmentUrl": "$(.execution.input.dynatraceEnvironmentUrl)" 109 | }, 110 | "when": null 111 | } 112 | ] 113 | }, 114 | "id": "examples-<<>>:AdvancedAvailabilityCheck:1", 115 | "name": "AdvancedAvailabilityCheck", 116 | "description": null, 117 | "catalog": "examples-<<>>", 118 | "version": 1, 119 | "inputKeys": { 120 | "dynatraceApiToken": { 121 | "type": "string", 122 | "sensitive": true, 123 | "required": true, 124 | "minSize": null, 125 | "maxSize": null, 126 | "minValue": null, 127 | "maxValue": null, 128 | "allowedValues": null, 129 | "allowedValuesFromInputKeys": null, 130 | "suggestedValues": null, 131 | "suggestedValuesFromInputKeys": null, 132 | "defaultValue": null, 133 | "defaultValueFromInput": null, 134 | "description": "Generated Dynatrace API Token" 135 | }, 136 | "dynatraceDataPoints": { 137 | "type": "string", 138 | "sensitive": true, 139 | "required": true, 140 | "minSize": null, 141 | "maxSize": null, 142 | "minValue": null, 143 | "maxValue": null, 144 | "allowedValues": null, 145 | "allowedValuesFromInputKeys": null, 146 | "suggestedValues": null, 147 | "suggestedValuesFromInputKeys": null, 148 | "defaultValue": null, 149 | "defaultValueFromInput": null, 150 | "description": "Custom data points, provided in the following syntax: metric.key,dimensions payload" 151 | }, 152 | "dynatraceEnvironmentUrl": { 153 | "type": "string", 154 | "sensitive": false, 155 | "required": true, 156 | "minSize": null, 157 | "maxSize": null, 158 | "minValue": null, 159 | "maxValue": null, 160 | "allowedValues": null, 161 | "allowedValuesFromInputKeys": null, 162 | "suggestedValues": null, 163 | "suggestedValuesFromInputKeys": null, 164 | "defaultValue": null, 165 | "defaultValueFromInput": null, 166 | "description": "Environment url for Dynatrace, e.g.: for managed - https://{your-domain}/e/{your-environment-id} & for saas: https://{your-environment-id}.live.dynatrace.com" 167 | } 168 | }, 169 | "outputKeys": {}, 170 | "tags": { 171 | "feature:logs": "", 172 | "feature:priority": "medium" 173 | } 174 | } 175 | ] 176 | } -------------------------------------------------------------------------------- /assets/autopi.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /auto-scale-neo-app/README.md: -------------------------------------------------------------------------------- 1 | # Auto Scale Neo Application 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | BTP Neo this does not provide a full-fledged and flexible autoscaling option. This example shows how to achieve such functionality. The command monitores your application and scales it up or down automatically, based on predefined rules. 12 | 13 | Furthermore, with the help of SAP Alert Notification this command can be automatically triggered whenever the CPU load metric of your application instance reaches a critical level. 14 | 15 | This example is described in further details by this blog post: [Application autoscaling with Automation Pilot and Alert Notification](https://blogs.sap.com/2021/06/04/application-autoscaling-with-automation-pilot-and-alert-notification-in-sap-btp-neo-environment/) 16 | 17 | ## Requirements 18 | 19 | To use this example you'll need the following: 20 | 21 | * SAP BTP Neo subaccount with at least one Java application 22 | * At least one quota which is necessary for the application upscaling 23 | * OAuth client credentials with sufficient scope for application management and access to monitoring data 24 | 25 | Check out the following resources for more information: 26 | 27 | * [Deploying and Updating Java Applications](https://help.sap.com/docs/btp/sap-btp-neo-environment/deploying-and-updating-java-applications) 28 | * [Using Platform APIs](https://help.sap.com/docs/BTP/ea72206b834e4ace9cd834feed6c0e09/using-platform-apis-84c881e4e30e43848b9b2f8401368020) 29 | 30 | ## How to use 31 | 32 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *AutoScaleNeoApp* command and trigger it. 33 | 34 | You'll need to provide values for the following input keys: 35 | 36 | * *region* - Technical name of your SAP BTP region, e.g. neo-eu1, neo-us2 37 | * *subAccount* - Name of your SAP BTP subaccount 38 | * *resourceName* - Name of your Java application 39 | * *clientId* - Neo Platform API client id 40 | * *clientSecret* - Neo Platform API client secret 41 | * *scaleUpThreshold* - Optional: CPU load threshold in percentage for scaling up an instance. Defaults to 70 42 | * *scaleDownThreshold* - Optional: CPU load threshold in percentage for scaling down an instance. Defaults to 30 43 | -------------------------------------------------------------------------------- /backup-catalog/README.md: -------------------------------------------------------------------------------- 1 | # Backup Automation Pilot Catalogs to GitHub 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | Automation Pilot allows customers to create their own catalogs and populate them with custom commands and inputs which are based on the provided ones. Customers can [export](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/48ee09640e094bcb9601d845f316f773.html) these catalogs from the UI and store them somewhere as a backup. If needed, they could be imported back into the same or another Automation Pilot tenant. 13 | 14 | In this example, we'll look over a command that automates the Automation Pilot catalog backup process. This command utilizes the Automation Pilot and GitHub APIs to extend the service's functionality. 15 | 16 | It performs the following steps: 17 | 18 | * Gets all commands and inputs which are part of a specified catalog by using the [Automation Pilot APIs](https://api.sap.com/package/SAPCloudPlatformAutomationPilot/rest) 19 | * Stores the result in a GitHub repository by creating or updating a file at a given path 20 | 21 | :warning: Values that are marked as sensitive in your inputs will not be backed up. 22 | 23 | On top of that, backup easily be performed on regular intervals (e.g., every day or week) by using the [Scheduled Executions](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html) functionality in Automation Pilot. 24 | 25 | ## Requirements 26 | 27 | To use this example you'll need the following: 28 | 29 | * Repository in a GitHub Enterprise server 30 | * Personal access token of a user with write access to the repository. Note that if your repository is private, token must be granted the *repo* scope 31 | * Automation Pilot service account with 'Read' permissions 32 | 33 | Check out the following resources for more information: 34 | 35 | * [Create a GitHub repository](https://docs.github.com/en/get-started/quickstart/create-a-repo) 36 | * [Managing teams and people with access to your GitHub repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-teams-and-people-with-access-to-your-repository) 37 | * [Creating a GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) 38 | * [Managing Automation Pilot Service Accounts](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/91713d7e71624dbf92ea43f5faf810e5.html) 39 | 40 | ## How to use 41 | 42 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *BackupCatalog* command and trigger it. 43 | 44 | You'll need to provide values for the following input keys: 45 | 46 | * *githubServer* - URL to the GitHub Enterprise server 47 | * *repository* - Name of the GitHub repository 48 | * *owner* - Account owner of the GitHub repository. This could be the name of a personal account or organization 49 | * *branch* - Name of the GitHub branch, e.g., *main* or *master* 50 | * *token* - GitHub personal access token 51 | * *user* - Name of the Automation Pilot service account 52 | * *password* - Password of the Automation Pilot service account 53 | * *catalog* - Technical name of the Automation Pilot catalog to backup 54 | 55 | :warning: The GitHub branch must already exists. Also, it must not have any branch protection or mandatory review requirements. Your user must be enable to directly push commits to it. 56 | 57 | ## Expected result 58 | 59 | Let's prepare a brand new GitHub Enterprise repository called *example-repo* (you can also use an existing one): 60 | 61 | ![Empty GitHub Repository](assets/empty-repository.png) 62 | 63 | We'll also create a GitHub personal access token with the *repo* scope: 64 | 65 | ![GitHub Token](assets/github-token.png) 66 | 67 | We'll start the execution with the following input. Some of the keys are omitted for brevity: 68 | 69 | * *catalog* - welcome 70 | * *path* - catalogs 71 | * *branch* - main 72 | 73 | Once triggered, the execution should quickly finish successfully: 74 | 75 | ![Finished Execution](assets/finished-execution.png) 76 | 77 | Going back to the GitHub repository, we can see that the catalog content is uploaded: 78 | 79 | ![Root GitHub Repository](assets/root-repository.png) 80 | 81 | ![File GitHub Repository](assets/file-repository.png) 82 | -------------------------------------------------------------------------------- /backup-catalog/assets/empty-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/backup-catalog/assets/empty-repository.png -------------------------------------------------------------------------------- /backup-catalog/assets/file-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/backup-catalog/assets/file-repository.png -------------------------------------------------------------------------------- /backup-catalog/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/backup-catalog/assets/finished-execution.png -------------------------------------------------------------------------------- /backup-catalog/assets/github-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/backup-catalog/assets/github-token.png -------------------------------------------------------------------------------- /backup-catalog/assets/root-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/backup-catalog/assets/root-repository.png -------------------------------------------------------------------------------- /cf-apps-insights/README.md: -------------------------------------------------------------------------------- 1 | # :sparkles: Cloud Foundry Apps Insights 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | Effortlessly identify the state of your Cloud Foundry applications using **CloudFoundryAppsInsights** example command, enhanced by the power of Gen AI. 12 | 13 | Gain valuable insights into the health and performance of each of your CF applications. Verify their state and receive short summary, empowering you to take proactive measures and maintain optimal functionality. 14 | 15 | 16 | Leveraging the capabilities of `gpt4o`, this command provides insights and useful suggestions for critical actions such as application restarts, instances increase, quota adjustments and e.g. 17 | 18 | Here are example Cloud Foundry Apps Insights: 19 | 20 | 21 | > 1. red-app: 22 | > - There are 3 instances running. 23 | > - The states of the instances are: RUNNING, RUNNING, RUNNING. 24 | > - The CPU usage for the instances are: 1.78%, 1.91%, 1.61% respectively. 25 | > - The memory usage for the instances are: 131.4MB (0.13GB), 134.7MB (0.13GB), 129.6MB (0.13GB) respectively. 26 | > - The applications have been up for 50894 seconds (841.57 minutes, 14.03 hours), 55215 seconds (920.25 minutes, 15.34 hours), > 7589 seconds (126.48 minutes, 2.11 hours) respectively. 27 | > - Suggestions: No action needed. 28 | > 29 | > 2. blue-app: 30 | > - There is 1 instance running. 31 | > - The state of the instance is: RUNNING. 32 | > - The CPU usage is: 1.91%. 33 | > - The memory usage is: 133.8MB (0.13GB). 34 | > - The application has been up for 49579 seconds (826.32 minutes, 13.77 hours). 35 | > - Suggestions: Consider increasing the number of instances. 36 | > 37 | > 3. green-app: 38 | > - There are 2 instances running. 39 | > - The states of the instances are: RUNNING, RUNNING. 40 | > - The CPU usage for the instances are: 1.60%, 1.96% respectively. 41 | > - The memory usage for the instances are: 129.4MB (0.12GB), 126.0MB (0.12GB) respectively. 42 | > - The applications have been up for 49554 seconds (825.9 minutes, 13.76 hours), 59444 seconds (990.73 minutes, 16.51 hours) > respectively. 43 | > - Suggestions: No action needed. 44 | > 45 | > 4. yellow-app: 46 | > - There is 1 instance and it is not running. 47 | > - The state of the application is: DOWN. 48 | > - The CPU and memory usage are not available as the application is not running. 49 | > - The application has not been alive (uptime is 0). 50 | > - Suggestions: The application is down, please restart the application. Also, consider increasing the number of instances. 51 | 52 | ## Requirements 53 | 54 | To use this example you'll need the following: 55 | * Cloud Foundry space with at least one application 56 | * Technical user with *Space Developer* role 57 | * Ai Core service instance with service key for authentication 58 | * SAP AI Launchpad application 59 | * Deployment for `gpt4o` 60 | 61 | Check out the following resources for more information: 62 | * [SAP AI Core Initial Setup](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/initial-setup?locale=en-US) 63 | * [SAP AI Core Documentation](https://help.sap.com/docs/sap-ai-core?locale=en-US) 64 | * [Tutorial for AI Core](https://developers.sap.com/tutorials/ai-core-generative-ai.html) 65 | 66 | 67 | ## How to use 68 | 69 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the **CloudFoundryAppsInsights** command and trigger it. 70 | 71 | You'll need to provide values for the following input keys: 72 | 73 | * *deploymentId* - ID of the deployment for gpt4о which will execute the query 74 | * *serviceKey* - Service key for the SAP AI Core service 75 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20 76 | * *subAccount* - Name of your Cloud Foundry organization 77 | * *resourceGroup* - Name of your Cloud Foundry space 78 | * *user* - Email or ID of your technical user 79 | * *password* - Password of your technical user 80 | * *identityProvider* - Identity provider to be used 81 | 82 | :information_source: Some of the needed information is available in your subaccount's *Overview* page under *Cloud Foundry Environment*. 83 | 84 | :information_source: **CloudFoundryAppsInsights** example uses model `gpt4o` and with small changes the insights can be modified in the prompt. 85 | 86 | :warning: Using a subaccount with fewer applications and instances enhances the accuracy of GPT model responses. -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/alert_notification_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "actions": [ 3 | { 4 | "type": "EMAIL", 5 | "name": "my-email", 6 | "state": "ENABLED", 7 | "properties": { 8 | "destination": "<>", 9 | "useHtml": "false" 10 | } 11 | } 12 | ], 13 | "conditions": [ 14 | { 15 | "name": "match-resource-quota-events", 16 | "mandatory": false, 17 | "propertyKey": "eventType", 18 | "predicate": "CONTAINS", 19 | "propertyValue": "ResourceQuotaUtilization", 20 | "labels": [], 21 | "description": "" 22 | } 23 | ], 24 | "subscriptions": [ 25 | { 26 | "name": "forward-resource-quota-events-to-my-mail", 27 | "conditions": [ 28 | "match-resource-quota-events" 29 | ], 30 | "actions": [ 31 | "my-email" 32 | ], 33 | "state": "ENABLED" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/ans-email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/ans-email.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/ans-subscription.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/ans-subscription.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/applications-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/applications-view.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/command-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/command-execution.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/org-quota.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/org-quota.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/space-instances-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/space-instances-view.png -------------------------------------------------------------------------------- /check-cf-space-quota-utilization/assets/space-quota.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-cf-space-quota-utilization/assets/space-quota.png -------------------------------------------------------------------------------- /check-hana-cloud-audit-logs/README.md: -------------------------------------------------------------------------------- 1 | # Check HANA Cloud Database Audit Log Entries 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | Auditing allows you to monitor and record selected actions performed in the SAP HANA Cloud database. It can help you achieve better security in the following ways: 12 | 13 | * Uncover security vulnerabilities 14 | * Show attempts to breach security 15 | 16 | This example commands performs an SQL query to find any audit log entries that might be considered suspicious. It does so by pulling data from the [AUDIT_LOG system view](https://help.sap.com/docs/HANA_SERVICE_CF/7c78579ce9b14a669c1f3295b0d8ca16/d1fe1244d29510148f69be8b0e060dcc.html). If there is at least one such audit log entry, the execution fails with an error message: 17 | 18 | ![Screenshot](assets/audit-logs-error-message.png) 19 | 20 | :information_source: SQL query should be modified to fit the user's needs and to better detect audit log entries which should be treated as suspicious. 21 | 22 | ## Requirements 23 | 24 | To use this example you'll need the following: 25 | 26 | * SAP HANA Cloud database 27 | * Enabled HANA Cloud auditing as described [here](https://learning.sap.com/learning-journey/provision-and-administer-databases-in-sap-hana-cloud/auditing-in-sap-hana-cloud_a6522675-08c8-45ac-801d-a2f7afe00550) 28 | * Database user with a AUDIT ADMIN, AUDIT OPERATOR, or AUDIT READ system privilege 29 | * JDBC URL of the following format: `jdbc:sap://:` 30 | * Allowed connections from Automation Pilot to your HANA Cloud database. Use [this procedure](https://help.sap.com/docs/HANA_SERVICE_CF/cc53ad464a57404b8d453bbadbc81ceb/71eb651f84274a0cb2f2b4380df91724.html) to add the NAT IPs of the [relevant Automation Pilot region](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/4536e41c57aa442095ccbac977965f26.html#regions). 31 | 32 | Check out the following resources for more information: 33 | 34 | * [Deploy SAP HANA Cloud](https://developers.sap.com/tutorials/hana-cloud-deploying.html) 35 | * [Create Users and Manage Roles and Privileges](https://developers.sap.com/tutorials/hana-cloud-mission-trial-4.html) 36 | * [Connect to the SAP HANA Database in SAP HANA Cloud via JDBC](https://help.sap.com/docs/HANA_CLOUD/db19c7071e5f4101837e23f06e576495/030a162d380b4ec0bc6a284954c8256d.html) 37 | * [Auditing Database Activity](https://help.sap.com/docs/HANA_CLOUD/9630e508caef4578b34db22014998dba/a7b91b9ce5864056a6868ddf5d036833.html) 38 | 39 | ## How to use 40 | 41 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *CheckHanaCloudAuditLogs* command and trigger it. 42 | 43 | You'll need to provide values for the following input keys: 44 | 45 | * *connectionUrl* - JDBC connection URL for the database 46 | * *user* - Name of a database user 47 | * *password* - Password for the specified database user 48 | 49 | :information_source: If you applied SAP's recommended auditing policies settings, you can use the following SQL statement to simulate some suspicious activity: 50 | 51 | ```sql 52 | -- Create temporary test role 53 | CREATE ROLE TEST_ROLE; 54 | 55 | -- Simulate suspicious activity with first user 56 | CREATE USER TEST_USER_1 PASSWORD Abcd1234; 57 | GRANT TEST_ROLE TO TEST_USER_1; 58 | VALIDATE USER TEST_USER_1 PASSWORD Abcd1234; 59 | DROP USER TEST_USER_1; 60 | 61 | -- Simulate suspicious activity with second user 62 | CREATE USER TEST_USER_2 PASSWORD Abcd1234; 63 | GRANT TEST_ROLE TO TEST_USER_2; 64 | VALIDATE USER TEST_USER_2 PASSWORD Abcd1234; 65 | DROP USER TEST_USER_2; 66 | 67 | -- Drop temporary test role 68 | DROP ROLE TEST_ROLE; 69 | ``` 70 | 71 | This command is most useful when executed every day. Automation Pilot allows executions to be automatically triggered on regular intervals - hourly, daily, weekly, monthly or yearly. You can find more details in the [documentation](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html). 72 | 73 | Another important aspect is alerting. It's important to receive notifications (in the form of email, slack message, Jira ticket or other) whenever the *CheckHanaCloudAuditLogs* command finds suspicious audit log entries. This could be easily achieved with the help of SAP Alert Notification. More information can be found [here](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/e75533639c6d4193aa8a7e7420c25f8c.html). 74 | -------------------------------------------------------------------------------- /check-hana-cloud-audit-logs/assets/audit-logs-error-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-audit-logs/assets/audit-logs-error-message.png -------------------------------------------------------------------------------- /check-hana-cloud-audit-logs/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": {}, 13 | "executors": [ 14 | { 15 | "execute": "sql-sapcp:ExecuteHanaCloudSqlStatement:1", 16 | "input": { 17 | "password": "$(.execution.input.password)", 18 | "statement": "SELECT\n AUDIT_POLICY_NAME,\n USER_NAME,\n APPLICATION_NAME,\n APPLICATION_USER_NAME,\n COUNT(*)\nFROM\n AUDIT_LOG\nWHERE\n TIMESTAMP > (ADD_SECONDS(CURRENT_TIMESTAMP, -86400))\n AND NOT (\n (\n AUDIT_POLICY_NAME = 'All successful logins'\n AND USER_NAME NOT IN ('DBADMIN')\n )\n OR (\n AUDIT_POLICY_NAME = 'All unsuccessful logins'\n AND USER_NAME = NULL\n )\n OR (\n AUDIT_POLICY_NAME = 'Authorizations changes'\n AND USER_NAME IN ('SYSTEM', '_SYS_DI_TO')\n )\n OR (\n AUDIT_POLICY_NAME = 'User administration'\n AND USER_NAME IN ('SYSTEM', '_SYS_DI_TO')\n )\n OR (\n AUDIT_POLICY_NAME = 'HDI administration'\n AND USER_NAME IN ('SYSTEM', '_SYS_DI_TO')\n )\n )\nGROUP BY\n AUDIT_POLICY_NAME,\n USER_NAME,\n APPLICATION_NAME,\n APPLICATION_USER_NAME;", 19 | "connectionUrl": "$(.execution.input.connectionUrl)", 20 | "user": "$(.execution.input.user)", 21 | "timeout": "10" 22 | }, 23 | "alias": "ReadAuditLogs", 24 | "progressMessage": null, 25 | "initialDelay": null, 26 | "pause": null, 27 | "when": null, 28 | "validate": { 29 | "semantic": "OR", 30 | "conditions": [ 31 | { 32 | "semantic": "OR", 33 | "cases": [ 34 | { 35 | "expression": "$( [.ReadAuditLogs.output.result | toArray[][] ] | length)", 36 | "operator": "EQUALS", 37 | "semantic": "OR", 38 | "values": [ 39 | "0" 40 | ] 41 | } 42 | ] 43 | } 44 | ] 45 | }, 46 | "autoRetry": null, 47 | "repeat": null, 48 | "errorMessages": [ 49 | { 50 | "message": "Detected suspicious audit log entries in the policies listed below. Please check if these activities are justified:$(\"\\n\\n\")$(.ReadAuditLogs.output.result | toArray[] | map(\"\\(.[0]) by \\(.[1] // \"UNKNOWN\") (\\(.[4]) entries)\") | join(\"\\n\"))", 51 | "when": { 52 | "semantic": "OR", 53 | "conditions": [ 54 | { 55 | "semantic": "AND", 56 | "cases": [ 57 | { 58 | "expression": "$( [.ReadAuditLogs.output.result | toArray[][] ] | length)", 59 | "operator": "GREATER_THAN", 60 | "semantic": "OR", 61 | "values": [ 62 | "0" 63 | ] 64 | } 65 | ] 66 | } 67 | ] 68 | } 69 | } 70 | ] 71 | } 72 | ], 73 | "listeners": [] 74 | }, 75 | "id": "examples-<<>>:CheckHanaCloudAuditLogs:1", 76 | "name": "CheckHanaCloudAuditLogs", 77 | "description": "Checks HANA Cloud database for any suspicious audit logs in the last day.", 78 | "catalog": "examples-<<>>", 79 | "version": 1, 80 | "inputKeys": { 81 | "password": { 82 | "type": "string", 83 | "sensitive": true, 84 | "required": true, 85 | "minSize": null, 86 | "maxSize": null, 87 | "minValue": null, 88 | "maxValue": null, 89 | "allowedValues": null, 90 | "allowedValuesFromInputKeys": null, 91 | "suggestedValues": null, 92 | "suggestedValuesFromInputKeys": null, 93 | "defaultValue": null, 94 | "defaultValueFromInput": null, 95 | "description": "Password for the specified database user." 96 | }, 97 | "connectionUrl": { 98 | "type": "string", 99 | "sensitive": false, 100 | "required": true, 101 | "minSize": null, 102 | "maxSize": null, 103 | "minValue": null, 104 | "maxValue": null, 105 | "allowedValues": null, 106 | "allowedValuesFromInputKeys": null, 107 | "suggestedValues": null, 108 | "suggestedValuesFromInputKeys": null, 109 | "defaultValue": null, 110 | "defaultValueFromInput": null, 111 | "description": "JDBC connection URL for the database." 112 | }, 113 | "user": { 114 | "type": "string", 115 | "sensitive": false, 116 | "required": true, 117 | "minSize": null, 118 | "maxSize": null, 119 | "minValue": null, 120 | "maxValue": null, 121 | "allowedValues": null, 122 | "allowedValuesFromInputKeys": null, 123 | "suggestedValues": null, 124 | "suggestedValuesFromInputKeys": null, 125 | "defaultValue": null, 126 | "defaultValueFromInput": null, 127 | "description": "Name of a database user." 128 | } 129 | }, 130 | "outputKeys": {}, 131 | "tags": {} 132 | } 133 | ] 134 | } -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/ans-action-email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/ans-action-email.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/ans-custom-event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/ans-custom-event.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/check-hana-availability-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/check-hana-availability-1.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/check-hana-availability-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/check-hana-availability-2.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-executed-command-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-executed-command-1-1.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-executed-command-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-executed-command-1.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-executed-command-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-executed-command-2.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-started.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-started.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-starting-AutoPi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-starting-AutoPi.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-starting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-starting.png -------------------------------------------------------------------------------- /check-hana-cloud-availability/assets/hana-stopped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-availability/assets/hana-stopped.png -------------------------------------------------------------------------------- /check-hana-cloud-backup/README.md: -------------------------------------------------------------------------------- 1 | # Check HANA Cloud Database Backup 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | A full backup of your SAP HANA Cloud database is [taken automatically](https://help.sap.com/docs/HANA_CLOUD/9ae9104a46f74a6583ce5182e7fb20cb/89d71f01daca4ecaaa069d6a060167f5.html) once per day. Nevertheless, as a save measure we can create an Automation Pilot command which verifies that there was a recent backup of the database. 12 | 13 | This example command performs an SQL query to find the most recent backup by pulling The pulling data from the [M_BACKUP_CATALOG system view](https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/20a8437d7519101495a3fa7ad9961cf6.html). If the last successful backup is older than the specified threshold, the execution fails with an error message: 14 | 15 | ![Screenshot](assets/backup-error-message.png) 16 | 17 | ## Requirements 18 | 19 | To use this example you'll need the following: 20 | 21 | * SAP HANA Cloud database 22 | * Database user 23 | * JDBC URL of the following format: `jdbc:sap://:` 24 | * Allowed connections from Automation Pilot to your HANA Cloud database. Use [this procedure](https://help.sap.com/docs/HANA_SERVICE_CF/cc53ad464a57404b8d453bbadbc81ceb/71eb651f84274a0cb2f2b4380df91724.html) to add the NAT IPs of the [relevant Automation Pilot region](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/4536e41c57aa442095ccbac977965f26.html#regions). 25 | 26 | Check out the following resources for more information: 27 | 28 | * [Deploy SAP HANA Cloud](https://developers.sap.com/tutorials/hana-cloud-deploying.html) 29 | * [Create Users and Manage Roles and Privileges](https://developers.sap.com/tutorials/hana-cloud-mission-trial-4.html) 30 | * [Connect to the SAP HANA Database in SAP HANA Cloud via JDBC](https://help.sap.com/docs/HANA_CLOUD/db19c7071e5f4101837e23f06e576495/030a162d380b4ec0bc6a284954c8256d.html) 31 | 32 | ## How to use 33 | 34 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *CheckHanaCloudBackup* command and trigger it. 35 | 36 | You'll need to provide values for the following input keys: 37 | 38 | * *connectionUrl* - JDBC connection URL for the database 39 | * *user* - Name of a database user 40 | * *password* - Password for the specified database user 41 | * *ageThreshold* - Backup age threshold in days. Defaults to 3 days 42 | 43 | This command is most useful when executed every day. Automation Pilot allows executions to be automatically triggered on regular intervals - hourly, daily, weekly, monthly or yearly. You can find more details in the [documentation](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html). 44 | 45 | Another important aspect is alerting. It's important to receive notifications (in the form of email, slack message, Jira ticket or other) whenever the *CheckHanaCloudBackup* command fails to find a recent backup. This could be easily achieved with the help of SAP Alert Notification. More information can be found [here](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/e75533639c6d4193aa8a7e7420c25f8c.html). 46 | -------------------------------------------------------------------------------- /check-hana-cloud-backup/assets/backup-error-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/check-hana-cloud-backup/assets/backup-error-message.png -------------------------------------------------------------------------------- /check-hana-cloud-backup/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": {}, 13 | "executors": [ 14 | { 15 | "execute": "sql-sapcp:ExecuteHanaCloudSqlStatement:1", 16 | "input": { 17 | "password": "$(.execution.input.password)", 18 | "resultTransformer": "toArray[0][0][0]", 19 | "statement": "SELECT MAX(ENTRY_ID)\nFROM SYS.M_BACKUP_CATALOG\nWHERE ENTRY_TYPE_NAME = 'complete data backup' AND STATE_NAME = 'successful'", 20 | "connectionUrl": "$(.execution.input.connectionUrl)", 21 | "user": "$(.execution.input.user)" 22 | }, 23 | "alias": "CheckBackup", 24 | "progressMessage": null, 25 | "initialDelay": null, 26 | "pause": null, 27 | "when": null, 28 | "validate": { 29 | "semantic": "OR", 30 | "conditions": [ 31 | { 32 | "semantic": "OR", 33 | "cases": [ 34 | { 35 | "expression": "$(nowMillis - (.CheckBackup.output.result | toNumber) < (.execution.input.ageThreshold * 24 * 60 * 60 * 1000))", 36 | "operator": "EQUALS", 37 | "semantic": "OR", 38 | "values": [ 39 | "true" 40 | ] 41 | } 42 | ] 43 | } 44 | ] 45 | }, 46 | "autoRetry": null, 47 | "repeat": null, 48 | "errorMessages": [ 49 | { 50 | "message": "No database backup in $(.execution.input.ageThreshold) day(s). Last backup was on $(.CheckBackup.output.result | toNumber | toDate(\"yyyy-MM-dd HH:mm:ss\"))", 51 | "when": { 52 | "semantic": "OR", 53 | "conditions": [ 54 | { 55 | "semantic": "OR", 56 | "cases": [ 57 | { 58 | "expression": "$(.CheckBackup.output.errorCode == null)", 59 | "operator": "EQUALS", 60 | "semantic": "OR", 61 | "values": [ 62 | "true" 63 | ] 64 | } 65 | ] 66 | } 67 | ] 68 | } 69 | } 70 | ] 71 | } 72 | ], 73 | "listeners": [] 74 | }, 75 | "id": "examples-<<>>:CheckHanaCloudBackup:1", 76 | "name": "CheckHanaCloudBackup", 77 | "description": "Checks whether there was a recent backup of the database", 78 | "catalog": "examples-<<>>", 79 | "version": 1, 80 | "inputKeys": { 81 | "password": { 82 | "type": "string", 83 | "sensitive": true, 84 | "required": true, 85 | "minSize": null, 86 | "maxSize": null, 87 | "minValue": null, 88 | "maxValue": null, 89 | "allowedValues": null, 90 | "allowedValuesFromInputKeys": null, 91 | "suggestedValues": null, 92 | "suggestedValuesFromInputKeys": null, 93 | "defaultValue": null, 94 | "defaultValueFromInput": null, 95 | "description": "Password for the specified database user." 96 | }, 97 | "connectionUrl": { 98 | "type": "string", 99 | "sensitive": false, 100 | "required": true, 101 | "minSize": null, 102 | "maxSize": null, 103 | "minValue": null, 104 | "maxValue": null, 105 | "allowedValues": null, 106 | "allowedValuesFromInputKeys": null, 107 | "suggestedValues": null, 108 | "suggestedValuesFromInputKeys": null, 109 | "defaultValue": null, 110 | "defaultValueFromInput": null, 111 | "description": "JDBC connection URL for the database" 112 | }, 113 | "ageThreshold": { 114 | "type": "number", 115 | "sensitive": false, 116 | "required": false, 117 | "minSize": null, 118 | "maxSize": null, 119 | "minValue": null, 120 | "maxValue": null, 121 | "allowedValues": null, 122 | "allowedValuesFromInputKeys": null, 123 | "suggestedValues": null, 124 | "suggestedValuesFromInputKeys": null, 125 | "defaultValue": "3", 126 | "defaultValueFromInput": null, 127 | "description": "Backup age threshold in days" 128 | }, 129 | "user": { 130 | "type": "string", 131 | "sensitive": false, 132 | "required": true, 133 | "minSize": null, 134 | "maxSize": null, 135 | "minValue": null, 136 | "maxValue": null, 137 | "allowedValues": null, 138 | "allowedValuesFromInputKeys": null, 139 | "suggestedValues": null, 140 | "suggestedValuesFromInputKeys": null, 141 | "defaultValue": null, 142 | "defaultValueFromInput": null, 143 | "description": "Name of a database user." 144 | } 145 | }, 146 | "outputKeys": {}, 147 | "tags": {} 148 | } 149 | ] 150 | } -------------------------------------------------------------------------------- /convert-json-to-html-table/README.md: -------------------------------------------------------------------------------- 1 | # Convert JSON to HTML Table 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Examples](#examples) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to convert a JSON array of objects into an HTML table. The command processes the JSON data and generates an HTML table string that can be used in web pages, embedded in emails, or other HTML-supported environments. 13 | 14 | You can use the following approaches to send the HTML table via email: 15 | 16 | * Create an [Email Action](https://help.sap.com/docs/alert-notification/sap-alert-notification-for-sap-btp/email-action-type?locale=en-US) with a custom template in the SAP Alert Notification service, and then send the HTML table using the [SendAnsEvent command](https://help.sap.com/docs/automation-pilot/automation-pilot/sendansevent?locale=en-US). 17 | * Directly send the HTML table using the [SendEmail command](https://help.sap.com/docs/automation-pilot/automation-pilot/sendemail-command?locale=en-US) with HTML formatting enabled. 18 | 19 | ## Requirements 20 | 21 | There are no specific requirements to use this example, other than having a JSON array of objects as input data. 22 | 23 | ## How to use 24 | 25 | Import the content of the [examples catalog](catalog.json) into your Automation Pilot tenant. Navigate to the *ConvertJsonToHtmlTable* command and trigger it. 26 | 27 | ## Examples 28 | 29 | ### Basic Example 30 | 31 | *JSON Array Input* 32 | 33 | ```json 34 | [ 35 | { 36 | "name": "John", 37 | "age": 30, 38 | "city": "New York", 39 | "state": "NY" 40 | }, 41 | { 42 | "name": "Jane", 43 | "age": 25, 44 | "city": "Los Angeles", 45 | "state": "CA" 46 | }, 47 | { 48 | "name": "Tom", 49 | "age": 35, 50 | "city": "Chicago", 51 | "state": "IL" 52 | }, 53 | { 54 | "name": "Sue", 55 | "age": 40, 56 | "city": "Houston", 57 | "state": "TX" 58 | } 59 | ] 60 | ``` 61 | 62 | *HTML Table Result* 63 | 64 |
agecitynamestate
30New YorkJohnNY
25Los AngelesJaneCA
35ChicagoTomIL
40HoustonSueTX
65 | 66 | ### Advanced Example 67 | 68 | *JSON Array Input* 69 | 70 | ```json 71 | [ 72 | { 73 | "name": "OS Memory Usage", 74 | "state": "Ok", 75 | "value": 42, 76 | "unit": "%", 77 | "timestamp": 1732608880000, 78 | "output": "OK: MemoryValue: 42 (W> 98, C> 98) " 79 | }, 80 | { 81 | "name": "Disk I/O", 82 | "state": "Ok", 83 | "value": 65327, 84 | "unit": "B/s", 85 | "timestamp": 1732608880000, 86 | "output": "OK: DiskRead: 0 B/s (W> 10000000, C> 15000000) DiskWrite: 65327 B/s (W> 10000000, C> 15000000)" 87 | }, 88 | { 89 | "name": "Average Response Time", 90 | "state": "Ok", 91 | "value": 0, 92 | "unit": "ms", 93 | "timestamp": 1732608880000, 94 | "output": "JMX OK - AverageResponseTimeMin = 0ms " 95 | }, 96 | { 97 | "name": "Certificate Validity", 98 | "state": "Ok", 99 | "value": 729, 100 | "unit": "days to expiration", 101 | "timestamp": 1732608881000, 102 | "output": "JMX OK - Alias = ajddef09eq; Thumbprint = BDD430E9BF9C12896C801848B5E834840B28F25C; ValidUntil = 2026-11-26T00:50:56Z; Expires in 729 days (W < 14 days, C < 7 days) " 103 | }, 104 | { 105 | "name": "Heap Memory Usage", 106 | "state": "Ok", 107 | "value": 12, 108 | "unit": "%", 109 | "timestamp": 1732608880000, 110 | "output": "HeapMemoryUsage.used = 151 of 1183 MB " 111 | }, 112 | { 113 | "name": "Busy Threads", 114 | "state": "Ok", 115 | "value": 0, 116 | "unit": "threads", 117 | "timestamp": 1732608880000, 118 | "output": "JMX OK - currentThreadsBusy = 0 (W > 150, C > 180) " 119 | }, 120 | { 121 | "name": "Requests per Minute", 122 | "state": "Ok", 123 | "value": 1, 124 | "unit": "requests", 125 | "timestamp": 1732608880000, 126 | "output": "JMX OK - RequestsCountMin = 1 " 127 | }, 128 | { 129 | "name": "CPU Load", 130 | "state": "Ok", 131 | "value": 11, 132 | "unit": "%", 133 | "timestamp": 1732608880000, 134 | "output": "OK CPUValue: 11 (W> 80, C> 90) " 135 | }, 136 | { 137 | "name": "Used Disc Space", 138 | "state": "Ok", 139 | "value": 22, 140 | "unit": "%", 141 | "timestamp": 1732608879000, 142 | "output": "DISK OK - free space: / 8709 MB (76% inode=90%); /var 7152 MB (93% inode=99%); /tmp 3846 MB (99% inode=99%); /usr/sap 8705 MB (92% inode=99%);" 143 | } 144 | ] 145 | ``` 146 | 147 | *HTML Table Result* 148 | 149 |
nameoutputstatetimestampunitvalue
OS Memory UsageOK: MemoryValue: 42 (W> 98, C> 98) Ok1732608880000%42
Disk I/OOK: DiskRead: 0 B/s (W> 10000000, C> 15000000) DiskWrite: 65327 B/s (W> 10000000, C> 15000000)Ok1732608880000B/s65327
Average Response TimeJMX OK - AverageResponseTimeMin = 0ms Ok1732608880000ms0
Certificate ValidityJMX OK - Alias = ajddef09eq; Thumbprint = BDD430E9BF9C12896C801848B5E834840B28F25C; ValidUntil = 2026-11-26T00:50:56Z; Expires in 729 days (W < 14 days, C < 7 days) Ok1732608881000days to expiration729
Heap Memory UsageHeapMemoryUsage.used = 151 of 1183 MB Ok1732608880000%12
Busy ThreadsJMX OK - currentThreadsBusy = 0 (W > 150, C > 180) Ok1732608880000threads0
Requests per MinuteJMX OK - RequestsCountMin = 1 Ok1732608880000requests1
CPU LoadOK CPUValue: 11 (W> 80, C> 90) Ok1732608880000%11
Used Disc SpaceDISK OK - free space: / 8709 MB (76% inode=90%); /var 7152 MB (93% inode=99%); /tmp 3846 MB (99% inode=99%); /usr/sap 8705 MB (92% inode=99%);Ok1732608879000%22
150 | -------------------------------------------------------------------------------- /convert-json-to-html-table/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "htmlTable": " $(.BuildTableHeaderRow.output.message) $(.BuildTableDataRows.output.message)
" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "utils-sapcp:Void:1", 18 | "input": { 19 | "message": "$(.execution.input.data | map(keys) | add | unique)" 20 | }, 21 | "alias": "ExtractHeaders", 22 | "description": null, 23 | "progressMessage": null, 24 | "initialDelay": null, 25 | "pause": null, 26 | "when": null, 27 | "validate": null, 28 | "autoRetry": null, 29 | "repeat": null, 30 | "errorMessages": [], 31 | "dryRun": null 32 | }, 33 | { 34 | "execute": "utils-sapcp:Void:1", 35 | "input": { 36 | "message": " $(.ExtractHeaders.output.message | toArray | map(\"\\(.)\") | join(\"\")) " 37 | }, 38 | "alias": "BuildTableHeaderRow", 39 | "description": null, 40 | "progressMessage": null, 41 | "initialDelay": null, 42 | "pause": null, 43 | "when": null, 44 | "validate": null, 45 | "autoRetry": null, 46 | "repeat": null, 47 | "errorMessages": [], 48 | "dryRun": null 49 | }, 50 | { 51 | "execute": "utils-sapcp:Void:1", 52 | "input": { 53 | "message": "$((.execution.input.data[] | [ .[$.ExtractHeaders.output.message | toArray[]] ] | map(\"\\(. // \"\")\")) | \"\" + join(\"\") + \"\")" 54 | }, 55 | "alias": "BuildTableDataRows", 56 | "description": null, 57 | "progressMessage": null, 58 | "initialDelay": null, 59 | "pause": null, 60 | "when": null, 61 | "validate": null, 62 | "autoRetry": null, 63 | "repeat": null, 64 | "errorMessages": [], 65 | "dryRun": null 66 | } 67 | ], 68 | "listeners": [] 69 | }, 70 | "id": "examples-<<>>:ConvertJsonToHtmlTable:1", 71 | "name": "ConvertJsonToHtmlTable", 72 | "description": "Convert JSON array of objects to HTML table", 73 | "catalog": "examples-<<>>", 74 | "version": 1, 75 | "inputKeys": { 76 | "data": { 77 | "type": "array", 78 | "sensitive": false, 79 | "required": true, 80 | "minSize": null, 81 | "maxSize": null, 82 | "minValue": null, 83 | "maxValue": null, 84 | "allowedValues": null, 85 | "allowedValuesFromInputKeys": null, 86 | "suggestedValues": null, 87 | "suggestedValuesFromInputKeys": null, 88 | "defaultValue": null, 89 | "defaultValueFromInput": null, 90 | "description": "JSON array data" 91 | } 92 | }, 93 | "outputKeys": { 94 | "htmlTable": { 95 | "type": "string", 96 | "sensitive": false, 97 | "description": "HTML table result" 98 | } 99 | }, 100 | "tags": {} 101 | } 102 | ] 103 | } -------------------------------------------------------------------------------- /execute-script-via-k8s-job/README.md: -------------------------------------------------------------------------------- 1 | # Execute Script Via Kubernetes Job 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Setup Pull Secret](#setup-pull-secret) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to execute a custom bash script within a Kubernetes Job in a customer-owned Kubernetes cluster (e.g., via [Kyma](https://help.sap.com/docs/btp/sap-business-technology-platform/kyma-environment) or from other Cloud Providers). The provided `ExecuteScript` command in SAP Automation Pilot has concrete limitations in terms of resources and timeout. By using a Kubernetes Job, you can leverage the resources of your own Kubernetes cluster and configure the job to meet your specific requirements. 13 | 14 | ### Key Features 15 | 16 | * **Resource Management**: Utilize the resources of your Kubernetes cluster to execute scripts that require more CPU, memory, or storage than what is available in the default `ExecuteScript` command. 17 | * **Custom Images**: Use your own container images from private registries to tailor the execution environment to your needs. 18 | * **Timeout Configuration**: Set higher timeouts for script execution, ensuring that long-running scripts can complete without being interrupted. 19 | * **Event Logging**: Retrieve all Kubernetes events related to the script execution for better debugging and monitoring. 20 | * **Data Security**: All data related to the execution of the script, including the script itself, parameters, and environment variables, is stored in a Kubernetes secret. 21 | 22 | ### Use Cases 23 | 24 | * **Complex Scripts**: Execute complex scripts that require significant computational resources or have long execution times. 25 | * **Custom Dependencies**: Run scripts that depend on specific tools or libraries available in custom container images. 26 | * **Scalability**: Execute large number of scripts in parallel in your Kubernetes cluster. 27 | 28 | ## Requirements 29 | 30 | To use this example you'll need the following: 31 | 32 | * **Kubernetes Cluster**: A Kubernetes cluster where the job will be executed. 33 | * **Kubeconfig**: Credentials for accessing the Kubernetes cluster. 34 | * **Container Image**: A container image that provides the environment where the script will be executed. You can also use images from public registries (e.g., `ubuntu:24.04`). 35 | * **Namespace**: The Kubernetes namespace where the job will be created. 36 | * **Image Pull Secret** (optional): A Kubernetes secret for pulling private container images. 37 | 38 | ## How to use 39 | 40 | 1. **Import the Example**: 41 | 42 | * Copy the content of the [catalog.json](./catalog.json) file. 43 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 44 | * Click on `Import` in the upper right corner. 45 | * Paste the catalog's content and import it. 46 | 47 | 2. **Trigger the Command Manually**: 48 | 49 | * Navigate to the `ExecuteScriptViaKubernetesJob` command in your SAP Automation Pilot tenant. 50 | * Click on the *Trigger* button after getting familiar with the command. 51 | * Provide values for the following input keys: 52 | * `kubeconfig`: Credentials for the specified Kubernetes cluster. 53 | * `namespace`: Namespace where the script will be executed. 54 | * `image`: Container image to be used for executing the script, e.g., *ubuntu:24.04* 55 | * `imagePullSecretName` (optional): Name of the image pull secret to use when the image is sourced from a private registry. 56 | * `script`: Script to be executed (base64 encoded). 57 | * `environment` (optional): Environment variables available during script execution. 58 | * `parameters` (optional): Parameters that will be passed to the script in the specified order. 59 | * `stdin` (optional): Sensitive data passed to the script's standard input. 60 | * `timeout` (optional): Timeout of the script in seconds (default is 30). 61 | * `outputLines` (optional): Number of script output lines to be returned (default is 1000). 62 | 63 | 3. **Monitor the Execution**: 64 | 65 | * The command will create a Kubernetes Job to execute the script, wait for it to finish, and at the end will retrieve the exit code, the script output, and all related Kubernetes events. 66 | * After the execution finishes, you can see the script output, exit code, and related events: 67 | 68 | ![Successful Execution](./assets/successful-execution.png) 69 | 70 | ![Script Output](./assets/script-output.png) 71 | 72 | ![Kubernetes Events](./assets/kubernetes-events.png) 73 | 74 | :information_source: The Kubernetes Job will be automatically cleaned up after execution, ensuring that no resources are left behind. The job is configured with [ttlSecondsAfterFinished](https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/) which automatically deletes the job after 3 minutes. 75 | 76 | :information_source: The Kubernetes secret created for the script execution will also be automatically deleted with a status listener when the execution enters a terminal state (FINISHED, ABORTED, or SUSPENDED). 77 | 78 | ## Setup Pull Secret 79 | 80 | If you need to pull a container image from a private registry, you can set up a pull secret using the `CreateK8sImagePullSecret` command provided in the example. 81 | 82 | 1. **Trigger the Command Manually**: 83 | 84 | * Navigate to the `CreateK8sImagePullSecret` command in your SAP Automation Pilot tenant. 85 | * Click on the *Trigger* button after getting familiar with the command. 86 | * Provide values for the following input keys: 87 | * `secretName`: Name of the secret to be created. 88 | * `namespace`: Namespace where the secret will be created. 89 | * `dockerconfig`: Credentials for the private container image registry in the format described [here](https://kubernetes.io/docs/concepts/containers/images/#config-json). 90 | * `kubeconfig`: Credentials for the specified Kubernetes cluster. 91 | 92 | 2. **Use the Pull Secret**: 93 | 94 | * When triggering the `ExecuteScriptViaKubernetesJob` command, provide the name of the created pull secret in the `imagePullSecretName` input key. 95 | 96 | This will ensure that the Kubernetes job can pull the container image from the private registry using the specified pull secret. 97 | -------------------------------------------------------------------------------- /execute-script-via-k8s-job/assets/kubernetes-events.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/execute-script-via-k8s-job/assets/kubernetes-events.png -------------------------------------------------------------------------------- /execute-script-via-k8s-job/assets/script-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/execute-script-via-k8s-job/assets/script-output.png -------------------------------------------------------------------------------- /execute-script-via-k8s-job/assets/successful-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/execute-script-via-k8s-job/assets/successful-execution.png -------------------------------------------------------------------------------- /grant-privileges/README.md: -------------------------------------------------------------------------------- 1 | # Grant Privileges on BTP Subaccount and CF Level 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | As a continuation of the [Setup Cloud Foundry BTP Environment](../prepare-btp-environment/) example, we'll explore the capabilities of SAP Automation Pilot manage users and their permissions on subacount, organization and space level. 12 | 13 | This example provides two commands which utilize the **SAP Authorization and Trust Management Service (xsuaa-sapcp)** and **Cloud Foundry (cf-sapcp)** provides catalogs. 14 | 15 | **GrantAdministratorPrivileges** performs the following actions on the target user: 16 | 17 | * Assigns *Subaccount Administrator* role collection 18 | * Assigns *Org Manager* role 19 | * Assigns *Space Manager* role 20 | 21 | ![Administrator Pipeline](./assets/administrator-pipeline.png) 22 | 23 | **GrantDeveloperPrivileges** performs the following actions on the target user: 24 | 25 | * Assigns *Subaccount Viewer* role collection 26 | * Assigns *Org Auditor* role 27 | * Assigns *Space Developer* role 28 | 29 | ![Administrator Pipeline](./assets/developer-pipeline.png) 30 | 31 | **MassGrantPrivileges** builds upon the above commands and executes them on multiple users at once. 32 | 33 | ![Mass Pipeline](./assets/mass-pipeline.png) 34 | 35 | :information_source: Make sure to check the other examples in the [BTP Provisioning](../README.md#btp-provisioning) section. 36 | 37 | ## Requirements 38 | 39 | To use this example you'll need the following: 40 | 41 | * BTP subaccount 42 | * Configured Cloud Foundry environment 43 | * Instance of [SAP Authorization and Trust Management Service](https://discovery-center.cloud.sap/serviceCatalog/authorization-and-trust-management-service?region=all) with plan *apiaccess* and a service key/binding with default configurations 44 | * One or more custom identity providers 45 | 46 | :warning: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 47 | 48 | Check out the following resources for more information: 49 | 50 | * [Example: Create and Configure BTP Subaccount](../prepare-btp-subaccount/) 51 | * [Example: Setup Cloud Foundry BTP Environment](../prepare-btp-environment/) 52 | * [Getting Started in the Cloud Foundry Environment](https://help.sap.com/docs/btp/sap-business-technology-platform/getting-started-in-cloud-foundry-environment) 53 | * [SAP Authorization and Trust Management Service](https://help.sap.com/docs/CP_AUTHORIZ_TRUST_MNG) 54 | * [Access Administration Using APIs of the SAP Authorization and Trust Management Service](https://help.sap.com/docs/btp/sap-business-technology-platform/access-administration-using-apis-of-sap-authorization-and-trust-management-service) 55 | * [Trust and Federation with Identity Providers](https://help.sap.com/docs/btp/sap-business-technology-platform/trust-and-federation-with-identity-providers) 56 | 57 | ## How to use 58 | 59 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *MassGrantPrivileges* command and trigger it. 60 | 61 | You'll need to provide values for the following input keys: 62 | 63 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20 64 | * *org* - Name of your Cloud Foundry organization 65 | * *space* - Name of your Cloud Foundry space 66 | * *user* - Email or ID of your technical user 67 | * *password* - Password of your technical user 68 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 69 | * *serviceKey* - Service key for *SAP Authorization and Trust Management Service* for *apiaccess* plan 70 | * *developers* - Email address of the target users which should be granted developer privileges 71 | * *administrators* - Email address of the target users which should be granted administrator privileges 72 | * *targetIdentityProvider* - Optional: origin key of the target user's identity provider. Defaults to sap.ids 73 | 74 | After the successful execution of the command, you can check which users were reassigned to another identity provider: 75 | 76 | ![Finished Execution](./assets/finished-execution.png) 77 | 78 | ![Execution Output](./assets/output-results.png) 79 | 80 | To grant privielges to a single user, navigate to the *GrantAdministratorPrivileges* or *GrantDeveloperPrivileges* commands and trigger them. 81 | 82 | You'll need to provide values for the following input keys: 83 | 84 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20 85 | * *org* - Name of your Cloud Foundry organization 86 | * *space* - Name of your Cloud Foundry space 87 | * *user* - Email or ID of your technical user 88 | * *password* - Password of your technical user 89 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 90 | * *serviceKey* - Service key for *SAP Authorization and Trust Management Service* for *apiaccess* plan 91 | * *targetUser* - user to whom the privileges will be granted 92 | * *targetIdentityProvider* - Optional: origin key of the target user's identity provider. Defaults to sap.ids 93 | 94 | :information_source: You can verify the result of your executions by navigating to your BTP subaccount and choosing **Security -> Users**. 95 | -------------------------------------------------------------------------------- /grant-privileges/assets/administrator-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/grant-privileges/assets/administrator-pipeline.png -------------------------------------------------------------------------------- /grant-privileges/assets/developer-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/grant-privileges/assets/developer-pipeline.png -------------------------------------------------------------------------------- /grant-privileges/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/grant-privileges/assets/finished-execution.png -------------------------------------------------------------------------------- /grant-privileges/assets/mass-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/grant-privileges/assets/mass-pipeline.png -------------------------------------------------------------------------------- /grant-privileges/assets/output-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/grant-privileges/assets/output-results.png -------------------------------------------------------------------------------- /http-cloud-connector/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Request via SAP Cloud Connector 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example demonstrates how SAP Automation Pilot can perform HTTP requests not only to public endpoints, but also to internal endpoints exposed via the [SAP Cloud Connector](https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/cloud-connector). Any HTTP-based protocol is supported, including OData, REST, and SOAP. 13 | 14 | The example targets the OData API ([ICM Ping Service](https://me.sap.com/notes/0002330899)) of a SAP Basis system, but you can use the same approach to access any HTTP endpoint—SAP or non-SAP—reachable through the Cloud Connector. 15 | 16 | By leveraging the Cloud Connector, Automation Pilot can interact with systems that are not directly accessible from the public internet, enabling secure automation scenarios across hybrid landscapes. 17 | 18 | ## Requirements 19 | 20 | To use this example you'll need the following: 21 | 22 | * **SAP Automation Pilot Tenant**: Access to an SAP Automation Pilot tenant. 23 | * **SAP Cloud Connector**: Connected to the same SAP BTP account as your Automation Pilot tenant. 24 | * **Configured Cloud Connector Mapping**: The internal HTTP endpoint (e.g., SAP Basis system) must be exposed via the Cloud Connector and accessible using a virtual hostname and port. 25 | 26 | ### Cloud Connector Setup Steps 27 | 28 | 1. **Expose your system through the Cloud Connector** 29 | Assign a virtual host and port to your internal system in the Cloud Connector admin console. This virtual host will be used to send requests from BTP (e.g., Automation Pilot) to your system. 30 | 31 | ![Cloud Connector Admin Console](./assets/cloud-connector-admin-console.png) 32 | 33 | 2. **Verify Cloud Connector connection in BTP** 34 | Once the Cloud Connector is successfully connected to your BTP subaccount and the system is exposed, you will see the Cloud Connector listed in your BTP subaccount cockpit. 35 | 36 | ![BTP Cockpit Cloud Connector](./assets/btp-cockpit-cloud-connector.png) 37 | 38 | 3. **Send requests via Automation Pilot** 39 | In Automation Pilot, use the `HttpRequest` command with Cloud Connector enabled. Provide the Location ID of the Cloud Connector (or leave empty if not specified) and use the virtual host/port as the target. This is already demonstrated in the example command. 40 | 41 | ![Automation Pilot HttpRequest Setup](./assets/automation-pilot-setup.png) 42 | 43 | **:information_source: Note:** 44 | When making HTTP requests via the Cloud Connector, it is recommended to increase the default timeout value for the request. Requests routed through the Cloud Connector may take longer to complete due to additional network hops and processing. 45 | 46 | ![Increase Timeout](./assets/increase-timeout-screenshot.png) 47 | *Example: Where to increase the timeout value in the command setup.* 48 | 49 | ## How to use 50 | 51 | 1. **Import the Example**: 52 | * Copy the content of the [catalog.json](./catalog.json) file. 53 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 54 | * Click on `Import` in the upper right corner. 55 | * Paste the catalog's content and import it. 56 | 57 | 2. **Trigger the Command**: 58 | * Use the `HttpCloudConnector` command. 59 | * Provide the `host` input (the virtual hostname and port as configured in the Cloud Connector). 60 | * Start the automation. 61 | 62 | ## Expected result 63 | 64 | After execution, the command will perform an HTTP request to the ICM Ping service of the SAP Basis system (or any other HTTP endpoint you specify) via the Cloud Connector. The response from the endpoint will be returned as output, confirming connectivity and successful configuration. 65 | 66 | ![Ping Response](./assets/ping-response.png) 67 | -------------------------------------------------------------------------------- /http-cloud-connector/assets/automation-pilot-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-cloud-connector/assets/automation-pilot-setup.png -------------------------------------------------------------------------------- /http-cloud-connector/assets/btp-cockpit-cloud-connector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-cloud-connector/assets/btp-cockpit-cloud-connector.png -------------------------------------------------------------------------------- /http-cloud-connector/assets/cloud-connector-admin-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-cloud-connector/assets/cloud-connector-admin-console.png -------------------------------------------------------------------------------- /http-cloud-connector/assets/increase-timeout-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-cloud-connector/assets/increase-timeout-screenshot.png -------------------------------------------------------------------------------- /http-cloud-connector/assets/ping-response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-cloud-connector/assets/ping-response.png -------------------------------------------------------------------------------- /http-cloud-connector/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "pingResponse": "$(.SendPing.output.body)" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "http-sapcp:HttpRequest:1", 18 | "input": { 19 | "method": "GET", 20 | "sccLocationId": "SCC_TEST", 21 | "url": "http://$(.execution.input.host)/sap/public/ping", 22 | "timeout": "15", 23 | "sccEnabled": "true" 24 | }, 25 | "alias": "SendPing", 26 | "description": "Perform a basic connectivity check via the ICM Ping service", 27 | "progressMessage": null, 28 | "initialDelay": null, 29 | "pause": null, 30 | "when": null, 31 | "validate": null, 32 | "autoRetry": null, 33 | "repeat": null, 34 | "errorMessages": [], 35 | "dryRun": null 36 | } 37 | ], 38 | "listeners": [] 39 | }, 40 | "id": "examples-<<>>:HttpCloudConnector:1", 41 | "name": "HttpCloudConnector", 42 | "description": "Performs an HTTP request to a SAP Basis system through the Cloud Connector configured for the current subaccount", 43 | "catalog": "examples-<<>>", 44 | "version": 1, 45 | "inputKeys": { 46 | "host": { 47 | "type": "string", 48 | "sensitive": false, 49 | "required": true, 50 | "minSize": null, 51 | "maxSize": null, 52 | "minValue": null, 53 | "maxValue": null, 54 | "allowedValues": null, 55 | "allowedValuesFromInputKeys": null, 56 | "suggestedValues": null, 57 | "suggestedValuesFromInputKeys": null, 58 | "defaultValue": null, 59 | "defaultValueFromInput": null, 60 | "description": "Virtual hostname and port of the SAP Basis system as made accessible via the Cloud Connector" 61 | } 62 | }, 63 | "outputKeys": { 64 | "pingResponse": { 65 | "type": "string", 66 | "sensitive": false, 67 | "description": "Response from the ICM Ping service" 68 | } 69 | }, 70 | "tags": {} 71 | } 72 | ] 73 | } -------------------------------------------------------------------------------- /http-oauth-client-credentials/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Request With OAuth Client Credentials 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [Configuring OAuth Setup](#configuring-oauth-setup) 8 | * [Configuring Automatic Retry for OAuth Token Acquisition](#configuring-automatic-retry-for-oauth-token-acquisition) 9 | * [How to use](#how-to-use) 10 | 11 | ## Description 12 | 13 | This example demonstrates how to perform HTTP requests to endpoints that require OAuth 2.0 authentication using the client credentials flow. Two scenarios are covered: 14 | 15 | * Using a client secret (standard client credentials flow) 16 | * Using mTLS for enhanced security 17 | 18 | Both scenarios target the [SAP Service Manager API](https://api.sap.com/api/APIServiceManager/path/getServiceOfferings), where authentication details are provided via a service key obtained from the SAP BTP cockpit. The service key contains all necessary information: client ID, authentication credentials (client secret or certificate/key), OAuth token URL, and the Service Manager API endpoint. 19 | 20 | SAP Automation Pilot's [HttpRequest](https://help.sap.com/docs/automation-pilot/automation-pilot/httprequest-command?locale=en-US) command supports multiple authentication mechanisms, including OAuth 2.0. It can transparently obtain and reuse OAuth tokens throughout the execution as long as they remain valid, and will automatically acquire a new token if the current one is about to expire. It is recommended to always let the `HttpRequest` command handle token acquisition. 21 | 22 | ## Requirements 23 | 24 | To use these examples you'll need the following: 25 | 26 | * **SAP Automation Pilot Tenant**: Access to an SAP Automation Pilot tenant. 27 | * **SAP Service Manager Instance**: A Service Manager instance in your SAP BTP subaccount. 28 | * **Service Key**: A service key for the Service Manager instance. 29 | 30 | > **Note:** 31 | > Each BTP service might require specific parameters when creating the service key. Additionally, the structure of the service key JSON may differ for each service. You must get familiar with the service you are using and configure the command accordingly. 32 | 33 | For example, a service key structure for **client secret** may look like this: 34 | 35 | ```json 36 | { 37 | "clientid": "sb-xxxx|service-manager!xxxx", 38 | "clientsecret": "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", 39 | "url": "https://my-subdomain.authentication.eu10.hana.ondemand.com", 40 | "sm_url": "https://service-manager.cfapps.eu10.hana.ondemand.com" 41 | } 42 | ``` 43 | 44 | For **mTLS**: 45 | 46 | ```json 47 | { 48 | "clientid": "sb-xxxx|service-manager!xxxx", 49 | "certificate": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----", 50 | "key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----", 51 | "certurl": "https://my-subdomain.authentication.cert.eu10.hana.ondemand.com", 52 | "sm_url": "https://service-manager.cfapps.eu10.hana.ondemand.com" 53 | } 54 | ``` 55 | 56 | ## Configuring OAuth Setup 57 | 58 | To configure the OAuth setup in your Automation Pilot command, you need to extract the required values from the service key using [Dynamic Expressions](https://help.sap.com/docs/automation-pilot/automation-pilot/dynamic-expression?locale=en-US). The screenshot below shows how to map the fields from the service key object to the OAuth configuration in the command input: 59 | 60 | ![OAuth Setup Example](./assets/oauth-setup-example.png) 61 | 62 | ## Configuring Automatic Retry for OAuth Token Acquisition 63 | 64 | In some scenarios, the request to obtain an OAuth token may fail due to network problems, timeouts, or other transient issues. You can configure your command to automatically retry the OAuth token request if such failures occur. 65 | 66 | To ensure that only the OAuth token acquisition is retried (and not the main API request), you should configure the retry condition to match only OAuth-related failures. This can be done by checking if the error message contains specific text, such as: 67 | 68 | * `Failed to obtain oAuth 2.0 token` (for general OAuth token acquisition failures) 69 | * `Connectivity timeout issue` (for network or timeout problems) 70 | 71 | The screenshot below shows an example of how to set up the autoretry condition: 72 | 73 | ![Autoretry Setup Example](./assets/autoretry-setup-example.png) 74 | 75 | ## How to use 76 | 77 | 1. **Import the Example**: 78 | * Copy the content of the [catalog.json](./catalog.json) file. 79 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 80 | * Click on `Import` in the upper right corner. 81 | * Paste the catalog's content and import it. 82 | 83 | 2. **Trigger the Command**: 84 | * For **client secret** authentication: 85 | * Use the `HttpOAuthWithSecret` command. 86 | * Provide the `serviceKey` input (the JSON object from your Service Manager service key with client secret). 87 | * For **mTLS (certificate + key)** authentication: 88 | * Use the `HttpOAuthWithMtls` command. 89 | * Provide the `serviceKey` input (the JSON object from your Service Manager service key with certificate and key). 90 | * Confirm and start the automation. 91 | -------------------------------------------------------------------------------- /http-oauth-client-credentials/assets/autoretry-setup-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-oauth-client-credentials/assets/autoretry-setup-example.png -------------------------------------------------------------------------------- /http-oauth-client-credentials/assets/oauth-setup-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/http-oauth-client-credentials/assets/oauth-setup-example.png -------------------------------------------------------------------------------- /mass-restart-cf-apps/README.md: -------------------------------------------------------------------------------- 1 | # Mass Restart Cloud Foundry Apps 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | This example command detects all Cloud Foundry applications in a given space and restarts them one by one. For simplicity the command performs stop-start restart which might cause downtime for your applications. However, this could be easily changed to a rolling restart. 12 | 13 | ## Requirements 14 | 15 | To use this example you'll need the following: 16 | 17 | * Cloud Foundry space with at least one application 18 | * Technical user with **Space Developer** role 19 | 20 | Check out the [documentation](https://help.sap.com/docs/btp/sap-business-technology-platform/administration-and-operations-in-cloud-foundry-environment) for more information. 21 | 22 | ## How to use 23 | 24 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *MassRestartCfApp* command and trigger it. 25 | 26 | You'll need to provide values for the following input keys: 27 | 28 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20 29 | * *subAccount* - Name of your Cloud Foundry organization 30 | * *resourceGroup* - Name of your Cloud Foundry space 31 | * *user* - Email or ID of your technical user 32 | * *password* - Password of your technical user 33 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 34 | -------------------------------------------------------------------------------- /mass-restart-cf-apps/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "restartedAppsCount": "$(.RestartApps.output.outputs | length)" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "applm-sapcp:ListCfApps:1", 18 | "input": { 19 | "resourceGroup": "$(.execution.input.resourceGroup)", 20 | "password": "$(.execution.input.password)", 21 | "pageSize": "100", 22 | "region": "$(.execution.input.region)", 23 | "user": "$(.execution.input.user)", 24 | "subAccount": "$(.execution.input.subAccount)", 25 | "identityProvider": "$(.execution.input.identityProvider)" 26 | }, 27 | "alias": "ListApps", 28 | "progressMessage": null, 29 | "initialDelay": null, 30 | "pause": null, 31 | "when": null, 32 | "validate": null, 33 | "autoRetry": null, 34 | "repeat": null, 35 | "errorMessages": [] 36 | }, 37 | { 38 | "execute": "utils-sapcp:ForEach:1", 39 | "input": { 40 | "inputs": "$(.ListApps.output.resourceNames | map({\"resourceName\": .}))", 41 | "defaultValues": "{\"rollingRestart\": \"false\", \"region\": \"$(.execution.input.region)\", \"subAccount\": \"$(.execution.input.subAccount)\", \"resourceGroup\": \"$(.execution.input.resourceGroup)\", \"user\": \"$(.execution.input.user)\", \"password\": \"$(.execution.input.password)\", \"identityProvider\": \"$(.execution.input.identityProvider)\"}", 42 | "command": "applm-sapcp:RestartCfApp:1" 43 | }, 44 | "alias": "RestartApps", 45 | "progressMessage": null, 46 | "initialDelay": null, 47 | "pause": null, 48 | "when": null, 49 | "validate": null, 50 | "autoRetry": null, 51 | "repeat": null, 52 | "errorMessages": [] 53 | } 54 | ], 55 | "listeners": [] 56 | }, 57 | "id": "examples-<<>>:MassRestartCfApps:1", 58 | "name": "MassRestartCfApps", 59 | "description": "Restart all applications in a given Cloud Foundry space", 60 | "catalog": "examples-<<>>", 61 | "version": 1, 62 | "inputKeys": { 63 | "resourceGroup": { 64 | "type": "string", 65 | "sensitive": false, 66 | "required": true, 67 | "minSize": null, 68 | "maxSize": null, 69 | "minValue": null, 70 | "maxValue": null, 71 | "allowedValues": null, 72 | "allowedValuesFromInputKeys": null, 73 | "suggestedValues": null, 74 | "suggestedValuesFromInputKeys": null, 75 | "defaultValue": null, 76 | "defaultValueFromInput": null, 77 | "description": "Technical name of a Cloud Foundry space. Example: my-space-demo-1" 78 | }, 79 | "password": { 80 | "type": "string", 81 | "sensitive": true, 82 | "required": true, 83 | "minSize": null, 84 | "maxSize": null, 85 | "minValue": null, 86 | "maxValue": null, 87 | "allowedValues": null, 88 | "allowedValuesFromInputKeys": null, 89 | "suggestedValues": null, 90 | "suggestedValuesFromInputKeys": null, 91 | "defaultValue": null, 92 | "defaultValueFromInput": null, 93 | "description": "Cloud Foundry user's password" 94 | }, 95 | "region": { 96 | "type": "string", 97 | "sensitive": false, 98 | "required": true, 99 | "minSize": null, 100 | "maxSize": null, 101 | "minValue": null, 102 | "maxValue": null, 103 | "allowedValues": null, 104 | "allowedValuesFromInputKeys": [ 105 | "metadata-sapcp:CfRegionData:1" 106 | ], 107 | "suggestedValues": null, 108 | "suggestedValuesFromInputKeys": null, 109 | "defaultValue": null, 110 | "defaultValueFromInput": null, 111 | "description": "Technical name of a Cloud Foundry region. Example: cf-eu10, cf-br10" 112 | }, 113 | "user": { 114 | "type": "string", 115 | "sensitive": false, 116 | "required": true, 117 | "minSize": null, 118 | "maxSize": null, 119 | "minValue": null, 120 | "maxValue": null, 121 | "allowedValues": null, 122 | "allowedValuesFromInputKeys": null, 123 | "suggestedValues": null, 124 | "suggestedValuesFromInputKeys": null, 125 | "defaultValue": null, 126 | "defaultValueFromInput": null, 127 | "description": "UserID/Email of the Cloud Foundry user which will be used for authentication" 128 | }, 129 | "subAccount": { 130 | "type": "string", 131 | "sensitive": false, 132 | "required": false, 133 | "minSize": null, 134 | "maxSize": null, 135 | "minValue": null, 136 | "maxValue": null, 137 | "allowedValues": null, 138 | "allowedValuesFromInputKeys": null, 139 | "suggestedValues": null, 140 | "suggestedValuesFromInputKeys": null, 141 | "defaultValue": null, 142 | "defaultValueFromInput": null, 143 | "description": "Technical name of a Cloud Foundry organization. Example: my-org-name-1" 144 | }, 145 | "identityProvider": { 146 | "type": "string", 147 | "sensitive": false, 148 | "required": false, 149 | "minSize": null, 150 | "maxSize": null, 151 | "minValue": null, 152 | "maxValue": null, 153 | "allowedValues": null, 154 | "allowedValuesFromInputKeys": null, 155 | "suggestedValues": null, 156 | "suggestedValuesFromInputKeys": null, 157 | "defaultValue": "sap.ids", 158 | "defaultValueFromInput": null, 159 | "description": "Identity provider to be used. By default it is SAP ID Service (sap.ids). To use a custom IdP, enter origin key from the CF Org/Space members section" 160 | } 161 | }, 162 | "outputKeys": { 163 | "restartedAppsCount": { 164 | "type": "number", 165 | "sensitive": false, 166 | "description": "Total number of restarted apps" 167 | } 168 | }, 169 | "tags": { 170 | "env": "cf" 171 | } 172 | } 173 | ] 174 | } -------------------------------------------------------------------------------- /mass-stop-start-cf-apps/README.md: -------------------------------------------------------------------------------- 1 | # Mass Stop/Start Cloud Foundry Apps 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [How to Label Cloud Foundry Apps](#how-to-label-cloud-foundry-apps) 9 | 10 | ## Description 11 | 12 | If your BTP global account uses the consumption-based commercial model (such as CPEA or Pay-As-You-Go), Cloud Foundry applications are billed based on their usage. Therefore, you can reduce the monthly cost by stopping applications which are used only for testing and development purposes. With the help of SAP Automation Pilot, such resources can be automatically stopped outside of working hours and started again the next day. To find out more about the Cloud Foundry's billng costs, please feel free to consult [SAP BTP, Cloud Foundry Runtime](https://discovery-center.cloud.sap/serviceCatalog/cloud-foundry-runtime?tab=service_plan®ion=all&commercialModel=cpea). 13 | 14 | SAP Automation Pilot has the capabilities to perform mass operations on tens or even hundreds of Cloud Foundry applications, including stop, start or restart. In addition to this, these operations can be performed regularly with the [Scheduled Executions functionality](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html). 15 | 16 | This example includes a total of four commands. *MassStopCfAppsInSpace* and *MassStartCfAppsInSpace* dynamically find and stop/start all applications in the given space. Similarly, *MassStopCfAppsInOrg* and *MassStartCfAppsInOrg* do the same thing but on organization level - the applications across all spaces are collected and then started/stopped. In addition, it's possible to ignore certain spaces and do not perform any operations on them. 17 | 18 | ![Mass Stop Apps in Org](./assets/mass-stop-org.png) 19 | ![Mass Start Apps in Org](./assets/mass-start-org.png) 20 | 21 | After a successful execution, each command outputs a short summary which is useful for transparency and traceability: 22 | 23 | ![Mass Stop Summary](./assets/mass-stop-summary.png) 24 | 25 | :warning: The commands within this example might cause downtime for a large amount of applications. Please make sure that you are not using them on productive systems. 26 | 27 | ## Requirements 28 | 29 | To use this example you'll need the following: 30 | 31 | * Multiple Cloud Foundry spaces with at least one application in each 32 | * Technical user with **Space Developer** role in each space 33 | 34 | :warning: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 35 | 36 | Check out the [documentation](https://help.sap.com/docs/btp/sap-business-technology-platform/administration-and-operations-in-cloud-foundry-environment) for more information. 37 | 38 | ## How to use 39 | 40 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. 41 | The examples includes four commands - *MassStopCfAppsInSpace*, *MassStartCfAppsInSpace*, *MassStopCfAppsInOrg* and *MassStartCfAppsInOrg*. Navigate to any of them and to trigger them. 42 | 43 | You'll need to provide values for the following input keys: 44 | 45 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20 46 | * *subAccount* - Name of your Cloud Foundry organization 47 | * *resourceGroup* - Name of your Cloud Foundry space 48 | * *user* - Email or ID of your technical user 49 | * *password* - Password of your technical user 50 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 51 | * *excludedSpaces* - Technical names of the Cloud Foundry spaces in which the applications should not be started/stopped. Example value: `["prod-1", "prod-2"]` 52 | * *excludedLabels* - If an application has any of the specified labels, it will not be started/stopped. Example value: `{ "env": "production" }"` 53 | 54 | :information_source: Most of the needed information is available in your subaccount's *Overview* page under *Cloud Foundry Environment*. 55 | 56 | As mentioned before, Automation Pilot allows executions to be automatically triggered on regular intervals - hourly, daily, weekly, monthly or yearly. We can create two [Scheduled Executions](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html) - one to stop all applications after working hours and another to start them up again on the next morning. 57 | 58 | :information_source: Scheduled Executions use the UTC time zone. 59 | 60 | Here are the some example schedule configurations: 61 | 62 | * *MassStopCfAppsInOrg* - executed every weekday at 16:30 UTC 63 | * Schedule - Weekly on Monday, Tuesday, Wednesday, Thursday and Friday 64 | * Hours - 16 65 | * Minutes - 30 66 | 67 | * *MassStartCfAppsInOrg* - every weekday at 06:30 UTC 68 | * Schedule - Weekly on Monday, Tuesday, Wednesday, Thursday and Friday 69 | * Hours - 6 70 | * Minutes - 30 71 | 72 | ## How to Label Cloud Foundry Apps 73 | 74 | ### Using CF CLI 75 | 76 | To add a label to an application using the CF CLI, use the following command: 77 | 78 | ```shell 79 | cf set-label app my-app environment=production 80 | ``` 81 | 82 | ### Using Manifest YAML 83 | 84 | To add labels to an application using a manifest YAML file, include the labels section under metadata. 85 | 86 | Example manifest.yml: 87 | 88 | ```yaml 89 | applications: 90 | - name: my-app 91 | memory: 512M 92 | instances: 1 93 | path: . 94 | metadata: 95 | labels: 96 | environment: production 97 | owner: team-a 98 | ``` 99 | -------------------------------------------------------------------------------- /mass-stop-start-cf-apps/assets/mass-start-org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/mass-stop-start-cf-apps/assets/mass-start-org.png -------------------------------------------------------------------------------- /mass-stop-start-cf-apps/assets/mass-stop-org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/mass-stop-start-cf-apps/assets/mass-stop-org.png -------------------------------------------------------------------------------- /mass-stop-start-cf-apps/assets/mass-stop-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/mass-stop-start-cf-apps/assets/mass-stop-summary.png -------------------------------------------------------------------------------- /mass-stop-start-hana-cloud/README.md: -------------------------------------------------------------------------------- 1 | # Mass Stop and Start of HANA Cloud Instances 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to automate the mass stopping and starting of HANA Cloud instances. It is particularly useful for managing large-scale environments where multiple HANA Cloud instances need to be controlled simultaneously. Automating these operations helps to reduce manual effort, minimize downtime, and ensure consistency across all instances. 13 | 14 | The example includes multiple commands, depending on the BTP subaccount environment. 15 | 16 | For *Cloud Foundry Environment*: 17 | 18 | * **MassStopHanaCloudDatabasesCF**: Stops all HANA Cloud instances across every Cloud Foundry space in a subaccount. 19 | * **MassStartHanaCloudDatabasesCF**: Starts all HANA Cloud instances across every Cloud Foundry space in a subaccount. 20 | 21 | For *Other Environment* (also known as *Multi-Environment* or Subaccount level): 22 | 23 | * **MassStopHanaCloudDatabasesOtherEnv**: Stops all HANA Cloud instances within a specified BTP subaccount (service: hana-cloud, plan: hana). 24 | * **MassStartHanaCloudDatabasesOtherEnv**: Starts all HANA Cloud instances within a specified BTP subaccount (service: hana-cloud, plan: hana). 25 | 26 | These commands provide flexibility to manage HANA Cloud instances at both the Cloud Foundry space level and the subaccount level, making it easier to handle different deployment scenarios. This example can manage one or multiple HANA instances, ranging from tens to even hundreds. 27 | 28 | ### Core Benefits 29 | 30 | * **Efficiency**: Automates repetitive tasks, saving time and reducing the risk of human error. 31 | * **Scalability**: Easily manage multiple instances across different environments. 32 | * **Consistency**: Ensures that all instances are started or stopped in a uniform manner. 33 | * **Cost Management**: Helps in managing costs by stopping instances when not in use. 34 | 35 | ### Sample Scenarios 36 | 37 | * **Development Environments**: Stop databases during non-working hours to save costs and start them again during working hours. 38 | * **Testing Environments**: Automatically start databases before running test suites and stop them afterward to optimize resource usage. 39 | * **Maintenance Windows**: Schedule stops and starts of databases during maintenance windows to ensure minimal disruption. 40 | 41 | ## Requirements 42 | 43 | For *Cloud Foundry Environment* you'll need the following: 44 | 45 | * **SAP Automation Pilot Tenant**: Ensure you have access to an SAP Automation Pilot tenant. 46 | * **HANA Cloud Databases**: HANA Cloud databases in Cloud Foundry. 47 | * **Service Manager Service Key**: A service key for the SAP Service Manager. 48 | * **Cloud Foundry User**: Credentials for a Cloud Foundry user with appropriate permissions (*Space Developer*). 49 | 50 | For *Other Environment* you'll need the following: 51 | 52 | * **SAP Automation Pilot Tenant**: Ensure you have access to an SAP Automation Pilot tenant. 53 | * **HANA Cloud Databases**: HANA Cloud databases in *Other Environment*. 54 | * **Service Manager Service Key**: A service key for the SAP Service Manager. 55 | 56 | ## How to use 57 | 58 | 1. **Import the Example**: 59 | 60 | * Copy the content of the [catalog.json](./catalog.json) file. 61 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 62 | * Click on `Import` in the upper right corner. 63 | * Paste the catalog's content and import it. 64 | 65 | ### Cloud Foundry Environment 66 | 67 | If your HANA Cloud database is in the *Cloud Foundry environment*, navigate to the desired command (e.g., `MassStopHanaCloudDatabasesCF`, `MassStartHanaCloudDatabasesCF`) in your SAP Automation Pilot tenant. 68 | 69 | You'll need to provide values for the following input keys: 70 | 71 | * `serviceKey`: Service key for the SAP Service Manager. 72 | * `user`: UserID/Email of the Cloud Foundry user which will be used for authentication. 73 | * `password`: Cloud Foundry user's password. 74 | * `identityProvider`: Identity provider to be used (optional, default is `sap.ids`). 75 | * `excludedInstances`: Names of HANA Cloud instances which should not be stopped/started. Example: `[ "my-prod-hana" ]` (optional). 76 | 77 | ### Other Environment 78 | 79 | If your HANA Cloud database is in the *Other environment*, navigate to the desired command (e.g., `MassStopHanaCloudDatabasesOtherEnv`, `MassStartHanaCloudDatabasesOtherEnv`) in your SAP Automation Pilot tenant. 80 | 81 | You'll need to provide values for the following input keys: 82 | 83 | * `serviceKey`: Service key for the SAP Service Manager. 84 | * `deadline`: Number of minutes to wait for the process to complete successfully (optional, default is 60 minutes). 85 | * `excludedInstances`: Names of HANA Cloud instances which should not be stopped/started. Example: `[ "my-prod-hana" ]` (optional). 86 | 87 | ## Expected result 88 | 89 | After executing the mass stop or start commands, you should see the following results: 90 | 91 | 1. The command will list all HANA Cloud instances in the specified environment. 92 | 2. It will exclude any instances specified in the `excludedInstances` input key. 93 | 3. The command will initiate the stop/start process for each instance. 94 | 4. It will wait for the stop/start process to complete for each instance. 95 | 5. The output will list all instances that have been successfully stopped/started. 96 | 97 | You can verify the status of the instances in the SAP HANA Cloud Central or by checking the output values in the Automation Pilot execution logs. 98 | -------------------------------------------------------------------------------- /mass-stop-start-hana-cloud/assets/list-parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/mass-stop-start-hana-cloud/assets/list-parameters.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/README.md: -------------------------------------------------------------------------------- 1 | # Update of HANA Cloud Database 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | SAP HANA Cloud releases new versions, also known as QRC (quarterly release cycle), every three months on the final day of each quarter. In between these QRC releases, patches containing bug fixes and other improvements are developed and made available. 13 | 14 | Ensuring that your HANA Cloud database is updated consistently is crucial for maintaining its security, reliability, and access to new features. Without user intervention, HANA Cloud instances are forcefully updated seven months following a version release. 15 | 16 | SAP Automation Pilot allows for complete automation of the update process. It can execute updates on a regular basis, entirely depending upon the customer's preference — weekly, monthly, quarterly, etc. Moreover, there's the choice of selecting a unique update strategy, enabling updates only to the latest patch version, the next available QRC version, or the latest possible QRC version. 17 | 18 | The command in this example executes the following steps: 19 | 20 | * Checks if an update is available based on the chosen update strategy. 21 | * Optionally, pauses and awaits explicit confirmation before performing the update. 22 | * Executes the update to the available version. 23 | * If no suitable version is available, the execution terminates without proceeding any further. 24 | 25 | Typically, an update requires the database to restart, resulting in downtime. Given this, the command pauses prior to the update until explicit confirmation is received from your DevOps team. If downtime is not an issue, or the database is configured to be updated without a restart, this confirmation can be disabled. For more information, visit this page: [Upgrading Without Restart](https://help.sap.com/docs/HANA_CLOUD/9ae9104a46f74a6583ce5182e7fb20cb/c26e42e6a7a4411191441c8d48fd9b11.html) 26 | 27 | :warning: Please note: It is not possible to revert to a previous version once the upgrade is complete. We strongly advise verifying everything works as expected on a test system prior to applying the update to the production environment. 28 | 29 | ## Requirements 30 | 31 | ### Cloud Foundry Environment 32 | 33 | If your HANA Cloud database is in the Cloud Foundry environment: 34 | 35 | * HANA Cloud database in the *Cloud Foundry environment*. 36 | * Platform user with *Space Developer* role in the space where the database resides. 37 | 38 | :warning: Please note: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 39 | 40 | ### Other Environment (Subaccount level) 41 | 42 | If your HANA Cloud database is in the *Other environment*: 43 | 44 | * HANA Cloud database in the *Other environment*. 45 | * Instance of [SAP Service Manager](https://help.sap.com/docs/service-manager/sap-service-manager/sap-service-manager) with plan *subaccount-admin* and a service key. 46 | 47 | Check out the following resources for more information: 48 | 49 | * [Deploy SAP HANA Cloud](https://developers.sap.com/tutorials/hana-cloud-deploying.html) 50 | * [Create Users and Manage Roles and Privileges](https://developers.sap.com/tutorials/hana-cloud-mission-trial-4.html) 51 | 52 | ## How to use 53 | 54 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. 55 | 56 | ### Cloud Foundry Environment 57 | 58 | If your HANA Cloud database is in the *Cloud Foundry environment*, navigate to the *UpdateHanaCloudDatabaseCF* command and trigger it. 59 | 60 | You'll need to provide values for the following input keys: 61 | 62 | * *updateStrategy* - Update strategies that allow you to update in a variety of ways depending on your needs (latest patch version, next QRC version, latest QRC version) 63 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20, cf-eu10-004 64 | * *org* - Name of your Cloud Foundry organization 65 | * *space* - Name of your Cloud Foundry space 66 | * *hanaCloudInstance* - Name of your HANA Cloud service instance 67 | * *user* - Email or ID of your technical user 68 | * *password* - Password of your technical user 69 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 70 | * *shouldConfirmBeforeUpdate* - Optional: whether to require confirmation before starting the update, if there's one available. Defaults to true 71 | 72 | :warning: Make sure that you using the correct *region* value by verifying it in the BTP Cockpit Overview page. For example, the region shown below is *cf-eu10-004*: 73 | 74 | ![BTP Cockpit Overview](assets/btp-cloud-foundry-env.png) 75 | 76 | ### Other Environment (Subaccount level) 77 | 78 | If your HANA Cloud database is in the *Other environment*, navigate to the *UpdateHanaCloudDatabaseOtherEnv* command and trigger it. 79 | 80 | You'll need to provide values for the following input keys: 81 | 82 | * *updateStrategy* - Update strategies that allow you to update in a variety of ways depending on your needs (latest patch version, next QRC version, latest QRC version) 83 | * *hanaCloudInstance* - Name of your HANA Cloud service instance 84 | * *serviceKey* - Service key to the SAP Service Manager, plan subaccount-admin 85 | * *shouldConfirmBeforeUpdate* - Optional: whether to require confirmation before starting the update, if there's one available. Defaults to true 86 | 87 | ### Scheduling 88 | 89 | This command is most useful if executed regularly. Automation Pilot allows executions to be automatically triggered on regular intervals - hourly, daily, weekly, monthly or yearly. You can find more details in the [documentation](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html). 90 | 91 | Another important aspect is alerting. It's important to receive notifications (in the form of email, slack message, Jira ticket or other) whenever the command fails or is waiting for a confirmation before proceeding with the update. This could be easily achieved with the help of SAP Alert Notification. More information can be found [here](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/e75533639c6d4193aa8a7e7420c25f8c.html). 92 | 93 | ## Expected result 94 | 95 | Let's execute the *UpdateHanaCloudDatabaseCF* command on a HANA Cloud database with multiple available QRC versions: 96 | 97 | ![HANA Cloud Available Versions](assets/hana-with-available-versions.png) 98 | 99 | We'll trigger it with *updateStrategy=next QRC version*. After finding the available QRC version, the execution halts: 100 | 101 | ![Paused Execution](assets/paused-execution.png) 102 | 103 | :information_source: The update confirmation can be disabled by triggering the command with `shouldConfirmBeforeUpdate=false`. This way the update will be performed completely automatically. 104 | 105 | Clicking on the *Confirm* button will present us with a dialog. We'll need to decide whether we want to continue with the update or abort it. For the sake of the demonstration, we'll confirm it: 106 | 107 | ![Confirmation Dialog](assets/confirmation-dialog.png) 108 | 109 | The execution begins the update to next QRC version. It might take a while, depending on the size of your database and its configuration. 110 | 111 | ![Running Update](assets/running-update.png) 112 | 113 | Eventually the execution finishes successfully: 114 | 115 | ![Finished Update](assets/finished-update.png) 116 | 117 | Clicking on *Output Values* will show us a short summary which is useful for transparency and traceability: 118 | 119 | ![Update Summary](assets/update-summary.png) 120 | 121 | We can also verify that the update was successful by checking the version in SAP HANA Cloud Central: 122 | 123 | ![Updated HANA Cloud](assets/updated-hana.png) 124 | -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/btp-cloud-foundry-env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/btp-cloud-foundry-env.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/confirmation-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/confirmation-dialog.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/finished-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/finished-update.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/hana-with-available-versions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/hana-with-available-versions.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/paused-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/paused-execution.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/running-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/running-update.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/update-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/update-summary.png -------------------------------------------------------------------------------- /patch-update-hana-cloud/assets/updated-hana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/patch-update-hana-cloud/assets/updated-hana.png -------------------------------------------------------------------------------- /prepare-btp-environment/README.md: -------------------------------------------------------------------------------- 1 | # Setup Cloud Foundry BTP Environment 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | As a continuation of the [Create and Configure BTP Subaccount](../prepare-btp-subaccount) example, we can use SAP Automation Pilot to fully setup the Cloud Foundry environment in an already existing BTP subaccount. 13 | 14 | The example command utilizes the **SAP Cloud Management Service (cis-sapcp)** and **Cloud Foundry (cf-sapcp)** provided catalogs to: 15 | 16 | * Enable the Cloud Foundry environment 17 | * Assign the *OrgManager* to the specified users 18 | * Create a Cloud Foundry space 19 | * Assign the *SpaceManager* role to the specified users. 20 | * Create service instance and key of *SAP Authorization and Trust Management Service (plan apiacces)*, which can be used to manage users on subaccount level. To learn how to manage users and their privileges on subaccount level, please check for [Grant Privileges Example](../grant-privileges/). 21 | 22 | ![Pipeline](assets/pipeline.png) 23 | 24 | :information_source: Make sure to check the other examples in the [BTP Provisioning](../README.md#btp-provisioning) section. 25 | 26 | ## Requirements 27 | 28 | To use this example you'll need the following: 29 | 30 | * BTP subaccount 31 | * Platform user with access to the BTP subaccount 32 | * Instance of [SAP Cloud Management Service](https://discovery-center.cloud.sap/serviceCatalog/8ffcd3a4-2d85-4a04-a762-be3e31f78a7c) with plan *local* and a service key/binding with default configurations. They must be created in a same BTP subaccount. 33 | 34 | :warning: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 35 | 36 | Check out the following resources for more information: 37 | 38 | * [Example: Create and Configure BTP Subaccount](../prepare-btp-subaccount/) 39 | * [Getting Started in the Cloud Foundry Environment](https://help.sap.com/docs/btp/sap-business-technology-platform/getting-started-in-cloud-foundry-environment) 40 | * [Getting Access to SAP Cloud Management Service](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/3670474a58c24ac2b082e76cbbd9dc19.html) 41 | * [SAP Cloud Management Service - Service Plans](https://help.sap.com/docs/btp/sap-business-technology-platform/sap-cloud-management-service-service-plans) 42 | 43 | ## How to use 44 | 45 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *PrepareCloudFoundryEnvironment* command and trigger it. 46 | 47 | You'll need to provide values for the following input keys: 48 | 49 | * *org* - Display name of the Cloud Foundry organization 50 | * *space* - Display name of the Cloud Foundry space 51 | * *admins* - Additional users that will receive the *OrgManager* and *SpaceManager* roles 52 | * *user* - UserID/Email for BTP user account used for authentication 53 | * *password* - Password for BTP user account used for authentication 54 | * *serviceKey* - The original JSON, presented by *SAP Cloud Management Service (plan local)* 55 | 56 | You'll receive the following output values after successfuly executing the command: 57 | 58 | * *orgId* - GUID of the Cloud Foundry organization 59 | * *spaceId* - GUID of the Cloud Foundry space 60 | * *region* - Technical name of the SAP BTP region in which the environment was enabled 61 | * *xsuaaServiceKey* - Service Key for *SAP Authorization and Trust Management Service (plan apiaccess)* 62 | 63 | :information_source: The region in which the environment was enabled might be different than the region of the subaccount. 64 | 65 | :information_source: The *xsuaaServiceKey* output is marked as sensitive and its value cannot be displayed in the UI. However, it can be referenced and used when composed in another command. 66 | 67 | ## Expected result 68 | 69 | Let's execute the *PrepareCloudFoundryEnvironment* command with the following input: 70 | 71 | * *org* - example-organization-d174df 72 | * *space* - example-space 73 | * *admins* - ["john.doe@sap.com"] *Note: Use your Email address* 74 | * *user* - *BTP technical user* 75 | * *password* - *BTP technical user password* 76 | * *serviceKey* - *Service key for SAP Cloud Management Service (plan local)* 77 | 78 | Execution is started and we can monitor its progress: 79 | 80 | ![Running Execution](assets/running-execution.png) 81 | 82 | After a few seconds, the execution should finish successfully: 83 | 84 | ![Finished Execution](assets/finished-execution.png) 85 | 86 | ![Output Result](assets/output-results.png) 87 | 88 | :information_source: The value of *xsuaaServiceKey* is not displayed because it's marked as sensitive. 89 | 90 | We can verify that the command was successful by checking the BTP subaccount overview: 91 | 92 | ![BTP Cockpit - Subaccount Overview](assets/subaccount-overview.png) 93 | 94 | Cloud Foundry space has a single service instances with binding: 95 | 96 | ![BTP Cockpit - Service Instance](assets/service-instance.png) 97 | -------------------------------------------------------------------------------- /prepare-btp-environment/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/finished-execution.png -------------------------------------------------------------------------------- /prepare-btp-environment/assets/output-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/output-results.png -------------------------------------------------------------------------------- /prepare-btp-environment/assets/pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/pipeline.png -------------------------------------------------------------------------------- /prepare-btp-environment/assets/running-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/running-execution.png -------------------------------------------------------------------------------- /prepare-btp-environment/assets/service-instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/service-instance.png -------------------------------------------------------------------------------- /prepare-btp-environment/assets/subaccount-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-environment/assets/subaccount-overview.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/README.md: -------------------------------------------------------------------------------- 1 | # Create and Configure BTP Subaccount 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | In this example, we'll explore the capabilities of SAP Automation Pilot to create subaccounts and make basic configurations. 13 | 14 | The example command utilizes the **SAP Cloud Management Service (cis-sapcp)** provided catalog to: 15 | 16 | * Create new BTP subaccount. 17 | * Configure entitlement for *SAP Cloud Management Service (cis)*. 18 | * Create service instance and key of *SAP Service Manager*, which can be used to manage service instances. 19 | * Create service instance and key of *SAP Cloud Management Service (plan local)*, which can be used to setup environments and subscriptions. 20 | 21 | ![Pipeline](assets/pipeline.png) 22 | 23 | Customers can easily modify the example command to fit their scenarios. For example, adding additional entitlements or creating additional service instances. 24 | 25 | :information_source: Both the *Service Manager* and *Cloud Management Service* catalogs work with the technical names of the services and their plans. You can find their values in your BTP subaccount, under *Entitlements*: 26 | 27 | ![BTP Entitlements](./assets/btp-entitlements.png) 28 | 29 | :warning: The example command is designed to ensure that the available subaccount is not deleted in the event of a failure. 30 | :information_source: Make sure to check the other examples in the [BTP Provisioning](../README.md#btp-provisioning) section. 31 | 32 | ## Requirements 33 | 34 | To use this example you'll need the following: 35 | 36 | * BTP global account 37 | * Platform user with access to the BTP global account and administrator roles in the subaccount where the key will be created in the CIS Central service instance 38 | * Enable Entitlements for Cloud Management Service in both the global account in BTP and the subaccount with the `central` plan 39 | * Instance of [SAP Cloud Management Service](https://discovery-center.cloud.sap/serviceCatalog/8ffcd3a4-2d85-4a04-a762-be3e31f78a7c) with plan *central* and a service key/binding with default configurations. They must be created in a separate BTP subaccount in the same global account. When creating the service instance you must choose Password as the Authorization Type: 40 | 41 | ![Cloud Management Authorization](./assets/cloud-management-authorization.png) 42 | 43 | :warning: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 44 | 45 | Check out the following resources for more information: 46 | 47 | * [Getting a Global Account](https://help.sap.com/docs/btp/sap-business-technology-platform/getting-global-account) 48 | * [Getting Access to SAP Cloud Management Service](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/3670474a58c24ac2b082e76cbbd9dc19.html) 49 | * [SAP Cloud Management Service - Service Plans](https://help.sap.com/docs/btp/sap-business-technology-platform/sap-cloud-management-service-service-plans) 50 | 51 | ## How to use 52 | 53 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *PrepareSubAccount* command and trigger it. 54 | 55 | You'll need to provide values for the following input keys: 56 | 57 | * *displayName* - Display name of the BTP subaccount 58 | * *region* - Technical name of the BTP region, where the subaccount will be created 59 | * *subdomain* - Subdomain of the BTP subaccount 60 | * *admins* - Additional users with subaccount administrator role collection 61 | * *user* - UserID/Email for BTP user account used for authentication 62 | * *password* - Password for BTP user account used for authentication 63 | * *serviceKey* - The original JSON, presented by *SAP Cloud Management Service (plan central)* 64 | 65 | You'll receive the following output values after successfuly executing the command: 66 | 67 | * *cisServiceKey* - Service Key for *SAP Cloud Management Service (plan local)* 68 | * *smServiceKey* - Service key for *SAP Service Manager (plan subaccount-admin)* 69 | 70 | :information_source: These output values are marked as sensitive and their value cannot be displayed in the UI. However, they can be referenced and used when composed in another command. 71 | 72 | ## Expected result 73 | 74 | Let's execute the *PrepareSubAccount* command with the following input: 75 | 76 | * *displayName* - Example Subaccount 77 | * *region* - cf-eu10 78 | * *subdomain* - example-subaccount-12d68ccf3a09 79 | * *admins* - ["john.doe@sap.com"] *Note: Use your Email address* 80 | * *user* - *BTP technical user* 81 | * *password* - *BTP technical user password* 82 | * *serviceKey* - *Service key for SAP Cloud Management Service (plan central)* 83 | 84 | Execution is started and we can monitor its progress: 85 | 86 | ![Running Execution](assets/running-execution.png) 87 | 88 | After a few seconds, the execution should finish successfully: 89 | 90 | ![Finished Execution](assets/finished-execution.png) 91 | 92 | We can verify that the command was successful by checking BTP Cockpit: 93 | 94 | ![BTP Cockpit - Created Subaccount](assets/btp-cockpit.png) 95 | 96 | Subaccount has the correct region, display name and subdomain: 97 | 98 | ![BTP Cockpit - Subaccount Overview](assets/subaccount-overview.png) 99 | 100 | Subaccount has two services instances with bindings: 101 | 102 | ![BTP Cockpit - Service Instances](assets/service-instances.png) 103 | -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/btp-cockpit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/btp-cockpit.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/btp-entitlements.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/btp-entitlements.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/cloud-management-authorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/cloud-management-authorization.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/finished-execution.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/pipeline.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/running-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/running-execution.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/service-instances.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/service-instances.png -------------------------------------------------------------------------------- /prepare-btp-subaccount/assets/subaccount-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/prepare-btp-subaccount/assets/subaccount-overview.png -------------------------------------------------------------------------------- /pretty-print-xml/README.md: -------------------------------------------------------------------------------- 1 | # Pretty Print XML 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | The command uses a python script to pretty print xml. 13 | 14 | ## Requirements 15 | 16 | There are no requirements to use this command. 17 | 18 | ## How to use 19 | 20 | 1. Trigger the PrettyPrintXml command 21 | 2. Enter the XML you want to pretty print in the required input key `xml` 22 | 23 | ## Expected result 24 | 25 | The expected result is to receive the pretty printed XML in the `xml` output key. -------------------------------------------------------------------------------- /pretty-print-xml/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "xml": "$(.prettyPrintXml.output.output | filter(length != 0 and . != \"\\t\" and . != \"\\t\\t\") | join(\"\\n\"))" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "scripts-sapcp:ExecuteScript:2", 18 | "input": { 19 | "environment": "{\"XML\":\"$(.execution.input.xml | toEscapedJson)\"}", 20 | "script": "printf \"%s\" \"${XML}\" > data.xml\n\necho 'import xml.dom.minidom\n\ndom = xml.dom.minidom.parse(\"data.xml\")\npretty_xml_as_string = dom.toprettyxml()\nprint(pretty_xml_as_string)\n' > program.py\n\npython3 program.py" 21 | }, 22 | "alias": "prettyPrintXml", 23 | "description": null, 24 | "progressMessage": null, 25 | "initialDelay": null, 26 | "pause": null, 27 | "when": null, 28 | "validate": null, 29 | "autoRetry": null, 30 | "repeat": null, 31 | "errorMessages": [], 32 | "dryRun": null 33 | } 34 | ], 35 | "listeners": [] 36 | }, 37 | "id": "examples-<<>>:PrettyPrintXml:1", 38 | "name": "PrettyPrintXml", 39 | "description": null, 40 | "catalog": "examples-<<>>", 41 | "version": 1, 42 | "inputKeys": { 43 | "xml": { 44 | "type": "string", 45 | "sensitive": false, 46 | "required": true, 47 | "minSize": null, 48 | "maxSize": null, 49 | "minValue": null, 50 | "maxValue": null, 51 | "allowedValues": null, 52 | "allowedValuesFromInputKeys": null, 53 | "suggestedValues": null, 54 | "suggestedValuesFromInputKeys": null, 55 | "defaultValue": null, 56 | "defaultValueFromInput": null, 57 | "description": null 58 | } 59 | }, 60 | "outputKeys": { 61 | "xml": { 62 | "type": "string", 63 | "sensitive": false, 64 | "description": null 65 | } 66 | }, 67 | "tags": {} 68 | } 69 | ] 70 | } -------------------------------------------------------------------------------- /reassign-identity-provider/README.md: -------------------------------------------------------------------------------- 1 | # Reassign Identity Provider 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | SAP BTP supports the use of customer's own corporate identity provider for platform users. In this example, we'll use the SAP Automation Pilot to automate the migration from one identity provider (e.g. sap.ids) to another on a BTP subaccount level. 12 | 13 | This example provides two commands which utilize the **SAP Authorization and Trust Management Service (xsuaa-sapcp)** provided catalog. 14 | 15 | **ReassignIdentityProvider** performs the following actions on the target user: 16 | 17 | * Gets all role collections which are assigned to the user 18 | * Assigns the user to the new identity provider by keeping their original set of role collections 19 | * Removes the user from the old identity provider 20 | 21 | ![Reassign Single](./assets/reassign-single.png) 22 | 23 | **MassReassignIdentityProvider** performs the following actions in the target BTP subaccount: 24 | 25 | * Lists all users in the subaccount 26 | * Performs the *ReassignIdentityProvider* command on each user 27 | 28 | ![Reassign All](./assets/reassign-all.png) 29 | 30 | :information_source: Make sure to check the other examples in the [BTP Provisioning](../README.md#btp-provisioning) section. 31 | 32 | ## Requirements 33 | 34 | To use this example you'll need the following: 35 | 36 | * BTP subaccount 37 | * Configured Cloud Foundry environment 38 | * Instance of [SAP Authorization and Trust Management Service](https://discovery-center.cloud.sap/serviceCatalog/authorization-and-trust-management-service?region=all) with plan *apiaccess* and a service key/binding with default configurations 39 | * One or more custom identity providers 40 | 41 | Check out the following resources for more information: 42 | 43 | * [Example: Create and Configure BTP Subaccount](../prepare-btp-subaccount/) 44 | * [Example: Setup Cloud Foundry BTP Environment](../prepare-btp-environment/) 45 | * [Getting Started in the Cloud Foundry Environment](https://help.sap.com/docs/btp/sap-business-technology-platform/getting-started-in-cloud-foundry-environment) 46 | * [SAP Authorization and Trust Management Service](https://help.sap.com/docs/CP_AUTHORIZ_TRUST_MNG) 47 | * [Access Administration Using APIs of the SAP Authorization and Trust Management Service](https://help.sap.com/docs/btp/sap-business-technology-platform/access-administration-using-apis-of-sap-authorization-and-trust-management-service) 48 | * [Trust and Federation with Identity Providers](https://help.sap.com/docs/btp/sap-business-technology-platform/trust-and-federation-with-identity-providers) 49 | 50 | ## How to use 51 | 52 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *MassReassignIdentityProvider* command and trigger it. 53 | 54 | You'll need to provide values for the following input keys: 55 | 56 | * *currentIdentityProvider* - Origin key of the identity provider that is currently assigned to the users. For example: sap.ids 57 | * *newIdentityProvider* - Origin key of the identity provider that must be assigned to the users. For example: a1rwcluzy-platform 58 | * *serviceKey* - The original JSON, presented by *SAP Authorization and Trust Management Service (plan apiaccess)* 59 | 60 | After the successful execution of the command, you can check which users were reassigned to another identity provider: 61 | 62 | ![Finished Execution](./assets/finished-execution.png) 63 | 64 | ![Execution Output](./assets/output-results.png) 65 | 66 | To reassign the identity provider of a single user, navigate to the *ReassignIdentityProvider* command and trigger it. 67 | 68 | You'll need to provide values for the following input keys: 69 | 70 | * *targetUser* - Email address of the target user which identity provider must be reassigned. 71 | * *currentIdentityProvider* - Origin key of the identity provider that is currently assigned to the user. For example: sap.ids 72 | * *newIdentityProvider* - Origin key of the identity provider that must be assigned to the user. For example: a1rwcluzy-platform 73 | * *serviceKey* - The original JSON, presented by *SAP Authorization and Trust Management Service (plan apiaccess)* 74 | 75 | :information_source: You can verify the result of your executions by navigating to your BTP subaccount and choosing **Security -> Users**. 76 | -------------------------------------------------------------------------------- /reassign-identity-provider/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/reassign-identity-provider/assets/finished-execution.png -------------------------------------------------------------------------------- /reassign-identity-provider/assets/output-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/reassign-identity-provider/assets/output-results.png -------------------------------------------------------------------------------- /reassign-identity-provider/assets/reassign-all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/reassign-identity-provider/assets/reassign-all.png -------------------------------------------------------------------------------- /reassign-identity-provider/assets/reassign-single.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/reassign-identity-provider/assets/reassign-single.png -------------------------------------------------------------------------------- /remove-inactive-subaccount-users/README.md: -------------------------------------------------------------------------------- 1 | # Remove Inactive Subaccount Users 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to use SAP Automation Pilot to identify and remove inactive users from a subaccount in SAP BTP. The command allows customization of the inactivity grace period and provides options to exclude specific users or remove users who have never logged in. 13 | 14 | Inactive users can pose a security risk if they are not monitored or managed properly. Regularly cleaning up inactive users helps maintain compliance with internal and external security standards. 15 | 16 | Automating the removal of inactive users offers several advantages over manual processes, such as reducing time and effort, enabling the management of a large number of users across multiple subaccounts, and more. 17 | 18 | The command can also be scheduled to run on a weekly, monthly, or custom basis to ensure continuous compliance and security. 19 | 20 | ### Customization Options 21 | 22 | The command provides several customization options to tailor the automation to your needs: 23 | 24 | * **Grace Period**: Adjust the number of days since a user's last login after which they are considered inactive by modifying the `grace` input parameter. 25 | * **Remove Users Who Never Logged In**: Enable or disable the removal of users who have never logged in by setting the `removeNeverLogged` input parameter. 26 | * **Exclude Specific Users**: Specify a list of users who should not be removed even if they are inactive by providing their usernames in the `excludeUsers` input parameter. 27 | 28 | ## Requirements 29 | 30 | To use this example you'll need the following: 31 | 32 | * **SAP Automation Pilot Tenant**: Ensure you have access to an SAP Automation Pilot tenant. 33 | * **SAP Authorization and Trust Management Service**: A service key (API credentials) to enable programmatic access to the SAP Authorization and Trust Management Service. 34 | 35 | To gain API access to **SAP Authorization and Trust Management Service**, follow the steps in the [SAP BTP documentation](https://help.sap.com/docs/btp/sap-business-technology-platform/get-access-to-apis). 36 | 37 | You can also use the BTP CLI to create the necessary API credentials for your BTP subaccount with the following command: 38 | 39 | ```shell 40 | btp --format json create security/api-credential --name autopi-credential --sub-account '' 41 | ``` 42 | 43 | ## How to use 44 | 45 | 1. **Import the Example**: 46 | 47 | * Copy the content of the [catalog.json](./catalog.json) file. 48 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 49 | * Click on `Import` in the upper right corner. 50 | * Paste the catalog's content and import it. 51 | 52 | 2. **Trigger the Command Manually**: 53 | 54 | * Navigate to the `RemoveInactiveSubaccountUsers` command in your SAP Automation Pilot tenant. 55 | * Click on the *Trigger* button after getting familiar with the command 56 | * Provide values for the following input keys: 57 | * `serviceKey`: The service key for SAP Authorization and Trust Management Service. 58 | * `grace`: Number of days since the last login after which a user is considered inactive. 59 | * `removeNeverLogged`: Boolean flag to enable or disable the removal of users who have never logged in. 60 | * `excludeUsers`: List of usernames to exclude from removal even if they are inactive. 61 | * `targetIdentityProvider`: Identity provider of the target users (default is `sap.ids`). 62 | * Confirm and start the automation 63 | 64 | :information_source: If you want to test the command without actually removing any users, click on the *Trigger Dry* Run option. This will allow the command to identify which users are inactive without making any changes. Once you have reviewed the list of inactive users, you can run the command again in non-dry run mode to proceed with the removal. 65 | 66 | ## Expected result 67 | 68 | After executing the command, the following results are expected: 69 | 70 | * Inactive users, based on the specified grace period, will be identified and removed from the subaccount. 71 | * Users who have never logged in will be removed if the `removeNeverLogged` parameter is set to true. 72 | * Users specified in the `excludeUsers` list will not be removed, even if they are inactive. 73 | * A list of removed inactive users will be provided as output for verification and record-keeping. 74 | -------------------------------------------------------------------------------- /rotate-hana-cloud-db-credentials/README.md: -------------------------------------------------------------------------------- 1 | # Rotate HANA Cloud Database Credentials 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to automate the rotation of credentials for a HANA Cloud database. Credential rotation is an important security practice that helps to minimize the risk of unauthorized access by periodically updating passwords. Regularly rotating database credentials is essential for maintaining the security of your database. This example automates the process, reducing the operational effort and ensuring that credentials are updated consistently and securely. 13 | 14 | In addition, this example can be run on demand or scheduled to run on a regular basis to ensure that database credentials are rotated periodically: 15 | 16 | * **Weekly Rotation**: Schedule the automation to run every Sunday at 10 PM. 17 | * **Monthly Rotation**: Schedule the automation to run on the first day of every month at 9 AM. 18 | * **Quarterly Rotation**: Schedule the automation to run on the first day of every quarter (January 1st, April 1st, July 1st, October 1st) at 10 AM. 19 | 20 | The provided automation performs the following steps: 21 | 22 | 1. **Generate a New Password**: Generates a new password of a specified length using the [GENERATE_PASSWORD](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/generate-password-function-security) function in HANA Cloud 23 | 2. **Rotate the Password**: Updates the password for the specified HANA Cloud user with the newly generated password. 24 | 3. **Update Destination Service Destination**: Updates the SAP Destination Service with the new credentials, ensuring that any applications using this service can continue to connect to the HANA Cloud database. 25 | 26 | ## Requirements 27 | 28 | To use this example you'll need the following: 29 | 30 | * **SAP Automation Pilot Tenant**: Ensure you have access to an SAP Automation Pilot tenant. 31 | * **HANA Cloud Database**: A HANA Cloud database instance where the credentials will be rotated. 32 | * **SAP Destination Service**: An SAP Destination Service instance and a service key to store the new credentials. 33 | * **Admin Database User**: Credentials for an admin database user that will be used for the rotation. 34 | * **Whitelisted IP Addresses**: Ensure that the HANA Cloud database allows access from [SAP Automation Pilot addresses](https://help.sap.com/docs/automation-pilot/automation-pilot/what-is-sap-automation-pilot?locale=en-US#service-availability) by whitelisting them. 35 | 36 | ## How to use 37 | 38 | 1. **Import the Example**: 39 | 40 | * Copy the content of the [catalog.json](./catalog.json) file. 41 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 42 | * Click on `Import` in the upper right corner. 43 | * Paste the catalog's content and import it. 44 | 45 | 2. **Trigger the Command Manually**: 46 | 47 | * Navigate to the `RotateHanaCloudDatabaseCredentials` command in your SAP Automation Pilot tenant. 48 | * Click on the *Trigger* button after getting familiar with the command 49 | * Provide values for the following input keys: 50 | * `password`: Password for the admin database user that will be used for rotation. 51 | * `userToRotate`: Name of the database user whose password will be rotated. 52 | * `destinationName`: Name of the SAP Destination Service destination where the new password will be stored. 53 | * `connectionUrl`: Connection URL for access to the HANA Cloud database. 54 | * `user`: Name of the admin database user that will be used for rotation. 55 | * `passwordLength`: Length of the new password (optional, default is 16). 56 | * `destinationServiceKey`: Service key for SAP Destination Service. 57 | * Confirm and start the automation 58 | 59 | ## Expected result 60 | 61 | After successfully executing the example, the password for the specified HANA Cloud user will be updated with the newly generated one: 62 | 63 | ![Successful Rotation](./assets/successful-rotation.png) 64 | 65 | The SAP Destination Service destination will be updated with the new credentials. 66 | 67 | :information_source: Note that this example uses a destination of type TCP, which is not visible in the SAP BTP cockpit. However, it can be retrieved from the APIs by our custom application, or other places integrated with the SAP Destination Service. 68 | 69 | ![SAP BTP Cockpit](./assets/sap-btp-cockpit.png) 70 | -------------------------------------------------------------------------------- /rotate-hana-cloud-db-credentials/assets/sap-btp-cockpit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/rotate-hana-cloud-db-credentials/assets/sap-btp-cockpit.png -------------------------------------------------------------------------------- /rotate-hana-cloud-db-credentials/assets/successful-rotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/rotate-hana-cloud-db-credentials/assets/successful-rotation.png -------------------------------------------------------------------------------- /run-hana-cloud-stored-procedure/README.md: -------------------------------------------------------------------------------- 1 | # Run HANA Cloud Stored Procedure 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example demonstrates how to trigger a stored procedure in HANA Cloud asynchronously and continuously monitor its status until completion using SAP Automation Pilot. This approach is useful for efficiently managing long-running processes without interrupting the execution flow. 13 | 14 | To start the HANA Cloud stored procedure asynchronously, the example uses the following SQL statement: `CALL "sleep"(10) ASYNC`. The result of this query is the `ASYNC_CALL_ID`, which can be used to check the status of the procedure from the `M_PROCEDURE_ASYNC_EXECUTIONS` system view. You can find more details about this approach in the [HANA Cloud documentation](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/call-statement-procedural). 15 | 16 | This example can be easily adapted to run your own productive stored procedure by modifying the SQL statement and the procedure parameters as needed. 17 | 18 | ## Requirements 19 | 20 | To use this example you'll need the following: 21 | 22 | * **SAP Automation Pilot Tenant**: Ensure you have access to an SAP Automation Pilot tenant. 23 | * **HANA Cloud Database**: A HANA Cloud database instance where the stored procedure will be executed. 24 | * **Stored Procedure**: The procedure used in this example is a simple sleep procedure to simulate a long-running process. You must create it manually first, for example from the HANA Cloud SQL Console. 25 | 26 | ```sql 27 | CREATE PROCEDURE "sleep" (IN sleep_duration INT) 28 | LANGUAGE SQLSCRIPT 29 | SQL SECURITY INVOKER READS SQL DATA AS 30 | BEGIN 31 | USING SQLSCRIPT_SYNC as SyncLib; 32 | CALL SyncLib:SLEEP_SECONDS(sleep_duration); 33 | END 34 | ``` 35 | 36 | * **Database User Credentials**: Credentials for a database user with the necessary permissions to execute the stored procedure. 37 | 38 | ## How to use 39 | 40 | 1. **Import the Example**: 41 | 42 | * Copy the content of the [catalog.json](./catalog.json) file. 43 | * Go to your SAP Automation Pilot tenant and navigate to `My Catalogs`. 44 | * Click on `Import` in the upper right corner. 45 | * Paste the catalog's content and import it. 46 | 47 | 2. **Trigger the Command Manually**: 48 | 49 | * Navigate to the `RunHanaCloudStoredProcedure` command in your SAP Automation Pilot tenant. 50 | * Click on the *Trigger* button after getting familiar with the command. 51 | * Provide values for the following input keys: 52 | * `connectionUrl`: Connection URL for access to the HANA Cloud database 53 | * `user`: Name of the database user 54 | * `password`: Password for the database user 55 | * `procedureDuration`: Duration of the procedure in seconds (default is 30) 56 | * Confirm and start the automation. 57 | 58 | ## Expected result 59 | 60 | After successfully executing the example, the stored procedure will be triggered asynchronously, and the status will be continuously polled until completion. The output will include the following details: 61 | 62 | * **id**: The unique identifier of the procedure execution. 63 | * **startTime**: The start time of the procedure. 64 | * **endTime**: The end time of the procedure. 65 | * **errorText**: The error message in case the procedure execution has failed. 66 | * **errorCode**: The error code in case the procedure execution has failed. 67 | 68 | These output keys provide comprehensive information about the execution status and any potential issues that occurred during the process. 69 | -------------------------------------------------------------------------------- /run-hana-cloud-stored-procedure/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "errorText": "$(.PollProcedure.output.result | toArray[0][0].ERROR_TEXT)", 14 | "errorCode": "$(.PollProcedure.output.result | toArray[0][0].ERROR_CODE)", 15 | "startTime": "$(.PollProcedure.output.result | toArray[0][0].START_TIME)", 16 | "endTime": "$(.PollProcedure.output.result | toArray[0][0].END_TIME)", 17 | "id": "$(.PollProcedure.output.result | toArray[0][0].ASYNC_CALL_ID)" 18 | }, 19 | "executors": [ 20 | { 21 | "execute": "sql-sapcp:ExecuteHanaCloudSqlStatement:1", 22 | "input": { 23 | "password": "$(.execution.input.password)", 24 | "statement": "CALL \"sleep\"( $(.execution.input.procedureDuration) ) ASYNC", 25 | "connectionUrl": "$(.execution.input.connectionUrl)", 26 | "resultRowFormat": "OBJECT", 27 | "user": "$(.execution.input.user)" 28 | }, 29 | "alias": "TriggerProcedure", 30 | "description": "Starts the HANA Cloud stored procedure asynchronously", 31 | "progressMessage": null, 32 | "initialDelay": null, 33 | "pause": null, 34 | "when": null, 35 | "validate": null, 36 | "autoRetry": null, 37 | "repeat": null, 38 | "errorMessages": [], 39 | "dryRun": null 40 | }, 41 | { 42 | "execute": "sql-sapcp:ExecuteHanaCloudSqlStatement:1", 43 | "input": { 44 | "password": "$(.execution.input.password)", 45 | "statement": "SELECT\n *\nFROM\n M_PROCEDURE_ASYNC_EXECUTIONS\nWHERE\n ASYNC_CALL_ID = ?", 46 | "connectionUrl": "$(.execution.input.connectionUrl)", 47 | "resultRowFormat": "OBJECT", 48 | "parameters": "[\"$(.TriggerProcedure.output.result | toArray[0][0].ASYNC_CALL_ID)\"]", 49 | "user": "$(.execution.input.user)" 50 | }, 51 | "alias": "PollProcedure", 52 | "description": "Continuously check the status of the stored procedure until it is complete", 53 | "progressMessage": null, 54 | "initialDelay": null, 55 | "pause": null, 56 | "when": null, 57 | "validate": null, 58 | "autoRetry": null, 59 | "repeat": { 60 | "maxCount": 100, 61 | "until": { 62 | "semantic": "OR", 63 | "conditions": [ 64 | { 65 | "semantic": "OR", 66 | "cases": [ 67 | { 68 | "expression": "$(.PollProcedure.output.result | toArray[0][0].END_TIME)", 69 | "operator": "NOT_EQUALS", 70 | "semantic": "OR", 71 | "values": [ 72 | "$(null)" 73 | ] 74 | } 75 | ] 76 | } 77 | ] 78 | }, 79 | "delay": "10s", 80 | "failOnMaxCount": true 81 | }, 82 | "errorMessages": [], 83 | "dryRun": null 84 | } 85 | ], 86 | "listeners": [] 87 | }, 88 | "id": "examples-<<>>:RunHanaCloudStoredProcedure:1", 89 | "name": "RunHanaCloudStoredProcedure", 90 | "description": "Triggers a stored procedure in HANA Cloud asynchronously and then continuously polls its status until completion", 91 | "catalog": "examples-<<>>", 92 | "version": 1, 93 | "inputKeys": { 94 | "password": { 95 | "type": "string", 96 | "sensitive": true, 97 | "required": true, 98 | "minSize": null, 99 | "maxSize": null, 100 | "minValue": null, 101 | "maxValue": null, 102 | "allowedValues": null, 103 | "allowedValuesFromInputKeys": null, 104 | "suggestedValues": null, 105 | "suggestedValuesFromInputKeys": null, 106 | "defaultValue": null, 107 | "defaultValueFromInput": null, 108 | "description": "Password of the database user" 109 | }, 110 | "connectionUrl": { 111 | "type": "string", 112 | "sensitive": false, 113 | "required": true, 114 | "minSize": null, 115 | "maxSize": null, 116 | "minValue": null, 117 | "maxValue": null, 118 | "allowedValues": null, 119 | "allowedValuesFromInputKeys": null, 120 | "suggestedValues": null, 121 | "suggestedValuesFromInputKeys": null, 122 | "defaultValue": null, 123 | "defaultValueFromInput": null, 124 | "description": "The JDBC connection URL used for the SQL statement" 125 | }, 126 | "procedureDuration": { 127 | "type": "number", 128 | "sensitive": false, 129 | "required": false, 130 | "minSize": null, 131 | "maxSize": null, 132 | "minValue": null, 133 | "maxValue": null, 134 | "allowedValues": null, 135 | "allowedValuesFromInputKeys": null, 136 | "suggestedValues": null, 137 | "suggestedValuesFromInputKeys": null, 138 | "defaultValue": "30", 139 | "defaultValueFromInput": null, 140 | "description": "Duration of the procedure in seconds" 141 | }, 142 | "user": { 143 | "type": "string", 144 | "sensitive": false, 145 | "required": true, 146 | "minSize": null, 147 | "maxSize": null, 148 | "minValue": null, 149 | "maxValue": null, 150 | "allowedValues": null, 151 | "allowedValuesFromInputKeys": null, 152 | "suggestedValues": null, 153 | "suggestedValuesFromInputKeys": null, 154 | "defaultValue": null, 155 | "defaultValueFromInput": null, 156 | "description": "Name of the database user" 157 | } 158 | }, 159 | "outputKeys": { 160 | "errorText": { 161 | "type": "string", 162 | "sensitive": false, 163 | "description": "The error message in case the procedure execution has failed" 164 | }, 165 | "errorCode": { 166 | "type": "number", 167 | "sensitive": false, 168 | "description": "The error code in case the procedure execution has failed" 169 | }, 170 | "startTime": { 171 | "type": "string", 172 | "sensitive": false, 173 | "description": "The start time of the procedure" 174 | }, 175 | "endTime": { 176 | "type": "string", 177 | "sensitive": false, 178 | "description": "The end time of the procedure" 179 | }, 180 | "id": { 181 | "type": "number", 182 | "sensitive": false, 183 | "description": "The unique identifier of the procedure execution" 184 | } 185 | }, 186 | "tags": {} 187 | } 188 | ] 189 | } -------------------------------------------------------------------------------- /script-http-request/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Request via Script 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | Automation Pilot provides the [*HttpRequest*](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/6ce1e04b7812411db04b80ea769ef46e.html) command which allows customers to perform arbitrary HTTP request to any public endpoint. Its flexibility and simplicity provides a way to use and automate most modern HTTP APIs. 13 | 14 | To ensure scalability and optimal performance for all Automation Pilot customers, the *HttpRequest* command has a strict limit on the maximum time that each request can take, as well as limit on the response size. 15 | 16 | However, some customer scenarios require working with synchronous HTTP APIs. Request to such APIs might take minutes to complete. Similar requirements could also apply to the response size. 17 | 18 | Automation Pilot enables such scenarios with the [*ExecuteScript*](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/d0854dbb80d84946bb57791db94b7e20.html) command. It can be used to run scripts in a fully isolated environment. These scripts can run for up to 5 minutes with limited set of computing, memory and storage resources. 19 | 20 | The supported runtimes include bash, python, node.js and provides access to popular CLI tools including curl, jq, and git. 21 | 22 | This example command has very similar contract to the original *HttpRequest*. However, its implementation is base entirely on *ExecuteScript* by utilizing [curl](https://curl.se/) and [jq](https://stedolan.github.io/jq/). It could be used to send requests to slow synchronous APIs and to work with larger response bodies. 23 | 24 | :warning: *ExecuteScript* has [some limitations](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/d0854dbb80d84946bb57791db94b7e20.html) described in the documentation. They also apply to this example command. 25 | 26 | ## Requirements 27 | 28 | There are no mandatory requirements. This command can perform HTTP requests to any public endpoint. 29 | 30 | ## How to use 31 | 32 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *HttpRequestViaScript* command and trigger it. 33 | 34 | You'll need to provide values for the following input keys: 35 | 36 | * *method* - Request method to use 37 | * *url* - URL to which to send the request 38 | * *body* - Optional: Request body to send with the request 39 | * *headers* - Optional: Request headers to send with the request 40 | * *timeout* - Optional: Maximum time that the request can take. Defauls to 60 seconds. Maximum allowed value is 240 seconds. 41 | * *user* - Optional: User name to use for server authentication 42 | * *password* - Optional: Password to use for server authentication 43 | * *authorizationHeader* - Optional: Explicit value for the HTTP authorization header. Overwrites all other forms of authentication 44 | * *responseBodyTransformer* - Optional: JQ expression to transform the response body with. The format must follow the one described in 45 | 46 | ## Expected result 47 | 48 | Let's execute the *HttpRequestViaScript* command with the following input: 49 | 50 | * *method* - GET 51 | * *url* - https://eu10.autopilot.ondemand.com/health 52 | * *timeout* - 30 53 | 54 | After a few seconds, the execution should finish successfully: 55 | 56 | ![Finished Execution](assets/finished-execution.png) 57 | 58 | The execution's output should be similar to this one: 59 | 60 | ![Execution Output](assets/execution-output.png) 61 | -------------------------------------------------------------------------------- /script-http-request/assets/execution-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/script-http-request/assets/execution-output.png -------------------------------------------------------------------------------- /script-http-request/assets/finished-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/script-http-request/assets/finished-execution.png -------------------------------------------------------------------------------- /transform-data/README.md: -------------------------------------------------------------------------------- 1 | # Transform Data 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | The commands attempts to transform data from the source data type to the target data type. 13 | Currently this commands transforming data from and to: 14 | * JSON 15 | * XML 16 | * YAML 17 | * CSV 18 | 19 | ## Requirements 20 | 21 | There are no requirements to use this command. 22 | 23 | ## How to use 24 | 25 | Enter the required input keys: 26 | * data 27 | * sourceFormat 28 | * targetFormat 29 | 30 | ## Expected result 31 | 32 | The expected result is to received the output data in the target format. 33 | 34 | ### Examples 35 | 36 | * Transforming XML to JSON 37 | Input: 38 | ``` 39 | Hello 40 | ``` 41 | Output: 42 | ``` 43 | { 44 | "xml": { 45 | "@name": "John", 46 | "@age": 25, 47 | "$": "Hello" 48 | } 49 | } 50 | ``` 51 | 52 | * Transforming JSON to CSV 53 | Input: 54 | ``` 55 | [ 56 | { 57 | "name": "John", 58 | "age": 25 59 | }, 60 | { 61 | "name": "Monica", 62 | "age": 23 63 | } 64 | ] 65 | ``` 66 | Output: 67 | ``` 68 | name,age 69 | John,25 70 | Monica,23 71 | ``` -------------------------------------------------------------------------------- /trigger-and-collect-outputs-batching/README.md: -------------------------------------------------------------------------------- 1 | # Trigger Multiple Executions and Collect their Outputs 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | This example contains commands that achieve the following 13 | 1. Execute a command with configured input values in batches 14 | 2. Collect the created executions' output values 15 | 3. Delete the created executions 16 | 17 | ## Requirements 18 | 19 | To use this example you'll need the following: 20 | 21 | The user and password of a SAP Automation Pilot service account with Read, Write, and Execute permissions. 22 | 23 | ## How to use 24 | 25 | 1. Import the catalog 26 | 2. Trigger the `TriggerAndCollectOutputsBatching` command 27 | 3. View the output of the execution 28 | 29 | ## Expected result 30 | 31 | By default the command will trigger and delete one execution of the Void command in SAP Automation Pilot. 32 | The output for the default input values will be: 33 | ``` 34 | [{"message":"Hello"}] 35 | ``` 36 | -------------------------------------------------------------------------------- /update-hana-cloud/README.md: -------------------------------------------------------------------------------- 1 | # Update of HANA Cloud Database 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | * [Expected result](#expected-result) 9 | 10 | ## Description 11 | 12 | SAP HANA Cloud releases new versions, also known as QRC (quarterly release cycle), every three months on the final day of each quarter. In between these QRC releases, patches containing bug fixes and other improvements are developed and made available. 13 | 14 | Ensuring that your HANA Cloud database is updated consistently is crucial for maintaining its security, reliability, and access to new features. Without user intervention, HANA Cloud instances are forcefully updated seven months following a version release. 15 | 16 | SAP Automation Pilot allows for complete automation of the update process. It can execute updates on a regular basis, entirely depending upon the customer's preference — weekly, monthly, quarterly, etc. Moreover, there's the choice of selecting a unique update strategy, enabling updates only to the latest patch version, the next available QRC version, or the latest possible QRC version. 17 | 18 | The command in this example executes the following steps: 19 | 20 | * Checks if an update is available based on the chosen update strategy. 21 | * Optionally, pauses and awaits explicit confirmation before performing the update. 22 | * Executes the update to the available version. 23 | * If no suitable version is available, the execution terminates without proceeding any further. 24 | 25 | Typically, an update requires the database to restart, resulting in downtime. Given this, the command pauses prior to the update until explicit confirmation is received from your DevOps team. If downtime is not an issue, or the database is configured to be updated without a restart, this confirmation can be disabled. For more information, visit this page: [Upgrading Without Restart](https://help.sap.com/docs/HANA_CLOUD/9ae9104a46f74a6583ce5182e7fb20cb/c26e42e6a7a4411191441c8d48fd9b11.html) 26 | 27 | :warning: Please note: It is not possible to revert to a previous version once the upgrade is complete. We strongly advise verifying everything works as expected on a test system prior to applying the update to the production environment. 28 | 29 | ## Requirements 30 | 31 | ### Cloud Foundry Environment 32 | 33 | If your HANA Cloud database is in the Cloud Foundry environment: 34 | 35 | * HANA Cloud database in the *Cloud Foundry environment*. 36 | * Platform user with *Space Developer* role in the space where the database resides. 37 | 38 | :warning: Please note: If you are planning to use SAP Universal ID, please keep [SAP Note 3085908](https://launchpad.support.sap.com/#/notes/3085908) in mind 39 | 40 | ### Other Environment (Subaccount level) 41 | 42 | If your HANA Cloud database is in the *Other environment*: 43 | 44 | * HANA Cloud database in the *Other environment*. 45 | * Instance of [SAP Service Manager](https://help.sap.com/docs/service-manager/sap-service-manager/sap-service-manager) with plan *subaccount-admin* and a service key. 46 | 47 | Check out the following resources for more information: 48 | 49 | * [Deploy SAP HANA Cloud](https://developers.sap.com/tutorials/hana-cloud-deploying.html) 50 | * [Create Users and Manage Roles and Privileges](https://developers.sap.com/tutorials/hana-cloud-mission-trial-4.html) 51 | 52 | ## How to use 53 | 54 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. 55 | 56 | ### Cloud Foundry Environment 57 | 58 | If your HANA Cloud database is in the *Cloud Foundry environment*, navigate to the *UpdateHanaCloudDatabaseCF* command and trigger it. 59 | 60 | You'll need to provide values for the following input keys: 61 | 62 | * *updateStrategy* - Update strategies that allow you to update in a variety of ways depending on your needs (latest patch version, next QRC version, latest QRC version) 63 | * *region* - Technical name of your SAP BTP region, e.g. cf-eu10, cf-us20, cf-eu10-004 64 | * *org* - Name of your Cloud Foundry organization 65 | * *space* - Name of your Cloud Foundry space 66 | * *hanaCloudInstance* - Name of your HANA Cloud service instance 67 | * *user* - Email or ID of your technical user 68 | * *password* - Password of your technical user 69 | * *identityProvider* - Optional: origin key of your identity provider. Defaults to sap.ids 70 | * *shouldConfirmBeforeUpdate* - Optional: whether to require confirmation before starting the update, if there's one available. Defaults to true 71 | 72 | :warning: Make sure that you using the correct *region* value by verifying it in the BTP Cockpit Overview page. For example, the region shown below is *cf-eu10-004*: 73 | 74 | ![BTP Cockpit Overview](assets/btp-cloud-foundry-env.png) 75 | 76 | ### Other Environment (Subaccount level) 77 | 78 | If your HANA Cloud database is in the *Other environment*, navigate to the *UpdateHanaCloudDatabaseOtherEnv* command and trigger it. 79 | 80 | You'll need to provide values for the following input keys: 81 | 82 | * *updateStrategy* - Update strategies that allow you to update in a variety of ways depending on your needs (latest patch version, next QRC version, latest QRC version) 83 | * *hanaCloudInstance* - Name of your HANA Cloud service instance 84 | * *serviceKey* - Service key to the SAP Service Manager, plan subaccount-admin 85 | * *shouldConfirmBeforeUpdate* - Optional: whether to require confirmation before starting the update, if there's one available. Defaults to true 86 | 87 | ### Scheduling 88 | 89 | This command is most useful if executed regularly. Automation Pilot allows executions to be automatically triggered on regular intervals - hourly, daily, weekly, monthly or yearly. You can find more details in the [documentation](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/96863a2380d24ba4bab0145bbd78e411.html). 90 | 91 | Another important aspect is alerting. It's important to receive notifications (in the form of email, slack message, Jira ticket or other) whenever the command fails or is waiting for a confirmation before proceeding with the update. This could be easily achieved with the help of SAP Alert Notification. More information can be found [here](https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/e75533639c6d4193aa8a7e7420c25f8c.html). 92 | 93 | ## Expected result 94 | 95 | Let's execute the *UpdateHanaCloudDatabaseCF* command on a HANA Cloud database with multiple available QRC versions: 96 | 97 | ![HANA Cloud Available Versions](assets/hana-with-available-versions.png) 98 | 99 | We'll trigger it with *updateStrategy=next QRC version*. After finding the available QRC version, the execution halts: 100 | 101 | ![Paused Execution](assets/paused-execution.png) 102 | 103 | :information_source: The update confirmation can be disabled by triggering the command with `shouldConfirmBeforeUpdate=false`. This way the update will be performed completely automatically. 104 | 105 | Clicking on the *Confirm* button will present us with a dialog. We'll need to decide whether we want to continue with the update or abort it. For the sake of the demonstration, we'll confirm it: 106 | 107 | ![Confirmation Dialog](assets/confirmation-dialog.png) 108 | 109 | The execution begins the update to next QRC version. It might take a while, depending on the size of your database and its configuration. 110 | 111 | ![Running Update](assets/running-update.png) 112 | 113 | Eventually the execution finishes successfully: 114 | 115 | ![Finished Update](assets/finished-update.png) 116 | 117 | Clicking on *Output Values* will show us a short summary which is useful for transparency and traceability: 118 | 119 | ![Update Summary](assets/update-summary.png) 120 | 121 | We can also verify that the update was successful by checking the version in SAP HANA Cloud Central: 122 | 123 | ![Updated HANA Cloud](assets/updated-hana.png) 124 | -------------------------------------------------------------------------------- /update-hana-cloud/assets/btp-cloud-foundry-env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/btp-cloud-foundry-env.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/confirmation-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/confirmation-dialog.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/finished-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/finished-update.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/hana-with-available-versions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/hana-with-available-versions.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/paused-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/paused-execution.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/running-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/running-update.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/update-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/update-summary.png -------------------------------------------------------------------------------- /update-hana-cloud/assets/updated-hana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/automation-pilot-examples/b300fe215d7e762d6aad308f37975ba48a84741d/update-hana-cloud/assets/updated-hana.png -------------------------------------------------------------------------------- /use-custom-npm-package/README.md: -------------------------------------------------------------------------------- 1 | # Use Custom NPM Package 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | SAP Automation Pilot has the functionality to run scripts in an isolated Linux environment which provides a large array of useful tools and runtimes including NodeJS. It's often necessary to install custom packges from the [npm registry](https://www.npmjs.com/) for functionalities that are not available in the standard NodeJS library. 12 | 13 | This examples show how to install a custom package such as [uuid](https://www.npmjs.com/package/uuid) and how to use it to generate UUIDs. The actual script can easily be modified to fit an actual productive scenario. 14 | 15 | Please refer to the [documentation](https://help.sap.com/docs/automation-pilot/automation-pilot/executescript-version-2) for more details about the Execute Script functionality in Automation Pilot. 16 | 17 | ## Requirements 18 | 19 | There are no mandatory requirements. 20 | 21 | ## How to use 22 | 23 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *UseCustomNpmPackage* command and check the configuration of the *PythonScript* executor. You can also trigger the command to see it in action. 24 | -------------------------------------------------------------------------------- /use-custom-npm-package/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "result": "$(.NodeJsScript.output.output | join(\"\\n\"))" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "scripts-sapcp:ExecuteScript:2", 18 | "input": { 19 | "script": "#!/usr/bin/env bash\n\n# Install custom NPM package\nnpm install uuid &> /dev/null\n\n# Run the actual NodeJS script\nnode << EOF\n\nconst { v4: uuidv4 } = require('uuid');\n\nfor (let i = 0; i < 10; i++) {\n console.log(uuidv4());\n}\n\nEOF" 20 | }, 21 | "alias": "NodeJsScript", 22 | "progressMessage": null, 23 | "initialDelay": null, 24 | "pause": null, 25 | "when": null, 26 | "validate": null, 27 | "autoRetry": null, 28 | "repeat": null, 29 | "errorMessages": [] 30 | } 31 | ], 32 | "listeners": [] 33 | }, 34 | "id": "examples-<<>>:UseCustomNpmPackage:1", 35 | "name": "UseCustomNpmPackage", 36 | "description": "Install and use custom NPM package in a script which generates UUIDs", 37 | "catalog": "examples-<<>>", 38 | "version": 1, 39 | "inputKeys": {}, 40 | "outputKeys": { 41 | "result": { 42 | "type": "string", 43 | "sensitive": false, 44 | "description": "Result of the NodeJS script" 45 | } 46 | }, 47 | "tags": {} 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /use-custom-python-package/README.md: -------------------------------------------------------------------------------- 1 | # Use Custom Python Package 2 | 3 | Table of Contents 4 | 5 | * [Description](#description) 6 | * [Requirements](#requirements) 7 | * [How to use](#how-to-use) 8 | 9 | ## Description 10 | 11 | SAP Automation Pilot has the functionality to run scripts in an isolated Linux environment which provides a large array of useful tools and runtimes including Python. It's often necessary to install custom packages from the [Python Package Index (PyPi)](https://pypi.org/) for functionalities that are not available in the standard Python library. 12 | 13 | This examples show how to install a custom package such as [requests](https://pypi.org/) and how to use it to send a simple HTTP request. The actual script can easily be modified to fit an actual productive scenario. 14 | 15 | Please refer to the [documentation](https://help.sap.com/docs/automation-pilot/automation-pilot/executescript-version-2) for more details about the Execute Script functionality in Automation Pilot. 16 | 17 | ## Requirements 18 | 19 | There are no mandatory requirements. 20 | 21 | ## How to use 22 | 23 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. Navigate to the *UseCustomPythonPackage* command and check the configuration of the *PythonScript* executor. You can also trigger the command to see it in action 24 | -------------------------------------------------------------------------------- /use-custom-python-package/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [], 8 | "commands": [ 9 | { 10 | "configuration": { 11 | "values": [], 12 | "output": { 13 | "result": "$(.PythonScript.output.output | join(\"\\n\"))" 14 | }, 15 | "executors": [ 16 | { 17 | "execute": "scripts-sapcp:ExecuteScript:2", 18 | "input": { 19 | "script": "#!/usr/bin/env bash\n\n# Install custom Python package\npip install requests -qq --no-warn-script-location\n\n# Run the actual Python script\npython3 <>>:UseCustomPythonPackage:1", 35 | "name": "UseCustomPythonPackage", 36 | "description": "Install and use custom Python package in a script which sends a call to a public API", 37 | "catalog": "examples-<<>>", 38 | "version": 1, 39 | "inputKeys": {}, 40 | "outputKeys": { 41 | "result": { 42 | "type": "string", 43 | "sensitive": false, 44 | "description": "Result of the Python script" 45 | } 46 | }, 47 | "tags": {} 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /use-make-and-helm/README.md: -------------------------------------------------------------------------------- 1 | # Use Make and Helm 2 | 3 | Table of Contents 4 | 5 | - [Use Make and Helm](#use-make-and-helm) 6 | - [Description](#description) 7 | - [Requirements](#requirements) 8 | - [How to use](#how-to-use) 9 | - [Cleaning up](#cleaning-up) 10 | 11 | ## Description 12 | 13 | SAP Automation Pilot has the functionality to run scripts in an isolated Linux environment which provides a large array of useful tools and runtimes including **kubectl**, **make** and **helm**. It migth be useful to pull a git repo, containing a helm chart project, build it and deploy it to a kubernetes cluster. 14 | 15 | This examples show how to configure your access to git and kubernetes cluster. Clone a repository containing helm project that builds with make. Build a make target and deploy a helm chart to kubernetes cluster. 16 | 17 | The example helm chart deploys a simple busy box deployment with a single replica to the default namespace. 18 | 19 | DISCLAIMER: the **make** tool is restricted to the current user and all security restrictions apply to any task that **make** tries to execute, so only **make** targets that do not require more privileges than the provided user can be leveraged in that way. 20 | 21 | DISCLAIMER: the script execution time is limited, so any long running jobs will not be able to finish. 22 | 23 | Please refer to the [documentation](https://help.sap.com/docs/automation-pilot/automation-pilot/executescript-version-2) for more details about the Execute Script functionality in Automation Pilot. 24 | 25 | ## Requirements 26 | 27 | Base64 encoded kubeconfig with access to a kubernetes cluster. 28 | 29 | ## How to use 30 | 31 | Import the content of [examples catalog](catalog.json) in your Automation Pilot tenant. 32 | - Navigate to the **Kubeconfig** input and put your base64 encoded kubeconfig as the **kubeconfig** value. 33 | - Navigate to the **HelmExample** command and trigger it to see it in action. 34 | 35 | **OPTIONAL**: 36 | - If you wish to use a different GIT repository than the provided one you can navigate to the **GitAccess** input and 37 | - put an [access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with read permissions as the **token** value 38 | - put the address of the repository to use without the protocol 39 | - You can then go to the **HelmExample** command and modify 40 | - **helmProjectPath** input key to point to the root directory of your helm project after cloning 41 | - **makeTarget** to use your desired **make** target 42 | 43 | ## Cleaning up 44 | To clean up the example resources on your kubernetes cluster you can trigger the **HelmExample** command with **uninstall_app** as the **makeTarget** input, or alternatively a cleanup target of your custom repository if you have configured one. 45 | -------------------------------------------------------------------------------- /use-make-and-helm/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "examples-<<>>", 3 | "technicalName": "examples", 4 | "name": "Automation Pilot Examples", 5 | "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", 6 | "owner": "<<>>", 7 | "inputs": [ 8 | { 9 | "id": "examples-<<>>:Kubeconfig:1", 10 | "name": "Kubeconfig", 11 | "description": "Provides the kubeconfig required to access the kubernetes cluster", 12 | "catalog": "examples-<<>>", 13 | "owner": null, 14 | "version": 1, 15 | "keys": { 16 | "kubeconfig": { 17 | "type": "string", 18 | "sensitive": true, 19 | "description": "Single line base64 encoded value of a kubeconfig providing the required access to a kubernetes cluster" 20 | } 21 | }, 22 | "values": { 23 | "kubeconfig": "" 24 | }, 25 | "tags": {} 26 | }, 27 | { 28 | "id": "examples-<<>>:MakeHelmGit:1", 29 | "name": "MakeHelmGit", 30 | "description": "Input containing the required information for git access to the helm project repository", 31 | "catalog": "examples-<<>>", 32 | "owner": null, 33 | "version": 1, 34 | "keys": { 35 | "helmProjectRepoAddress": { 36 | "type": "string", 37 | "sensitive": false, 38 | "description": null 39 | }, 40 | "token": { 41 | "type": "string", 42 | "sensitive": true, 43 | "description": "Token providing read access to the git repository. It can be left empty if the repository has public access." 44 | } 45 | }, 46 | "values": { 47 | "helmProjectRepoAddress": "github.com/SAP-samples/automation-pilot-examples.git", 48 | "token": "" 49 | }, 50 | "tags": {} 51 | } 52 | ], 53 | "commands": [ 54 | { 55 | "configuration": { 56 | "values": [], 57 | "output": { 58 | "scriptOutput": "$(.helmScript.output.output)" 59 | }, 60 | "executors": [ 61 | { 62 | "execute": "scripts-sapcp:ExecuteScript:2", 63 | "input": { 64 | "stdin": "$(.execution.input.kubeconfig)\n$(.execution.input.gitToken)", 65 | "environment": "{\"GIT_PROTOCOL\":\"https://\",\"GIT_ADDRESS\":\"$(.execution.input.gitAddress)\",\"MAKE_TARGET\":\"$(.execution.input.makeTarget)\",\"HELM_PROJECT_DIR\":\"$(.execution.input.helmProjectPath)\"}", 66 | "script": "#!/usr/bin/env bash\n\nread -t 5 CONFIG\nread -t 5 TOKEN\n\necho \"$CONFIG\" > ~/encodedConfig\n\nbase64 -i ~/encodedConfig -d > ~/config\n\nexport KUBECONFIG=~/config\n\ngit clone $GIT_PROTOCOL$TOKEN@$GIT_ADDRESS\n\ncd \"$HELM_PROJECT_DIR\"\n\nmake $MAKE_TARGET\n" 67 | }, 68 | "alias": "helmScript", 69 | "progressMessage": null, 70 | "initialDelay": null, 71 | "pause": null, 72 | "when": null, 73 | "validate": null, 74 | "autoRetry": null, 75 | "repeat": null, 76 | "errorMessages": [] 77 | } 78 | ], 79 | "listeners": [] 80 | }, 81 | "id": "examples-<<>>:HelmExample:1", 82 | "name": "HelmExample", 83 | "description": "Clones a git repo with helm project in it and executes a make target on the cloned repo.", 84 | "catalog": "examples-<<>>", 85 | "version": 1, 86 | "inputKeys": { 87 | "helmProjectPath": { 88 | "type": "string", 89 | "sensitive": false, 90 | "required": false, 91 | "minSize": null, 92 | "maxSize": null, 93 | "minValue": null, 94 | "maxValue": null, 95 | "allowedValues": null, 96 | "allowedValuesFromInputKeys": null, 97 | "suggestedValues": null, 98 | "suggestedValuesFromInputKeys": null, 99 | "defaultValue": "automation-pilot-examples/use-make-and-helm/helm-example", 100 | "defaultValueFromInput": null, 101 | "description": "Path pointing to the helm project directory. This directory is expected to contain the Makefile with the desired target" 102 | }, 103 | "gitAddress": { 104 | "type": "string", 105 | "sensitive": false, 106 | "required": false, 107 | "minSize": null, 108 | "maxSize": null, 109 | "minValue": null, 110 | "maxValue": null, 111 | "allowedValues": null, 112 | "allowedValuesFromInputKeys": null, 113 | "suggestedValues": null, 114 | "suggestedValuesFromInputKeys": null, 115 | "defaultValue": null, 116 | "defaultValueFromInput": { 117 | "inputReference": "examples-<<>>:MakeHelmGit:1", 118 | "inputKey": "helmProjectRepoAddress" 119 | }, 120 | "description": "Address pointing to the git repository. I.E. github.com/{{user}}/{{repository}}.git" 121 | }, 122 | "makeTarget": { 123 | "type": "string", 124 | "sensitive": false, 125 | "required": false, 126 | "minSize": null, 127 | "maxSize": null, 128 | "minValue": null, 129 | "maxValue": null, 130 | "allowedValues": null, 131 | "allowedValuesFromInputKeys": null, 132 | "suggestedValues": [ 133 | "install_app", 134 | "uninstall_app" 135 | ], 136 | "suggestedValuesFromInputKeys": null, 137 | "defaultValue": "install_app", 138 | "defaultValueFromInput": null, 139 | "description": "Make target to execute in the designated folder." 140 | }, 141 | "gitToken": { 142 | "type": "string", 143 | "sensitive": true, 144 | "required": false, 145 | "minSize": null, 146 | "maxSize": null, 147 | "minValue": null, 148 | "maxValue": null, 149 | "allowedValues": null, 150 | "allowedValuesFromInputKeys": null, 151 | "suggestedValues": null, 152 | "suggestedValuesFromInputKeys": null, 153 | "defaultValue": null, 154 | "defaultValueFromInput": { 155 | "inputReference": "examples-<<>>:MakeHelmGit:1", 156 | "inputKey": "token" 157 | }, 158 | "description": "Token granting read permissions to the git repository." 159 | }, 160 | "kubeconfig": { 161 | "type": "string", 162 | "sensitive": true, 163 | "required": false, 164 | "minSize": null, 165 | "maxSize": null, 166 | "minValue": null, 167 | "maxValue": null, 168 | "allowedValues": null, 169 | "allowedValuesFromInputKeys": null, 170 | "suggestedValues": null, 171 | "suggestedValuesFromInputKeys": null, 172 | "defaultValue": null, 173 | "defaultValueFromInput": { 174 | "inputReference": "examples-<<>>:Kubeconfig:1", 175 | "inputKey": "kubeconfig" 176 | }, 177 | "description": "Single line Base64 encoded kubeconfig granting access to the target kubernetes cluster." 178 | } 179 | }, 180 | "outputKeys": { 181 | "scriptOutput": { 182 | "type": "string", 183 | "sensitive": false, 184 | "description": "The output of the script execution" 185 | } 186 | }, 187 | "tags": {} 188 | } 189 | ] 190 | } -------------------------------------------------------------------------------- /use-make-and-helm/helm-example/Makefile: -------------------------------------------------------------------------------- 1 | install_app: 2 | helm upgrade --atomic --install make-helm-example ./chart 3 | 4 | uninstall_app: 5 | helm uninstall make-helm-example -------------------------------------------------------------------------------- /use-make-and-helm/helm-example/chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: busy-box 3 | version: 1.0.0 4 | appVersion: 1.0.0 5 | deprecated: false 6 | -------------------------------------------------------------------------------- /use-make-and-helm/helm-example/chart/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | app: {{ .Values.appName }} 6 | name: {{ .Values.appName }} 7 | spec: 8 | replicas: {{ .Values.replicas }} 9 | selector: 10 | matchLabels: 11 | app: {{ .Values.appName }} 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ .Values.appName }} 16 | spec: 17 | containers: 18 | - image: {{ .Values.imageName }} 19 | name: {{ .Values.appName }}-{{ randAlphaNum 5 | lower }} 20 | resources: {} 21 | command: ["sh", "-c", "while true; do sleep 86400; done"] -------------------------------------------------------------------------------- /use-make-and-helm/helm-example/chart/values.yaml: -------------------------------------------------------------------------------- 1 | appName: busy-box 2 | imageName: busybox 3 | replicas: 1 --------------------------------------------------------------------------------