API Integration Reference

REST API Endpoints

Configuration commands interact with the following Detect REST API endpoints:

CLI Command REST Endpoint HTTP Method Authentication
get-all-datasource-names-for-logged-in-user /api/unicadetect/v1/configuration/datasources GET OAuth2 Bearer Token
get-all-kafka-cluster-names /api/unicadetect/v1/configuration/kafka-clusters GET OAuth2 Bearer Token

Response Models

Datasource Names Response

// DTOs involved
public class ListOfNamesDto {
    private List<String> names;  // List of datasource names
}

Sample JSON Response:

{
  "names": [
    "UnicaDetectDS",
    "MARKETING_ANALYTICS_DS",
    "CRM_DATA_DS"
  ]
}

Kafka Clusters Response

// DTOs involved
public class KafkaConfigurations {
    private List<KafkaClusterConfigDto> clusters;
}

public class KafkaClusterConfigDto {
    private String name;                    // Cluster name
    private String bootstrapServers;        // Broker addresses
    private Map<String, Object> properties; // Additional Kafka properties
}

Sample JSON Response:

{
  "clusters": [
    {
      "name": "prod-kafka-cluster",
      "bootstrapServers": "kafka1.prod.com:9092,kafka2.prod.com:9092",
      "properties": {
        "security.protocol": "SASL_SSL",
        "sasl.mechanism": "PLAIN",
        "compression.type": "gzip"
      }
    }
  ]
}
Note: The CLI displays only the name field from each cluster. To view complete cluster configurations including bootstrap servers and properties, use the Detect REST API directly or Platform UI.

Direct API Access (Alternative to CLI)

If you prefer to access the REST API directly:

Using curl with OAuth2

# Step 1: Obtain OAuth2 access token
TOKEN=$(curl -s -X POST http://default.hcl.in:5001/unica/oauth/token \
  -d "client_id=333842" \
  -d "client_secret=c3xzOPhy5KeYubl" \
  -d "grant_type=client_credentials" | jq -r '.access_token')

# Step 2: Call Detect API with token
curl -H "Authorization: Bearer $TOKEN" \
  http://default.hcl.in:8080/detect/api/unicadetect/v1/configuration/datasources | jq .

# Step 3: Get Kafka clusters
curl -H "Authorization: Bearer $TOKEN" \
  http://default.hcl.in:8080/detect/api/unicadetect/v1/configuration/kafka-clusters | jq .

Using Postman

  1. Create request: GET http://default.hcl.in:8080/detect/api/unicadetect/v1/configuration/datasources
  2. Add headers:
    m_tokenId: <oauth2-token>
       api_auth_mode: manager
       m_user_name: asm_admin
  3. Or use OAuth2 in Postman:
    • Authorization Type: OAuth 2.0
    • Grant Type: Client Credentials
    • Access Token URL: http://default.hcl.in:5001/unica/oauth/token
    • Client ID: 333842
    • Client Secret: c3xzOPhy5KeYubl