IBM Support

Part 2: Configuration management

White Papers


Abstract

This tutorial series explains how to use the REST management interface to manage and monitor the configuration of IBM DataPower Gateway appliances. It describes the functions, structure, and capabilities of the REST management interface, as implemented in firmware release 7.2.0.0. This series also includes examples of common use cases with associated request and response payloads. In Part 1, you learned the basic concepts of the REST management interface and status monitoring. In Part 2, you learn how to manage appliance configurations by using the REST management interface.

Content

Introduction

The REST management interface offers end-to-end configuration management capabilities in firmware release 7.2.0.0 of the IBM DataPower Gateway Appliance. You can retrieve and view existing configurations, perform updates on existing configurations, create configurations, and delete configurations. In Part 2 of this series, you learn about requests to retrieve, modify, and delete existing configurations. You also learn how to compose request payloads to create configurations. For information about other request types, such as status monitoring, file and directory management, and appliance operations, see the other parts in this series.

Retrieving existing configurations

In this section, you retrieve configurations of objects that are on the appliance.

Identify the object class

To begin retrieving existing configurations from the appliance, you first identify the object class of interest. To identify the required class name, access the root Uniform Resource Identifier (URI) of the REST management interface, as the following request shows, to identify the configuration root URI:

 GET https://dphost.com:5554/mgmt/

In the received response, as shown in Listing 1, you can identify the configuration root URI as /mgmt/config/.

Root URI response
 {   "_links": {     "self": {       "href": "/mgmt/"     },     "config": {       "href": "/mgmt/config/"     },     "domains": {       "href": "/mgmt/domains/config/"     },     "status": {       "href": "/mgmt/status/"     },     "actionqueue": {       "href": "/mgmt/actionqueue/"     },     "filestore": {       "href": "/mgmt/filestore/"     },     "metadata": {       "href": "/mgmt/metadata/"     },     "types": {       "href": "/mgmt/types/"     }   } }

Access the configuration root URI, /mgmt/config/, to retrieve a list of all available object classes on the appliance, as the following request shows:

 GET https://dphost.com:5554/mgmt/config/

To identify the exact formatting of the class name, search the received response payload, which is partially shown in Listing 2.

Partial response of the configuration root URI
 {   "_links": {     "self": {       "href": "/mgmt/config/"     }   },   "AAAPolicy": {     "href": "/mgmt/config/{domain}/AAAPolicy"   },   "AccessControlList": {     "href": "/mgmt/config/{domain}/AccessControlList"   },   "AppSecurityPolicy": {     "href": "/mgmt/config/{domain}/AppSecurityPolicy"   },   "AS2ProxySourceProtocolHandler": {     "href": "/mgmt/config/{domain}/AS2ProxySourceProtocolHandler"   },   "AuditLog": {     "href": "/mgmt/config/{domain}/AuditLog"   },   "CertMonitor": {     "href": "/mgmt/config/{domain}/CertMonitor"   },   "CloudConnectorService": {     "href": "/mgmt/config/{domain}/CloudConnectorService"   },   ... }

As an alternative to identifying the formatting of the object class, examine the URI that is displayed in the WebGUI browser window when an object or object list is accessed.

Retrieve the object class list

After you determine the formatting of the class name, you can retrieve a list of existing objects for the target class. To retrieve the list, construct a URI of the form /mgmt/config/{domain}/{class_name}, replacing {domain} with the target domain and replacing {class_name} with the object class. This URI is shown in the following example with the target domain of my-testing-domain and the class name of HTTPSourceProtocolHandler:

 GET https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler

The response to a class listing request returns all objects of the class within the target domain. If no objects exist for the class, an informational message is returned, as shown in Listing 3.

Object class list response
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler"     }   },   "result": "no configuration retrieved"   } }
Retrieve the object-level configuration

If at least one object of a specific class exists within a domain, you can retrieve the configuration of that object. To retrieve the configuration, construct a URI of the form /mgmt/config/{domain}/{class_name}/{object_name}. In this form, replace {domain} with the target domain, {class_name} with the object class, and {object_name} with the specific object instance.

The following request shows this URI. Here, the target domain is my-testing-domain, the class name is HTTPSourceProtocolHandler, and the object name is test-HTTP-SPH.

 GET https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH

The response to an object retrieval request returns the configuration of a specific object instance within the target domain, as shown in Listing 4.

