SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Call SAP HANA Cockpit GET APIs

Introduce all the available SAP HANA cockpit GET APIs and the method to use them.

Overview

🎓 beginner 15 min. SAP HANABeginnerSAP API Management

You will learn

  • โœ”What are the cockpit GET APIs that you can use
  • โœ”How to call a cockpit GET APIs
Unknown U Unknown November 1, 2022
Created by November 20, 2018
Contributors

Prerequisites

Prerequisites

  • Install the Python programming language on the computer that will call the endpoints

Steps

Intro

SAP HANA cockpit provides non modifying (GET) REST API endpoints. The GET APIs don’t create, delete, or change anything in the cockpit - they only inform you the existing information that you would like to examine.

There are five cockpit GET API endpoints:

  1. RegisteredResourcesGet: returns information about the resources registered in SAP HANA cockpit
  2. GroupsForUserGet: returns information about the resource groups that are visible to you
  3. GroupResourcesGet: returns information about the resources in a specified group that is visible to you (uses cockpit-landscape-svc)
  4. GroupUsersGet: returns information about the cockpit users in SAP HANA cockpit Database Group
  5. CockpitUsersGet: returns information about cockpit users

Only two of the five cockpit GET APIs will be further explained in the following steps. To know more about the cockpit GET APIs, click here to navigate to the SAP Help Portal.

The sample code for all the cockpit APIs (GET and POST ones) is posted at the end of the cockpit POST APIs tutorial as an appendix. The code is written in Python and you are welcome to copy and run it to examine how each API works.


Step 1 Call the RegisteredResourcesGet endpoint
โ€”

This endpoint provides information about the resources registered in SAP HANA cockpit that you are allowed to see.

To use this API, copy the following code to your Python file.

Python
def list_cockpit_resources(client, authorization):
    targetURI = baseURL + '/resource/RegisteredResourcesGet'

    resourceListResponse = client.get(targetURI, verify=False, headers=get_header(authorization))
    return resourceListResponse.json()

Suppose we only want all the names and the ID numbers of the cockpit resources. We then need to parse the JSON response:

Python
result = list_cockpit_resources(client, authorization)
resources = result["result"]
print("Cockpit resources:")
for resource in resources:
    print("- Resource name: " + resource["ResourceName"] + ", resource ID: " + resource["ResourceId"])

Run the entire program and your output should be similar to the following:

Code
Cockpit resources:
- Resource name: SYSTEMDB@H4C, resource ID: 1
- Resource name: SYSTEMDB@DB1, resource ID: 2
- Resource name: DB1@DB1, resource ID: 3
Step 2 Call the GroupsForUserGet endpoint
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 2
1. Call the RegisteredResourcesGet endpoint 2. Call the GroupsForUserGet endpoint

Learn more →