Skip to content

Commit

Permalink
MG-73 - Add domain ID to API endpoints (#74)
Browse files Browse the repository at this point in the history
* add domain id to things

Signed-off-by: ianmuchyri <[email protected]>

* add domain id to channels

Signed-off-by: ianmuchyri <[email protected]>

* add domain id to groups

Signed-off-by: ianmuchyri <[email protected]>

* fix invitations and bootstraps

Signed-off-by: ianmuchyri <[email protected]>

* fix certs

Signed-off-by: ianmuchyri <[email protected]>

* fix tests

Signed-off-by: ianmuchyri <[email protected]>

* fix examples

Signed-off-by: ianmuchyri <[email protected]>

* add changeset

Signed-off-by: ianmuchyri <[email protected]>

* remove domains endpoint

Signed-off-by: ianmuchyri <[email protected]>

* remove unnecessary comment

Signed-off-by: ianmuchyri <[email protected]>

* add changeset

Signed-off-by: ianmuchyri <[email protected]>

* address comments

Signed-off-by: ianmuchyri <[email protected]>

* fix comment for enable

Signed-off-by: ianmuchyri <[email protected]>

* get domain id from invitation

Signed-off-by: ianmuchyri <[email protected]>

* update tests and example

Signed-off-by: ianmuchyri <[email protected]>

---------

Signed-off-by: ianmuchyri <[email protected]>
  • Loading branch information
ianmuchyri authored Oct 25, 2024
1 parent 7197ff4 commit c4f60b9
Show file tree
Hide file tree
Showing 22 changed files with 723 additions and 497 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-coats-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@absmach/magistrala-sdk": patch
---

remove domains endpoints
5 changes: 5 additions & 0 deletions .changeset/wicked-geckos-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@absmach/magistrala-sdk": patch
---

update things, channels, groups, bootstrap, certs api endpoints to have domain id
9 changes: 9 additions & 0 deletions examples/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const mySdk = new SDK({
})

const token = '<token>'
const domainId = '<domainId>'

mySdk.bootstrap.AddBootstrap(
{
Expand All @@ -15,6 +16,7 @@ mySdk.bootstrap.AddBootstrap(
thing_id: '<thingId>',
name: '<bootstrapName>'
},
domainId,
token
)
.then((response: any) => {
Expand All @@ -31,6 +33,7 @@ mySdk.bootstrap.Whitelist(
thing_id: '<thingId>',
name: '<bootstrapName>'
},
domainId,
token)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -44,6 +47,7 @@ mySdk.bootstrap.UpdateBootstrap(
name: 'Bootstrap1',
thing_id: '<thingId>'
},
domainId,
token)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -54,6 +58,7 @@ mySdk.bootstrap.UpdateBootstrap(

mySdk.bootstrap.ViewBootstrap(
'<thingId>',
domainId,
token)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -69,6 +74,7 @@ mySdk.bootstrap.UpdateBootstrapCerts(
client_key: '<clientKey>',
ca_cert: '<caCert>'
},
domainId,
token
)
.then((response: any) => {
Expand All @@ -80,6 +86,7 @@ mySdk.bootstrap.UpdateBootstrapCerts(

mySdk.bootstrap.RemoveBootstrap(
'<thingId>',
domainId,
token)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -101,6 +108,7 @@ mySdk.bootstrap.Bootstrap(

mySdk.bootstrap.Bootstraps(
{ offset: 0, limit: 10 },
domainId,
token
)
.then((response: any) => {
Expand All @@ -112,6 +120,7 @@ mySdk.bootstrap.Bootstraps(

mySdk.bootstrap.UpdateBootstrapConnection(
'<thingId>',
domainId,
['<channelId>', '<channelId2>'],
token)
.then((response: any) => {
Expand Down
5 changes: 5 additions & 0 deletions examples/certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ const mySdk = new SDK({
})

const token = '<token>'
const domainId = '<domainId>'

mySdk.certs
.IssueCert(
'<thingID>',
'<valid>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -24,6 +26,7 @@ mySdk.certs
mySdk.certs
.ViewCertByThing(
'<thingID>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -36,6 +39,7 @@ mySdk.certs
mySdk.certs
.ViewCert(
'<certID>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -48,6 +52,7 @@ mySdk.certs
mySdk.certs
.RevokeCert(
'<thingID>',
domainId,
token
)
.then((response: any) => {
Expand Down
28 changes: 21 additions & 7 deletions examples/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ const mySdk = new SDK({
// Channels.ts examples.

const token = '<token>'
const domainId = '<domainId>'

mySdk.channels
.CreateChannel(
{ name: '<channelName>' }, token)
{ name: '<channelName>' }, domainId, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -23,7 +24,7 @@ mySdk.channels
})

mySdk.channels
.Channel('<channelID>', token)
.Channel('<channelID>', domainId, token)
.then((response: any) => {
console.log(response)
})
Expand All @@ -32,7 +33,7 @@ mySdk.channels
})

mySdk.channels
.Channels({ offset: 0, limit: 10 }, token)
.Channels({ offset: 0, limit: 10 }, domainId, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -43,6 +44,7 @@ mySdk.channels
mySdk.channels
.UpdateChannel(
{ id: '<channelId>', name: '<channelName>' },
domainId,
token
)
.then((response: any) => {
Expand All @@ -53,7 +55,7 @@ mySdk.channels
})

mySdk.channels
.Disable({ id: '<channelId>' }, token)
.Disable('<channelId>', domainId, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -62,7 +64,7 @@ mySdk.channels
})

mySdk.channels
.Enable({ id: '<channelId>' }, token)
.Enable('<channelId>', domainId, token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -74,6 +76,7 @@ mySdk.channels
.ChannelsByThing(
'<thingId>',
{ offset: 0, limit: 5 },
domainId,
token
)
.then((response: any) => {
Expand All @@ -87,6 +90,7 @@ mySdk.channels
.ConnectThing(
'<thingId>',
'<channelId>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -100,6 +104,7 @@ mySdk.channels
.DisconnectThing(
'<thingId>',
'<channelId>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -113,6 +118,7 @@ mySdk.channels
.Connect(
'<thingId>',
'<channelId>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -126,6 +132,7 @@ mySdk.channels
.Disconnect(
'<thingId>',
'<channelId>',
domainId,
token
)
.then((response: any) => {
Expand All @@ -139,6 +146,7 @@ mySdk.channels
.ListChannelUsers(
'<channelId>',
{ offset: 0, limit: 5 },
domainId,
token
)
.then((response: any) => {
Expand All @@ -152,6 +160,7 @@ mySdk.channels
.ListChannelUserGroups(
'<channelId>',
{ offset: 0, limit: 5 },
domainId,
token
)
.then((response: any) => {
Expand All @@ -162,7 +171,7 @@ mySdk.channels
})

mySdk.channels
.ChannelPermissions('<channelId>', token)
.ChannelPermissions('<channelId>', domainId, token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -177,6 +186,7 @@ mySdk.channels
'<userId1>', '<userId2>'
],
'administrator',
domainId,
token
)
.then((response: any) => {
Expand All @@ -193,6 +203,7 @@ mySdk.channels
'<userId1>', '<userId2>'
],
'administrator',
domainId,
token
)
.then((response: any) => {
Expand All @@ -208,6 +219,7 @@ mySdk.channels
[
'<UserGroupId1>', '<UserGroupId2>'
],
domainId,
token
)
.then((response: any) => {
Expand All @@ -223,6 +235,7 @@ mySdk.channels
[
'<UserGroupId1>', '<UserGroupId2>'
],
domainId,
token
)
.then((response: any) => {
Expand All @@ -234,7 +247,8 @@ mySdk.channels

mySdk.channels
.DeleteChannel(
{ id: '<channelId>' },
'<channelId>',
domainId,
token
)
.then((response: any) => {
Expand Down
Loading

0 comments on commit c4f60b9

Please sign in to comment.