Object retrieval response
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/test-HTTP-SPH"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     }   },   "HTTPSourceProtocolHandler": {     "name": "test-HTTP-SPH",     "mAdminState": "enabled",     "LocalAddress": "0.0.0.0",     "LocalPort": 8001,     "HTTPVersion": "HTTP/1.1",     "AllowedFeatures": {       "HTTP-1.0": "on",       "HTTP-1.1": "on",       "POST": "on",       "GET": "off",       "PUT": "on",       "HEAD": "off",       "OPTIONS": "off",       "TRACE": "off",       "DELETE": "off",       "CONNECT": "off",       "CustomMethods": "off",       "QueryString": "on",       "FragmentIdentifiers": "on",       "DotDot": "off",       "CmdExe": "off"     },     "PersistentConnections": "on",     "MaxPersistentConnectionsReuse": 0,     "AllowCompression": "off",     "AllowWebSocketUpgrade": "off",     "WebSocketIdleTimeout": 0,     "MaxURLLen": 16384,     "MaxTotalHdrLen": 128000,     "MaxHdrCount": 0,     "MaxNameHdrLen": 0,     "MaxValueHdrLen": 0,     "MaxQueryStringLen": 0   } }
Retrieve the property-level configuration

You can also retrieve the value of a specific property, instead of retrieving the object configuration in its entirety. To retrieve the value, construct a URI of the form: /mgmt/config/{domain}/{class_name}/{object_name}/{property_name}. In this URI, replace {domain} with the target domain, replace {class_name} with the object class, and replace {object_name} with the object instance. Also, replace {property_name} with the specific property name as it appears in the complete object configuration response in Listing 4.

The following request shows this URI. Here, the target domain is my-testing-domain, the class name is HTTPSourceProtocolHandler, the object name is test-HTTP-SPH, and the property name is LocalPort.

 GET https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH/LocalPort

The response to an object property retrieval request returns the value of the specific object property, as shown in Listing 5.

Object property retrieval response
 {   "_links": {     "self": { "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/       test-HTTP-SPH/LocalPort"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     }   },   "LocalPort": 8003 }
Modifying and deleting existing configurations

In this section, you modify and delete the configurations of objects that are on the appliance.

Modify the property-level configuration

To modify an existing property value, you overwrite the existing value with a payload that contains an updated value. To overwrite the value, retrieve the current property value. For examples that use the HTTPSourceProtocolHandler object, see the request and response in Retrieve the object-level configuration and in Retrieve the property-level configuration.

Next, examine the current property value to determine the change. After you identify the current change, modify the property payload that is received, as shown in Listing 5, to remove the _links{} stanza. Any properties that reference other configuration objects on the appliance must also remove the embedded href link. Listing 6 shows the result with the payload that contains an updated property value for LocalPort.

Modified property-level payload
 {   "LocalPort": 8012 }

After the modified payload is composed, overwrite the existing property value by sending an HTTP PUT request as shown in the following example. Updating the configuration on the property level allows for updating one property value per request. To update multiple property values with a single request, an update on the object level is required.

 PUT https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH/LocalPort 

After the target property is updated, a confirmation response is received as shown in Listing 7.

Object property modification response
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/                test-HTTP-SPH/LocalPort"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     }   },   "LocalPort": "property has been updated." }
Modify the object-level configuration

To modify an existing object configuration, overwrite the existing configuration with an updated payload. To overwrite the configuration, retrieve the current configuration of the object to be modified. An example of this request is shown in the object retrieval request for an HTTPSourceProtocolHandler object in Retrieve the object-level configuration.

Then, examine the current configuration, as shown in Listing 4, to determine the configuration changes. After you identify the current changes, modify the payload received in Listing 4 to remove the _links{} stanza and all properties that should remain unchanged. Remove the embedded href link for any properties that reference other configuration objects on the appliance as shown in Listing 8. In this listing, the payload contains the updated property values for mAdminState, LocalAddress, LocalPort, and HTTPVersion.

Modified object-level payload
 {   "HTTPSourceProtocolHandler": {     "name": "test-HTTP-SPH",     "mAdminState": "disabled",     "LocalAddress": "1.2.3.4",     "LocalPort": 8005,     "HTTPVersion": "HTTP/1.0"   } }

After the modified payload is composed, send an HTTP PUT request to overwrite the existing configuration:

 PUT https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH

Updating the configuration on the object level allows for updating multiple property values with a single request. You can update an individual property value on the property level instead, as explained in Modify the property-level configuration.

After the target object instance is updated, you receive a confirmation response as shown in Listing 9.

Object modification response
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/test-HTTP-SPH"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     },     "test-HTTP-SPH": "Configuration has been updated." }
Delete the object-level configuration

Configuration deletion is supported only on the object level. The object DELETE request expects to receive no request payload. If a payload is supplied, the following request is triggered, reporting a failure:

 DELETE https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH

After the deletion request is processed, you receive a confirmation response as shown in Listing 10.

