Skip to content

Commit

Permalink
Merge pull request #48 from adobe/eventsSDK-update
Browse files Browse the repository at this point in the history
Update aio-lib-events version and use registration V2 API
  • Loading branch information
sangeetha5491 authored Apr 12, 2023
2 parents 685141e + aac2f98 commit 60a72ea
Show file tree
Hide file tree
Showing 19 changed files with 372 additions and 256 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@adobe/aio-lib-console": "^4.0.0",
"@adobe/aio-lib-core-config": "^3.0.0",
"@adobe/aio-lib-core-logging": "^2.0.0",
"@adobe/aio-lib-events": "^2.0.1",
"@adobe/aio-lib-events": "^3.0.0",
"@adobe/aio-lib-ims": "^6.0.1",
"@oclif/core": "^1.5.2",
"js-yaml": "^3.13.1"
Expand Down
6 changes: 3 additions & 3 deletions src/commands/event/registration/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class CreateCommand extends BaseCommand {

aioLogger.debug(`create event registration with body ${body}`)
cli.action.start('Creating new Event Registration')
const registration = await this.eventClient.createWebhookRegistration(this.conf.org.id, this.conf.integration.id, body)
const registration = await this.eventClient.createRegistration(this.conf.org.id, this.conf.project.id, this.conf.workspace.id, body)
cli.action.stop()
aioLogger.debug(`create successful, id: ${registration.id}, name: ${registration.name}`)
aioLogger.debug(`create successful, id: ${registration.registration_id}, name: ${registration.name}`)

if (flags.json) {
this.printJson(registration)
Expand Down Expand Up @@ -90,7 +90,7 @@ The JSON should follow the following format:
{
"name": "<event registration name>",
"description": "<event registration description>",
"delivery_type": "WEBHOOK|WEBHOOK_BATCH|JOURNAL",
"delivery_type": "webhook|webhook_batch|journal",
"webhook_url": "<webhook URL responding to challenge>",
"events_of_interest": [{
"provider_id": "<event provider id>",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/event/registration/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class DeleteCommand extends BaseCommand {
}])
if (response.delete) {
cli.action.start('Deleting Registration')
await this.eventClient.deleteWebhookRegistration(this.conf.org.id,
this.conf.integration.id, args.registrationId)
await this.eventClient.deleteRegistration(this.conf.org.id,
this.conf.project.id, this.conf.workspace.id, args.registrationId)
cli.action.stop()
this.log('Registration ' + args.registrationId +
' has been deleted successfully')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/event/registration/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GetCommand extends BaseCommand {

aioLogger.debug(`get registration: ${args.registrationId}`)
cli.action.start(`Retrieving Registration with id ${args.registrationId}`)
const registration = await this.eventClient.getWebhookRegistration(this.conf.org.id, this.conf.integration.id, args.registrationId)
const registration = await this.eventClient.getRegistration(this.conf.org.id, this.conf.project.id, this.conf.workspace.id, args.registrationId)
cli.action.stop()
aioLogger.debug(`get successful, name: ${registration.name}`)

Expand Down
15 changes: 7 additions & 8 deletions src/commands/event/registration/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ class ListCommand extends BaseCommand {

aioLogger.debug(`list registrations in the workspace ${this.conf.workspace.id}`)
cli.action.start(`Retrieving Registrations for the Workspace ${this.conf.workspace.id}`)
const registrations = await this.eventClient.getAllWebhookRegistrations(this.conf.org.id, this.conf.integration.id)
const registrationHalModel = await this.eventClient.getAllRegistrationsForWorkspace(this.conf.org.id, this.conf.project.id, this.conf.workspace.id)
cli.action.stop()
aioLogger.debug(`list successful, got ${registrations.length} elements with ids: ${registrations.map(r => r.id)}`)

aioLogger.debug(`list successful, got ${registrationHalModel._embedded.registrations.length} elements with ids: ${registrationHalModel._embedded.registrations.map(r => r.id)}`)
if (flags.json) {
this.printJson(registrations)
this.printJson(registrationHalModel)
} else if (flags.yml) {
this.printYaml(registrations)
this.printYaml(registrationHalModel)
} else {
// print formatted result
cli.table(registrations, {
cli.table(registrationHalModel._embedded.registrations, {
registration_id: { minWidth: 38, header: 'ID' },
name: { minWidth: 25, header: 'NAME' },
integration_status: { minWidth: 10, header: 'INTEGRATION_STATUS' },
enabled: { minWidth: 10, header: 'ENABLED' },
delivery_type: { minWidth: 10, header: 'DELIVERY_TYPE' },
status: { minWidth: 10, header: 'STATUS' }
webhook_status: { minWidth: 10, header: 'WEBHOOK_STATUS' }
}, {
printLine: this.log.bind(this)
})
Expand Down
39 changes: 23 additions & 16 deletions test/__fixtures__/registration/create.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"_links": {
"rel:events": {
"href": "https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1"
},
"rel:trace": {
"href": "https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1"
},
"self": {
"href": "https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1"
}
},
"id": 11111,
"name": "bowling 1",
"description": "let me know when we can go play bowling!",
"client_id": "1234654902189324798",
"parent_client_id": "9088675987031198237",
"webhook_url": "https://send-me-a-bowling-event.com/right-now",
"status": "VERIFIED",
"type": "APP",
"integration_status": "ENABLED",
"webhook_status": "verified",
"enabled": "true",
"events_of_interest": [
{
"event_code": "com.adobe.bowling",
"provider_id": "IDP1",
"provider": "3rd_party_custom_events_ORG@AdobeOrg_IDP01",
"provider_label": "bowling",
"provider_description": "let's play bowling",
"event_delivery_format": "cloud_events_v1"
}
{
"event_code": "com.adobe.bowling",
"provider_id": "IDP1",
"provider": "3rd_party_custom_events_ORG@AdobeOrg_IDP01",
"provider_label": "bowling",
"provider_description": "let's play bowling",
"event_delivery_format": "cloud_events_v1"
}
],
"registration_id": "REGID1",
"delivery_type": "WEBHOOK",
"events_url": "https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1",
"delivery_type": "webhook",
"created_date": "2020-06-12T13:53:59.363Z",
"updated_date": "2020-06-12T13:53:59.363Z",
"runtime_action": ""
"updated_date": "2020-06-12T13:53:59.363Z"
}
23 changes: 15 additions & 8 deletions test/__fixtures__/registration/create.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"_links": {
"rel:events": {
"href": "https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1"
},
"rel:trace": {
"href": "https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1"
},
"self": {
"href": "https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1"
}
},
"id": 11111,
"name": "bowling 1",
"description": "let me know when we can go play bowling!",
"client_id": "1234654902189324798",
"parent_client_id": "9088675987031198237",
"webhook_url": "https://send-me-a-bowling-event.com/right-now",
"status": "VERIFIED",
"type": "APP",
"integration_status": "ENABLED",
"webhook_status": "verified",
"enabled": "true",
"events_of_interest": [
{
"event_code": "com.adobe.bowling",
Expand All @@ -19,9 +28,7 @@
}
],
"registration_id": "REGID1",
"delivery_type": "WEBHOOK",
"events_url": "https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1",
"delivery_type": "webhook",
"created_date": "2020-06-12T13:53:59.363Z",
"updated_date": "2020-06-12T13:53:59.363Z",
"runtime_action": ""
"updated_date": "2020-06-12T13:53:59.363Z"
}
21 changes: 13 additions & 8 deletions test/__fixtures__/registration/create.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
_links:
'rel:events':
href: >-
https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1
'rel:trace':
href: >-
https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1
self:
href: >-
https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1
id: 11111
name: bowling 1
description: let me know when we can go play bowling!
client_id: '1234654902189324798'
parent_client_id: '9088675987031198237'
webhook_url: 'https://send-me-a-bowling-event.com/right-now'
status: VERIFIED
type: APP
integration_status: ENABLED
webhook_status: verified
enabled: 'true'
events_of_interest:
- event_code: com.adobe.bowling
provider_id: IDP1
Expand All @@ -15,10 +23,7 @@ events_of_interest:
provider_description: let's play bowling
event_delivery_format: cloud_events_v1
registration_id: REGID1
delivery_type: WEBHOOK
events_url: >-
https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1
delivery_type: webhook
created_date: '2020-06-12T13:53:59.363Z'
updated_date: '2020-06-12T13:53:59.363Z'
runtime_action: ''

57 changes: 32 additions & 25 deletions test/__fixtures__/registration/get.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"id": 11111,
"name": "bowling 1",
"description": "let me know when we can go play bowling!",
"client_id": "1234654902189324798",
"parent_client_id": "9088675987031198237",
"webhook_url": "https://send-me-a-bowling-event.com/right-now",
"status": "VERIFIED",
"type": "APP",
"integration_status": "ENABLED",
"events_of_interest": [
{
"event_code": "com.adobe.bowling",
"provider_id": "IDP1",
"provider": "3rd_party_custom_events_ORG@AdobeOrg_IDP01",
"provider_label": "bowling",
"provider_description": "let's play bowling",
"event_delivery_format": "cloud_events_v1"
}
],
"registration_id": "REGID1",
"delivery_type": "WEBHOOK",
"events_url": "https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1",
"created_date": "2020-06-12T13:53:59.363Z",
"updated_date": "2020-06-12T13:53:59.363Z",
"runtime_action": ""
"_links": {
"rel:events": {
"href": "https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1"
},
"rel:trace": {
"href": "https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1"
},
"self": {
"href": "https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1"
}
},
"id": 11111,
"name": "bowling 1",
"description": "let me know when we can go play bowling!",
"client_id": "1234654902189324798",
"webhook_url": "https://send-me-a-bowling-event.com/right-now",
"webhook_status": "verified",
"enabled": "true",
"events_of_interest": [
{
"event_code": "com.adobe.bowling",
"provider_id": "IDP1",
"provider": "3rd_party_custom_events_ORG@AdobeOrg_IDP01",
"provider_label": "bowling",
"provider_description": "let's play bowling",
"event_delivery_format": "cloud_events_v1"
}
],
"registration_id": "REGID1",
"delivery_type": "webhook",
"created_date": "2020-06-12T13:53:59.363Z",
"updated_date": "2020-06-12T13:53:59.363Z"
}
23 changes: 15 additions & 8 deletions test/__fixtures__/registration/get.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"_links": {
"rel:events": {
"href": "https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1"
},
"rel:trace": {
"href": "https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1"
},
"self": {
"href": "https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1"
}
},
"id": 11111,
"name": "bowling 1",
"description": "let me know when we can go play bowling!",
"client_id": "1234654902189324798",
"parent_client_id": "9088675987031198237",
"webhook_url": "https://send-me-a-bowling-event.com/right-now",
"status": "VERIFIED",
"type": "APP",
"integration_status": "ENABLED",
"webhook_status": "verified",
"enabled": "true",
"events_of_interest": [
{
"event_code": "com.adobe.bowling",
Expand All @@ -19,9 +28,7 @@
}
],
"registration_id": "REGID1",
"delivery_type": "WEBHOOK",
"events_url": "https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1",
"delivery_type": "webhook",
"created_date": "2020-06-12T13:53:59.363Z",
"updated_date": "2020-06-12T13:53:59.363Z",
"runtime_action": ""
"updated_date": "2020-06-12T13:53:59.363Z"
}
21 changes: 13 additions & 8 deletions test/__fixtures__/registration/get.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
_links:
'rel:events':
href: >-
https://events-va6.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/REGID1
'rel:trace':
href: >-
https://eventtraces-va6.adobe.io/traces/consumerOrgId/projectId/workspaceId/registration/REGID1
self:
href: >-
https://api.adobe.io/events/consumerOrgId/projectId/workspaceId/registrations/REGID1
id: 11111
name: bowling 1
description: let me know when we can go play bowling!
client_id: '1234654902189324798'
parent_client_id: '9088675987031198237'
webhook_url: 'https://send-me-a-bowling-event.com/right-now'
status: VERIFIED
type: APP
integration_status: ENABLED
webhook_status: verified
enabled: 'true'
events_of_interest:
- event_code: com.adobe.bowling
provider_id: IDP1
Expand All @@ -15,10 +23,7 @@ events_of_interest:
provider_description: let's play bowling
event_delivery_format: cloud_events_v1
registration_id: REGID1
delivery_type: WEBHOOK
events_url: >-
https://events-va6.adobe.io/events/organizations/99999/integrations/888888/REGID1
delivery_type: webhook
created_date: '2020-06-12T13:53:59.363Z'
updated_date: '2020-06-12T13:53:59.363Z'
runtime_action: ''

Loading

0 comments on commit 60a72ea

Please sign in to comment.