-
Notifications
You must be signed in to change notification settings - Fork 32
/
Program.cs
119 lines (102 loc) · 4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
using Deepgram.Models.Manage.v1;
namespace SampleApp
{
class Program
{
private const string MEMBER_BY_EMAIL = "MEMBER_TO_DELETE_BY_EMAIL";
static async Task Main(string[] args)
{
// Initialize Library with default logging
// Normal logging is "Info" level
Library.Initialize();
// use the client factory with a API Key set with the "DEEPGRAM_API_KEY" environment variable
var deepgramClient = ClientFactory.CreateManageClient();
// get projects
var projectResp = await deepgramClient.GetProjects();
if (projectResp == null)
{
Console.WriteLine("ListProjects failed.");
Environment.Exit(1);
}
string myId = null;
string myName = null;
foreach (var project in projectResp.Projects)
{
myId = project.ProjectId;
myName = project.Name;
break;
}
Console.WriteLine($"\n\n{projectResp}\n\n");
// list members
string memberId = null;
var listResp = await deepgramClient.GetMembers(myId);
if (listResp == null)
{
Console.WriteLine("\n\nNo members found\n\n");
}
else
{
Console.WriteLine($"\n\n{listResp}\n\n");
foreach (var member in listResp.Members)
{
if (member.Email == MEMBER_BY_EMAIL)
{
memberId = member.MemberId;
}
}
}
if (memberId == null)
{
Console.WriteLine("This example requires a member who is already a member with email in the value of \"MEMBER_BY_EMAIL\".");
Console.WriteLine("This is required to exercise the UpdateMemberScope function.");
Console.WriteLine("In the absence of this, this example will exit early.");
Environment.Exit(1);
}
// get member scope
var memberResp = await deepgramClient.GetMemberScopes(myId, memberId);
if (memberResp == null)
{
Console.WriteLine("\n\nNo scopes found\n\n");
Environment.Exit(1);
}
Console.WriteLine($"\n\n{memberResp}\n\n");
// update scope
var scopeUpdate = new MemberScopeSchema()
{
Scope = "admin"
};
var updateResp = await deepgramClient.UpdateMemberScope(myId, memberId, scopeUpdate);
Console.WriteLine($"\n\n{updateResp}\n\n");
// get member scope
memberResp = await deepgramClient.GetMemberScopes(myId, memberId);
if (memberResp == null)
{
Console.WriteLine("\n\nNo scopes found\n\n");
Environment.Exit(1);
}
Console.WriteLine($"\n\n{memberResp}\n\n");
// update scope
scopeUpdate = new MemberScopeSchema()
{
Scope = "member",
};
updateResp = await deepgramClient.UpdateMemberScope(myId, memberId, scopeUpdate);
Console.WriteLine($"\n\n{updateResp}\n\n");
// get member scope
memberResp = await deepgramClient.GetMemberScopes(myId, memberId);
if (memberResp == null)
{
Console.WriteLine("\n\nNo scopes found\n\n");
Environment.Exit(1);
}
Console.WriteLine($"\n\n{memberResp}\n\n");
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadKey();
// Teardown Library
Library.Terminate();
}
}
}