Object deletion response
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/test-HTTP-SPH     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     }   },   "HTTPSourceProtocolHandler": {     "value": "Configuration has been deleted."   } } 

Deletion of individual object properties is not supported. To remove an optional property or to reset a required property to its default value, delete and re-create the entire configuration object. Omit the values of specific properties from the request payload. List properties, or properties that contain multiple entries of the same type, are handled differently. List properties allow updates and do not require the entire object configuration to be deleted first. For more information, go to Modifying the list properties.

Creating configurations

In this section, you create configuration objects on the appliance. You also compose valid request payloads and send requests to create objects.

Compose the valid request payload

To create an object configuration, create a valid payload that contains the new configuration. If you cannot create a valid payload by examining response payloads of the REST management interface for the same object class, as shown in the request in Retrieve the object-level configuration and in Listing 4, use another approach.

To begin constructing the payload, identify the structural description of the target object, that is, the object schema. You can retrieve this information from two sources: the metadata resource of the REST management interface and the appliance Service-Oriented Management Interface (SOMA) schema. You can choose which approach to use to construct a valid payload because you do not need to consult both sources.

To retrieve the object schema from the metadata resource of the REST management interface, access the metadata root URI of the REST management interface:

 GET https://dphost.com:5554/mgmt/metadata/

The response that is returned from the metadata root URI (see Listing 11) shows the options that are available for retrieving the configuration object schema within the object link: /mgmt/metadata/{domain}/{object_name}.

Metadata root URI response
 {   "_links": {     "self": {       "href": "/mgmt/metadata/"     },     "object": {       "href": "/mgmt/metadata/{domain}/{object_name}"     },     "property": {       "href": "/mgmt/metadata/{domain}/{object_name}/{property_name}"     },     "operation": {       "href": "/mgmt/metadata/{domain}/operations/{operation_name}"     }   } }

To retrieve object metadata, enter the following request. Here, for {domain}, substitute my-testing-domain, and for {object_name}, substitute the HTTPSourceProtocolHandler object class.

 GET https://dphost.com:5554/mgmt/metadata/my-testing-domain/HTTPSourceProtocolHandler

The information retrieved from the metadata resource is the same, regardless of the {domain} identifier. The {domain} identifier is required to ensure that the user has access permissions to the target domain.

The response returned from the metadata request can be large, depending on the target object class. The relevant information for constructing a request payload is in the properties element of the response, as shown in Listing 12 for the HTTPSourceProtocolHandler class. This list includes all target object properties and information about minimum and maximum values, required properties, and default values.

Metadata retrieval response
 {   "_links": {     "self": {       "href": "/mgmt/metadata/my-testing-domain/HTTPSourceProtocolHandler"     },     "doc": {       "href": "/mgmt/docs/metadata/HTTPSourceProtocolHandler"     }   },   "object": {     "name": "HTTPSourceProtocolHandler",     "uri": "protocol/http",     "cli-alias": "source-http",     ...     "properties": {       "property": [         {           "name": "mAdminState",           "type": {             "href": "/mgmt/types/default/dmAdminState"           },           "cli-alias": "admin-state",           "default": "enabled",           ...         },         {           "name": "UserSummary",           "type": {             "href": "/mgmt/types/default/dmString"           },           "cli-alias": "summary",           ...         },         {           "name": "LocalAddress",           "type": {             "href": "/mgmt/types/default/dmLocalIPHostAddress"           },           "required": "true",           "cli-alias": "local-address",           "default": "0.0.0.0",           ...         },         {           "name": "LocalPort",           "type": {             "href": "/mgmt/types/default/dmIPPort"           },           "required": "true",           "cli-alias": "port",           "minimum": 1,           "maximum": "0xFFFF",           "default": 80,           ...         },         {           "name": "HTTPVersion",           "type": {             "href": "/mgmt/types/default/dmHTTPVersion"           },           "cli-alias": "http-client-version",           "default": "HTTP/1.1",           ...         },         ...       ]     }   } }

To supplement the information that is retrieved from the metadata resource of the REST management interface, you can examine the SOMA schema of the target object. The SOMA schema for all configuration objects is available on the appliance from the default domain inside the store:///xml-mgmt.xsd file. Searching for an object class results in a schema similar to the one in Listing 13 for an HTTPSourceProtocolHandler class. By examining the minOccurs and maxOccurs attributes, you can easily observe the relevant information to construct a request payload for the REST management interface. For example, you can see which properties are required.

