Skip to content

Commit

Permalink
add channel role management
Browse files Browse the repository at this point in the history
Signed-off-by: ianmuchyri <[email protected]>
  • Loading branch information
ianmuchyri committed Jan 26, 2025
1 parent 227ce41 commit 089cdab
Show file tree
Hide file tree
Showing 4 changed files with 1,019 additions and 162 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-rats-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@absmach/magistrala-sdk": patch
---

Add channel level role management
182 changes: 173 additions & 9 deletions examples/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mySdk.channels
.CreateChannels(
[{ name: "<channelName1>" }, { name: "<channelName2>" }],
domainId,
token,
token
)
.then((response: any) => {
console.log("response:", response);
Expand All @@ -56,7 +56,7 @@ mySdk.channels
.UpdateChannelNameAndMetadata(
{ id: "<channelId>", name: "<channelName>", metadata: { key: "value" } },
domainId,
token,
token
)
.then((response: any) => {
console.log("response:", response);
Expand All @@ -69,7 +69,7 @@ mySdk.channels
.UpdateChannelTags(
{ id: "<channelId>", tags: ["tag1", "tag2"] },
domainId,
token,
token
)
.then((response: any) => {
console.log("response:", response);
Expand Down Expand Up @@ -102,7 +102,7 @@ mySdk.channels
"<channelId>",
["publish"],
domainId,
token,
token
)
.then((response: any) => {
console.log("response: ", response);
Expand All @@ -117,7 +117,7 @@ mySdk.channels
"<channelId>",
["publish"],
domainId,
token,
token
)
.then((response: any) => {
console.log("response: ", response);
Expand All @@ -132,7 +132,7 @@ mySdk.channels
["<channelId1>", "<channelId1>"],
["publish"],
domainId,
token,
token
)
.then((response: any) => {
console.log("response:", response);
Expand All @@ -147,7 +147,7 @@ mySdk.channels
["<channelId1>", "<channelId1>"],
["publish"],
domainId,
token,
token
)
.then((response: any) => {
console.log("response: ", response);
Expand All @@ -156,15 +156,17 @@ mySdk.channels
console.error(error);
});

mySdk.channels.SetChannelParentGroup(domainId, "<channelId>", "<parentGroupId>", token)
mySdk.channels
.SetChannelParentGroup(domainId, "<channelId>", "<parentGroupId>", token)
.then((response: any) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels.DeleteChannelParentGroup(domainId, "<channelId>", token)
mySdk.channels
.DeleteChannelParentGroup(domainId, "<channelId>", token)
.then((response: any) => {
console.log("response: ", response);
})
Expand All @@ -180,3 +182,165 @@ mySdk.channels
.catch((error) => {
console.error(error);
});

mySdk.channels
.ListChannelActions(domainId, token)
.then((response: any) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.CreateChannelRole("<channelId>", "<roleName>", domainId, token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.ListChannelRoles("<channelId>", domainId, { offset: 0, limit: 10 }, token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.ViewChannelRole("<channelId>", domainId, "<roleId>", token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.UpdateChannelRole(
"<channelId>",
domainId,
"<roleId>",
{ name: "<updatedRoleName>" },
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.DeleteChannelRole("<channelId>", domainId, "<roleId>", token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.AddChannelRoleActions(
"<channelId>",
domainId,
"<roleId>",
["<action>", "<action>"],
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.ListChannelRoleActions("<channelId>", domainId, "<roleId>", token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.DeleteChannelRoleActions(
"<channelId>",
domainId,
"<roleId>",
["<action>", "<action>"],
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.DeleteAllChannelRoleActions("<channelId>", domainId, "<roleId>", token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.AddChannelRoleMembers(
"<channelId>",
domainId,
"<roleId>",
["<userId>", "<userId>"],
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.ListChannelRoleMembers(
"<channelId>",
domainId,
"<roleId>",
{ offset: 0, limit: 10 },
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.DeleteChannelRoleMembers(
"<channelId>",
domainId,
"<roleId>",
["<userId>", "<userId>"],
token
)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});

mySdk.channels
.DeleteAllChannelRoleMembers("<channelId>", domainId, "<roleId>", token)
.then((response) => {
console.log("response: ", response);
})
.catch((error) => {
console.error(error);
});
Loading

0 comments on commit 089cdab

Please sign in to comment.