@solace-community/eventportal
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -54,3 +54,3 @@ const EventPortal = require('../src/index') | ||
let addressLevels = [ | ||
{name: "tamimi", addressLevelType: "literal"}, | ||
{name: "level1", addressLevelType: "literal"}, | ||
{name: "level2", addressLevelType: "variable"}, | ||
@@ -106,28 +106,18 @@ {name: "level3", addressLevelType: "literal"}, | ||
// const schemaContent = require("./schemaSample.json") | ||
// DOMAIN_NAME = process.argv[2] || process.env.SOLACE_APPLICATION_DOMAIN | ||
// if (!DOMAIN_NAME) throw new Error("Define Application Domain Name") | ||
// async function createEDA(){ | ||
// try { | ||
// // 1. Create Application Domain | ||
// 1. Create Application Domain | ||
// // 2. Create a Schema Object | ||
// 2. Create a Schema Object | ||
// // 3. Create a Schema version. If exist : THROW ERROR | ||
// 3. Create a Schema version. | ||
// // 4. Create an Event object | ||
// 4. Create an Event object | ||
// // 5. Create an Event version and associate a schema and topic to it. If exist: THROW ERROR | ||
// 5. Create an Event version and associate a schema and topic to it. | ||
// // Topic definitions | ||
// // addressLevel = [{"name": "level1", "addressLevelType": "literal"}] | ||
// // 6. Create Application in Application domain | ||
// 6. Create Application in Application domain | ||
// // 7. Create a new Application Version with details. If exists: THROW ERROR | ||
// 7. Create a new Application Version with details. | ||
// console.log("DONE") | ||
// } catch(e) { | ||
@@ -134,0 +124,0 @@ // throw new Error(e) |
{ | ||
"name": "@solace-community/eventportal", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "This is a wrapper to Solace PubSub+ Event Portal REST API", | ||
@@ -13,6 +13,4 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"query-string": "^7.1.1", | ||
"querystring": "^0.2.1" | ||
"axios": "^0.27.2" | ||
} | ||
} |
@@ -249,5 +249,13 @@ # Solace Pubsub+ Event Portal REST API Wrapper | ||
<details> | ||
<summary>getApplicationState(applicationName, applicationVersion)</summary> | ||
Returns the Application State given the application name and application version. The current states are | ||
- DRAFT | ||
- RELEASED | ||
- DEPRECATED | ||
- RETIRED | ||
</details> | ||
## To-Do | ||
- [x] Document methods in README | ||
- [ ] Add Jest unit tests |
@@ -42,3 +42,31 @@ const axios = require('axios') | ||
/** | ||
* Gets the state of the Application given the name and the version number | ||
* | ||
* @param {String} applicationName - Application name | ||
* @param {String} applicationVersion - Application version | ||
*/ | ||
async getApplicationState(applicationName, applicationVersion){ | ||
try { | ||
let applicationID = await this.getApplicationObjectID(applicationName) | ||
const response = await this.api(this.token, "GET", `applications/${applicationID}/versions?version=${applicationVersion}`) | ||
let stateID = response.data.length == 0 ? null : response.data[0].stateId | ||
switch (stateID) { | ||
case "1": | ||
return "DRAFT" | ||
case "2": | ||
return "RELEASED" | ||
case "3": | ||
return "DEPRECATED" | ||
case "4": | ||
return "RETIRED" | ||
default: | ||
return null | ||
} | ||
} catch (error) { | ||
throw new Error(error) | ||
} | ||
} | ||
/** | ||
@@ -73,5 +101,6 @@ * Create application object. If Application object name already exists, return matching Application object ID | ||
try { | ||
const response = await this.api(this.token, 'GET', `applications/${applicationID}`, null) | ||
const response = await this.api(this.token, 'GET', `applications/${applicationID}`) | ||
return response.data.name | ||
} catch (error) { | ||
throw new Error(error) | ||
} | ||
@@ -83,3 +112,3 @@ } | ||
console.log(`Fetching application ID for application: ${applicationName}`) | ||
const response = await this.api(this.token, 'GET', `applications?name=${applicationName}`, null) | ||
const response = await this.api(this.token, 'GET', `applications?name=${applicationName}`) | ||
return response.data[0].id | ||
@@ -130,3 +159,3 @@ } catch (error) { | ||
try { | ||
const response = await this.api(this.token, 'GET', `events/${eventID}`, null) | ||
const response = await this.api(this.token, 'GET', `events/${eventID}`) | ||
return response.data.name | ||
@@ -140,3 +169,3 @@ } catch (error) { | ||
console.log(`Fetching Event ID for Event: ${eventName}`) | ||
const response = await this.api(this.token, 'GET', `events?name=${eventName}`, null) | ||
const response = await this.api(this.token, 'GET', `events?name=${eventName}`) | ||
return response.data[0].id | ||
@@ -205,3 +234,3 @@ } catch (error) { | ||
try { | ||
const response = await this.api(this.token, 'GET', `schemas/${schemaID}`, null) | ||
const response = await this.api(this.token, 'GET', `schemas/${schemaID}`) | ||
return response.data.name | ||
@@ -221,3 +250,3 @@ } catch (error) { | ||
console.log(`Fetching Schema ID for Schema: ${schemaName}`) | ||
const response = await this.api(this.token, 'GET', `schemas?name=${schemaName}`, null) | ||
const response = await this.api(this.token, 'GET', `schemas?name=${schemaName}`) | ||
return response.data[0].id | ||
@@ -268,3 +297,3 @@ } catch (error) { | ||
console.log(`Fetching Domain ID for Application Domain: ${domainName}`) | ||
const response = await this.api(this.token, 'GET', `applicationDomains?name=${domainName}`, null) | ||
const response = await this.api(this.token, 'GET', `applicationDomains?name=${domainName}`) | ||
return response.data[0].id | ||
@@ -282,9 +311,12 @@ } catch (error) { | ||
async getApplicationDomainName(domainID) { | ||
try { | ||
console.log(`Fetching Domain Name for ApplicationDomainID: ${domainID}`) | ||
const response = await this.api(this.token, 'GET', `applicationDomains?ids=${domainID}`, null) | ||
return response.data[0].name | ||
} catch (error) { | ||
throw new Error(error) | ||
if(domainID){ | ||
try { | ||
console.log(`Fetching Domain Name for ApplicationDomainID: ${domainID}`) | ||
const response = await this.api(this.token, 'GET', `applicationDomains?ids=${domainID}`) | ||
return response.data[0].name | ||
} catch (error) { | ||
throw new Error(error) | ||
} | ||
} | ||
return null | ||
} | ||
@@ -291,0 +323,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25514
1
6
534
261
5
- Removedquery-string@^7.1.1
- Removedquerystring@^0.2.1
- Removeddecode-uri-component@0.2.2(transitive)
- Removedfilter-obj@1.1.0(transitive)
- Removedquery-string@7.1.3(transitive)
- Removedquerystring@0.2.1(transitive)
- Removedsplit-on-first@1.1.0(transitive)
- Removedstrict-uri-encode@2.0.0(transitive)