SOMA schema for a target object
 <xsd:complexType name="ConfigHTTPSourceProtocolHandler">   <xsd:complexContent>     <xsd:extension base="tns:ConfigSourceProtocolHandler">       <xsd:choice maxOccurs="unbounded">         <xsd:element name="UserSummary" minOccurs="0" maxOccurs="1">           <xsd:simpleType>             <xsd:union memberTypes="tns:dmString tns:dmEmptyElement" />           </xsd:simpleType>         </xsd:element>         <xsd:element name="LocalAddress" minOccurs="1" maxOccurs="1">           <xsd:simpleType>             <xsd:union memberTypes="tns:dmLocalIPHostAddress tns:dmEmptyElement" />           </xsd:simpleType>         </xsd:element>         <xsd:element name="LocalPort" minOccurs="1" maxOccurs="1">           <xsd:simpleType>             <xsd:union memberTypes="tns:dmIPPort tns:dmEmptyElement" />           </xsd:simpleType>         </xsd:element>         <xsd:element name="HTTPVersion" minOccurs="0" maxOccurs="1">           <xsd:simpleType>             <xsd:union memberTypes="tns:dmHTTPVersion tns:dmEmptyElement" />           </xsd:simpleType>         </xsd:element>          ...       </xsd:choice>       ...     </xsd:extension>   </xsd:complexContent> </xsd:complexType>

By relying on the metadata resource of the REST management interface and on the appliance SOMA schema, you can identify the properties that are required to create the target object. You can also identify the property names to use in the payload. By using this information, a proper JSON request payload is structured as shown in Listing 14.

Request payload structure
 {   "{object_class_name}": {     "name": "{object_name}",     "{property1_name}": "{property1_value}",     "{property2_name}": "{property2_value}",     "{property3_name}": "{property3_value}",     "{property4_name}": "{property4_value}"     ...   } }

When you substitute the {object_class_name}, {object_name}, and all required properties and their values, a valid JSON request payload for the REST management interface is created. Listing 15 shows a valid payload to create an HTTPSourceProtocolHandler object, where the property values are set for mAdminState, LocalAddress, LocalPort, and HTTPVersion.

Valid request payload
 {   "HTTPSourceProtocolHandler": {     "name": "test-HTTP-SPH",     "mAdminState": "enabled",     "LocalAddress": "0.0.0.0",     "LocalPort": 8001,     "HTTPVersion": "HTTP/1.1"   } }
Compose the valid request URI

You can choose from two approaches to create a configuration object. Both approaches achieve the same result, but target a different URI. The first approach uses an HTTP POST request, and the second uses an HTTP PUT request. Use the POST request to create objects because a POST request results in failure if an object with the same name exists in the target domain. This approach prevents you from accidentally overwriting an existing object configuration. However, you can create an object configuration by using a PUT request. Issuing a PUT request on an existing object configuration overwrites the configuration with the values in the request payload.

To create a configuration object with a POST request, construct a URI as follows and use an appropriate substitute for {domain_name} and {class_name}:

 POST https://dphost.com:5554/mgmt/config/{domain_name}/{class_name}

To create a configuration object with a PUT request, construct a URI as shown in the following request. Use an appropriate substitute for {domain_name}, {class_name}, and {object_name}. The {object_name} in the URI and the request payload must match. Otherwise, an error results.

 PUT https://dphost.com:5554/mgmt/config/{domain_name}/{class_name}/{object_name}
Send a request and interpret the response

After you construct the request payload and the target URI, create an object configuration by sending a POST request or PUT request. The following example shows how to create an HTTPSourceProtocolHandler object with a POST request:

 POST https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler

The following example shows how to create the same object with a PUT request:

 PUT https://dphost.com:5554/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler/ test-HTTP-SPH 

For both request types, the {domain_name}, {class_name}, and {object_name} values were substituted with the same values shown in Compose the valid request URI.

Both the POST and PUT requests return the same response after the object is successfully created, as shown in Listing 16.

Object creation response
 {   "result": "",   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"     }   },   "test-HTTP-SPH": "Configuration has been created." }

The next POST and PUT requests that are sent to the same target URI generate different responses. Subsequent POST requests to existing configuration objects result in an error, as shown in Listing 17.

Response to the next POST request
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/HTTPSourceProtocolHandler"     }   },   "error": "Resource already exists." }

The next PUT requests to an existing configuration object result in overwriting the object with the information in the incoming payload, as shown in Listing 18.

Response to the next PUT request
 {   "_links": {     "self": {       "href": "/mgmt/config/my-testing-domain/ 		    HTTPSourceProtocolHandler/test-HTTP-SPH"     },     "doc": {       "href": "/mgmt/docs/config/HTTPSourceProtocolHandler"   },   "test-HTTP-SPH": "Configuration has been updated." }

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SS9H2Y","label":"IBM DataPower Gateway"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
08 June 2021

UID

ibm11109685