Skip to content

About

Extension to FINOS CDM for https plugin

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

# CDM Plugin: HTTPS A CDM plugin that provides HTTP/HTTPS integration as Rune-callable functions. ## Overview This plugin follows the standard CDM plugin architecture: ``` ┌─────────────────────────────────────┐ │ .rosetta files (Rune namespace) │ ← cdm.plugin.https.* │ Enums, Types, Functions │ ├─────────────────────────────────────┤ │ Code Generator (automatic) │ ← produces abstract Java classes ├─────────────────────────────────────┤ │ Bridge classes │ ← Rune abstract → SPI (written once) ├─────────────────────────────────────┤ │ SPI Implementation │ ← HttpsCdmClientImpl (java.net.http) │ Discovered via ServiceLoader │ └─────────────────────────────────────┘ ``` ## Rune Files All three files share the namespace `cdm.plugin.https`: | File | Contents | |------------------------------------|---------------------------------------------| | `plugin-https-enum.rosetta` | HttpMethodEnum, AuthTypeEnum, HttpStatusCategoryEnum | | `plugin-https-type.rosetta` | HttpRequest, HttpResponse, HttpHeader, HttpAuthConfig | | `plugin-https-func.rosetta` | HttpPost, HttpGet, HttpSend | ## Usage in Rune Rune authors call these functions exactly like built-in CDM functions: ``` namespace cdm.myworkflow import cdm.plugin.https.* func ReportTradeToRegulator: inputs: tradeJson string (1..1) regulatorUrl string (1..1) output: httpsResponse HttpResponse (1..1) set httpsResponse: HttpPost(regulatorUrl, tradeJson, empty, empty) ``` ## Usage in Java ### With Guice (recommended) ```java Injector injector = Guice.createInjector( new CdmRuntimeModule(), new HttpsPluginModule(Map.of( "auth.type", "bearer", "auth.token", "your-token-here" )) ); // The Rune-generated HttpPost function is now backed by the plugin HttpPost httpPost = injector.getInstance(HttpPost.class); HttpResponse response = httpPost.evaluate(url, body, headers, auth); ``` ### Direct SPI usage (without Guice) ```java CdmHttpClient client = ServiceLoader.load(CdmHttpClient.class) .findFirst().orElseThrow(); client.initialize(Map.of( "connect.timeout.seconds", "10", "auth.type", "apikey", "auth.key", "your-api-key", "auth.header", "X-API-Key" )); PluginResult result = client.post( "https://api.counterparty.com/v1/trades", cdmTradeJson, Map.of("X-Request-Id", UUID.randomUUID().toString()) ); ``` ## Configuration | Key | Default | Description | |----------------------------|-------------|-------------------------------------| | `connect.timeout.seconds` | `30` | TCP connection timeout | | `request.timeout.seconds` | `60` | Per-request timeout | | `auth.type` | `none` | none / bearer / basic / apikey | | `auth.token` | — | Bearer token or API key value | | `auth.username` | — | Basic auth username | | `auth.password` | — | Basic auth password | | `auth.header` | `X-API-Key` | Custom header name for API key auth | ## Project Structure ``` cdm-plugin-https/ ├── pom.xml ├── src/main/rosetta/cdm/plugin/https/ │ ├── plugin-https-enum.rosetta │ ├── plugin-https-type.rosetta │ └── plugin-https-func.rosetta ├── src/main/java/ │ ├── cdm/plugin/api/ ← shared SPI interfaces │ │ ├── CdmPlugin.java │ │ ├── PluginResult.java │ │ └── http/CdmHttpClient.java │ └── cdm/plugin/https/ │ ├── bridge/ ← Rune abstract → SPI │ │ ├── HttpPostBridge.java │ │ └── HttpGetBridge.java │ ├── impl/ ← SPI implementation │ │ └── HttpsCdmClientImpl.java │ └── module/ ← Guice wiring │ └── HttpsPluginModule.java ├── src/main/resources/META-INF/services/ │ └── cdm.plugin.api.http.CdmHttpClient └── src/test/java/cdm/plugin/https/ └── HttpsPluginTest.java ``` ## What Ships in the JAR ``` cdm-plugin-https-1.0.0.jar ├── cdm/plugin/https/**/*.class ← compiled Java (all layers) ├── META-INF/services/ ← SPI registration │ └── cdm.plugin.api.http.CdmHttpClient └── rosetta/cdm/plugin/https/ ← .rosetta source files ├── plugin-https-enum.rosetta (importable by other Rune projects) ├── plugin-https-type.rosetta └── plugin-https-func.rosetta ``` ## Adapting This Template for Other Plugins This project serves as the reference template. To create a new plugin: 1. Copy this project structure 2. Replace `https` with your plugin name in namespaces and paths 3. Define your enums, types, and functions in .rosetta files 4. Implement the appropriate SPI interface (CdmAnalyticsProvider, CdmBlockchainProvider, etc.) 5. Write bridge classes that connect generated abstracts to SPI 6. Register your SPI implementation in META-INF/services 7. Create a Guice module ## Dependencies - **JDK 17+** (uses java.net.http, text blocks, records) - **CDM Java 6.0.0+** (for CDM types and Rune runtime) - **Google Guice 7.0** (CDM's DI framework) - **No external HTTP libraries** (uses JDK built-in java.net.http) # cdm-https-plugin

About

Extension to FINOS CDM for https plugin

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages