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 POST APIs

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

Overview

🎓 beginner 25 min. SAP HANABeginnerSAP API Management

You will learn

  • โœ”What are the cockpit POST APIs that you can use
  • โœ”How to call cockpit POST APIs
Unknown U Unknown March 27, 2023
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 modifying (POST) REST API endpoints. Unlike the GET endpoints, the POST endpoints create, delete, or change objects in the cockpit.

There are nineteen cockpit POST API endpoints:

  1. SystemRegister: registers an SAP HANA resource in the cockpit
  2. SystemUnregister: unregisters an SAP HANA resource that’s already registered
  3. CockpitUserCreate: creates a new cockpit user
  4. CockpitUserDelete: deletes a cockpit user
  5. CockpitUserUpdate: updates an existing user (SSO option available)
  6. CockpitUserRetrieve: returns a cockpit user’s information with role collection
  7. GroupCreate: creates a new resource group
  8. GroupDelete: deletes a resource group
  9. GroupResourceAdd: adds a resource to a group
  10. GroupResourceRemove: removes a resource from a group
  11. GroupUserAdd: adds a user to a group
  12. GroupUserRemove: removes a user from a group
  13. GroupUpdate: updates the information of an existing group
  14. ResourceSecurityUpdate: enables, disables, enforces resource SSO
  15. ResourceUpdate: updates database name, description, owner name, owner email, and owner details
  16. TechnicalUserStore: updates database technical user name and password
  17. SSOKerberosUpdate: enables/disables SSO with Kerberos
  18. RemoteCredentialsSet: stores credentials for the database user connecting to the monitored database (as displayed in Database Directory, uses cockpit-landscape-svc)
  19. SapControlUserSet*: sets credentials for SAPControl access

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

The sample code for all the cockpit APIs (GET and POST ones) is posted in Step 5. 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 SystemRegister endpoint
โ€”

This endpoint registers an SAP HANA resource in the cockpit. You have two options to register a cockpit resource: either by using its instance number or its port number.

Copy the following code to your Python program:

Python
def add_resource_via_instance(client, authorization, hostName, instanceNumber, techUser, techUserCredentials,\
                         databaseName, encryptJDBC, validateServerCertificate, hostNameInCertificate):
    if databaseName == None:
        data = {'hostName': hostName,
				'instanceNumber': instanceNumber,
				'techUser': techUser,
				'techUserCredentials': techUserCredentials,
				'isMultiTenant': False,
				'encryptJDBC': encryptJDBC,
			    'validateServerCertificate': validateServerCertificate,
                'hostNameInCertificate': hostNameInCertificate}

    else:
        data = {'hostName': hostName,
				'instanceNumber': instanceNumber,
				'techUser': techUser,
				'techUserCredentials': techUserCredentials,
				'databaseName': databaseName,
				'isMultiTenant': True,
				'encryptJDBC': encryptJDBC,
		    	'validateServerCertificate': validateServerCertificate,
                'hostNameInCertificate': hostNameInCertificate}

    targetURI = baseURL + '/registration/SystemRegister'
    resourceCreateResponse = client.post(targetURI, verify=False, json=data, headers=get_header(authorization))

    return resourceCreateResponse.json()

Then call the function by replacing the parameters with the corresponding information. In this example, we will choose not encrypting anything nor putting an override hostname in certificate.

Python
result = add_resource_via_instance(client, authorization, '<host.domain.com>', '<instance>', 'TECH_USER', 'Password1', '', False, False, '')
print(json.dumps(result, indent=4, sort_keys=True))

Run the entire program (make sure to delete or comment out the calling statements for the GET endpoints) and your output should be similar to the following:

JSON
{
    "result": {
        "resid": 111,
        "resourceName": "SYSTEMDB@DEMO"
    }
}
Step 2 Call the ResourceUnregister endpoint
+
Step 3 Call the CockpitUserCreate endpoint
+
Step 4 Call the CockpitUserDelete endpoint
+
Step 5 Appendix
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Call the SystemRegister endpoint 2. Call the ResourceUnregister endpoint 3. Call the CockpitUserCreate endpoint 4. Call the CockpitUserDelete endpoint 5. Appendix

Learn more →