Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Manage API Examples and Fix Formatting in Other Examples #260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions Deepgram.Dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,36 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "balances", "balances", "{7C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\balances\Manage.csproj", "{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "debug", "debug", "{60E5C3AE-B377-4E53-B4CF-03D33839F382}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "streaming", "streaming", "{248ECFA2-D91E-4544-8B61-9D4410D90BEF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "tests\debug\streaming\Streaming.csproj", "{B488DC2B-02B2-46D7-9EA6-7033C1190878}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "invitations", "invitations", "{01445A10-0E4E-4457-A4CC-D071897D3FCF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "keys", "keys", "{1C04C4F8-3FC6-4487-8E48-779D2F223247}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "members", "members", "{25550C53-1E7F-46BF-9D94-3369A3A4E5A3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "projects", "projects", "{E7D50060-F040-4607-A0EF-34A4ABB4C770}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "usage", "usage", "{CB0677E6-85EC-47B9-A392-FF5B56484F15}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scopes", "scopes", "{6B24CAD4-8486-405C-B7EB-14086177C634}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\invitations\Manage.csproj", "{47017DCF-19C3-4692-8EB2-45DD9E6893CD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\keys\Manage.csproj", "{64436CDA-A428-44F8-8F16-B8CFD577DE04}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\members\Manage.csproj", "{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\projects\Manage.csproj", "{0C82172F-6433-4089-919A-6CA7A54BAFA4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\scopes\Manage.csproj", "{A65BCE7D-761C-4D09-8E89-CEA461D7C832}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manage", "examples\manage\usage\Manage.csproj", "{260D68E2-540F-4BFF-AF52-B014E7615795}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -183,6 +213,34 @@ Global
{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51}.Release|Any CPU.Build.0 = Release|Any CPU
{B488DC2B-02B2-46D7-9EA6-7033C1190878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B488DC2B-02B2-46D7-9EA6-7033C1190878}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B488DC2B-02B2-46D7-9EA6-7033C1190878}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B488DC2B-02B2-46D7-9EA6-7033C1190878}.Release|Any CPU.Build.0 = Release|Any CPU
{47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47017DCF-19C3-4692-8EB2-45DD9E6893CD}.Release|Any CPU.Build.0 = Release|Any CPU
{64436CDA-A428-44F8-8F16-B8CFD577DE04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64436CDA-A428-44F8-8F16-B8CFD577DE04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64436CDA-A428-44F8-8F16-B8CFD577DE04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64436CDA-A428-44F8-8F16-B8CFD577DE04}.Release|Any CPU.Build.0 = Release|Any CPU
{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC}.Release|Any CPU.Build.0 = Release|Any CPU
{0C82172F-6433-4089-919A-6CA7A54BAFA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C82172F-6433-4089-919A-6CA7A54BAFA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C82172F-6433-4089-919A-6CA7A54BAFA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C82172F-6433-4089-919A-6CA7A54BAFA4}.Release|Any CPU.Build.0 = Release|Any CPU
{A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A65BCE7D-761C-4D09-8E89-CEA461D7C832}.Release|Any CPU.Build.0 = Release|Any CPU
{260D68E2-540F-4BFF-AF52-B014E7615795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{260D68E2-540F-4BFF-AF52-B014E7615795}.Debug|Any CPU.Build.0 = Debug|Any CPU
{260D68E2-540F-4BFF-AF52-B014E7615795}.Release|Any CPU.ActiveCfg = Release|Any CPU
{260D68E2-540F-4BFF-AF52-B014E7615795}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -230,6 +288,21 @@ Global
{FA5723B3-74E9-4221-80EF-4833C1C3DD9F} = {C673DFD1-528A-4BAE-94E6-02EF058AC363}
{7CD5D816-0F30-45D7-9C9F-872E67F6A711} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{2BF14C9B-755E-41FD-BB59-D6A82E0EFC51} = {7CD5D816-0F30-45D7-9C9F-872E67F6A711}
{60E5C3AE-B377-4E53-B4CF-03D33839F382} = {9D2B336D-17F9-41D5-A4E5-F3EDA7F496A5}
{248ECFA2-D91E-4544-8B61-9D4410D90BEF} = {60E5C3AE-B377-4E53-B4CF-03D33839F382}
{B488DC2B-02B2-46D7-9EA6-7033C1190878} = {248ECFA2-D91E-4544-8B61-9D4410D90BEF}
{01445A10-0E4E-4457-A4CC-D071897D3FCF} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{1C04C4F8-3FC6-4487-8E48-779D2F223247} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{25550C53-1E7F-46BF-9D94-3369A3A4E5A3} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{E7D50060-F040-4607-A0EF-34A4ABB4C770} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{CB0677E6-85EC-47B9-A392-FF5B56484F15} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{6B24CAD4-8486-405C-B7EB-14086177C634} = {FA5723B3-74E9-4221-80EF-4833C1C3DD9F}
{47017DCF-19C3-4692-8EB2-45DD9E6893CD} = {01445A10-0E4E-4457-A4CC-D071897D3FCF}
{64436CDA-A428-44F8-8F16-B8CFD577DE04} = {1C04C4F8-3FC6-4487-8E48-779D2F223247}
{FE8EE50A-9632-4C2B-8425-6D3D2EE12DFC} = {25550C53-1E7F-46BF-9D94-3369A3A4E5A3}
{0C82172F-6433-4089-919A-6CA7A54BAFA4} = {E7D50060-F040-4607-A0EF-34A4ABB4C770}
{A65BCE7D-761C-4D09-8E89-CEA461D7C832} = {6B24CAD4-8486-405C-B7EB-14086177C634}
{260D68E2-540F-4BFF-AF52-B014E7615795} = {CB0677E6-85EC-47B9-A392-FF5B56484F15}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D4ABC6D-7126-4EE2-9303-43A954616B2A}
Expand Down
2 changes: 1 addition & 1 deletion Deepgram/Models/Manage/v1/Details.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public record Details
/// Number of audio files processed in the request.
/// </summary>
[JsonPropertyName("total_audio")]
public int? TotalAudio { get; set; }
public double? TotalAudio { get; set; }

/// <summary>
/// Number of channels in the audio associated with the request.
Expand Down
6 changes: 3 additions & 3 deletions Deepgram/Models/Manage/v1/InviteSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

namespace Deepgram.Models.Manage.v1;

public class InviteSchema(string email, string scope)
public class InviteSchema
{
/// <summary>
/// email of the person being invited
/// </summary>
[JsonPropertyName("email")]
public string? Email { get; set; } = email;
public string? Email { get; set; }

/// <summary>
/// scopes to add for the invited person
/// </summary>
[JsonPropertyName("scope")]
public string? Scope { get; set; } = scope;
public string? Scope { get; set; }

}
6 changes: 3 additions & 3 deletions Deepgram/Models/Manage/v1/KeySchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

namespace Deepgram.Models.Manage.v1;

public class KeySchema(string comment, List<string> scopes)
public class KeySchema
{

/// <summary>
/// Comment to describe key
/// </summary>
[JsonPropertyName("comment")]
public string? Comment { get; set; } = comment;
public string? Comment { get; set; }

/// <summary>
/// Scopes of the key
/// </summary>
[JsonPropertyName("scopes")]
public List<string>? Scopes { get; set; } = scopes;
public List<string>? Scopes { get; set; }

/// <summary>
/// Tag names for key
Expand Down
4 changes: 2 additions & 2 deletions Deepgram/Models/Manage/v1/MemberScopeSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Deepgram.Models.Manage.v1;

public class MemberScopeSchema(string scope)
public class MemberScopeSchema
{
/// <summary>
/// Scope to add for member
/// </summary>
[JsonPropertyName("scope")]
public string? Scope { get; set; } = scope;
public string? Scope { get; set; }
}
4 changes: 2 additions & 2 deletions Deepgram/Models/Manage/v1/UsageFieldsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public record UsageFieldsResponse
/// ReadOnlyList of <see cref="RequestMethod"/>
/// </summary>
[JsonPropertyName("processing_methods")]
[JsonConverter(typeof(JsonStringEnumConverter))]
public IReadOnlyList<RequestMethod>? ProcessingMethods { get; set; }
//[JsonConverter(typeof(JsonStringEnumConverter))]
public IReadOnlyList<string>? ProcessingMethods { get; set; }

/// <summary>
/// ReadOnlyList of included languages
Expand Down
1 change: 1 addition & 0 deletions Deepgram/Models/PreRecorded/v1/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT

namespace Deepgram.Models.PreRecorded.v1;

public record Channel
{
/// <summary>
Expand Down
32 changes: 0 additions & 32 deletions Deepgram/Models/PreRecorded/v1/IntentSchema.cs

This file was deleted.

8 changes: 7 additions & 1 deletion examples/analyze/intent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ static async Task Main(string[] args)
// Normal logging is "Info" level
Library.Initialize();

// JSON options
JsonSerializerOptions options = new(JsonSerializerDefaults.Web)
{
WriteIndented = true
};

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new AnalyzeClient();

Expand All @@ -35,7 +41,7 @@ static async Task Main(string[] args)
Intents = true,
});

Console.WriteLine(JsonSerializer.Serialize(response));
Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n");
Console.ReadKey();

// Teardown Library
Expand Down
8 changes: 7 additions & 1 deletion examples/analyze/sentiment/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ static async Task Main(string[] args)
// Normal logging is "Info" level
Library.Initialize();

// JSON options
JsonSerializerOptions options = new(JsonSerializerDefaults.Web)
{
WriteIndented = true
};

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new AnalyzeClient();

Expand All @@ -35,7 +41,7 @@ static async Task Main(string[] args)
Sentiment = true,
});

Console.WriteLine(JsonSerializer.Serialize(response));
Console.WriteLine(JsonSerializer.Serialize(response, options));
Console.ReadKey();

// Teardown Library
Expand Down
8 changes: 7 additions & 1 deletion examples/analyze/summary/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ static async Task Main(string[] args)
// Normal logging is "Info" level
Library.Initialize();

// JSON options
JsonSerializerOptions options = new(JsonSerializerDefaults.Web)
{
WriteIndented = true
};

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new AnalyzeClient();

Expand All @@ -35,7 +41,7 @@ static async Task Main(string[] args)
Summarize = true,
});

Console.WriteLine(JsonSerializer.Serialize(response));
Console.WriteLine(JsonSerializer.Serialize(response, options));
Console.ReadKey();

// Teardown Library
Expand Down
8 changes: 7 additions & 1 deletion examples/analyze/topic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ static async Task Main(string[] args)
// Normal logging is "Info" level
Library.Initialize();

// JSON options
JsonSerializerOptions options = new(JsonSerializerDefaults.Web)
{
WriteIndented = true
};

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new AnalyzeClient();

Expand All @@ -35,7 +41,7 @@ static async Task Main(string[] args)
Topics = true,
});

Console.WriteLine(JsonSerializer.Serialize(response));
Console.WriteLine(JsonSerializer.Serialize(response, options));
Console.ReadKey();

// Teardown Library
Expand Down
73 changes: 36 additions & 37 deletions examples/manage/balances/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ static async Task Main(string[] args)
// OR very chatty logging
//Library.Initialize(LogLevel.Debug); // LogLevel.Default, LogLevel.Debug, LogLevel.Verbose

// JSON options
JsonSerializerOptions options = new(JsonSerializerDefaults.Web)
{
WriteIndented = true
};
davidvonthenen marked this conversation as resolved.
Show resolved Hide resolved

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new ManageClient();

Expand All @@ -28,48 +34,41 @@ static async Task Main(string[] args)
Console.WriteLine("No projects found.");
return;
}
Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n");

Console.WriteLine(JsonSerializer.Serialize(response));

//var projectId = "";
//foreach (var project in response.Projects)
//{
// Console.WriteLine($"Project ID: {project.ProjectId}");
// projectId = project.ProjectId;
// break;
//}

//var balanacesResponse = deepgramClient.GetBalances(projectId);
//if (balanacesResponse == null || balanacesResponse.Balances == null)
//{
// Console.WriteLine("No balance found.");
// return;
//}

//Console.WriteLine("\n\nBalances:");
//Console.WriteLine(JsonSerializer.Serialize(balanacesResponse));
//Console.WriteLine("\n\n");
var projectId = "";
foreach (var project in response.Projects)
{
Console.WriteLine($"Using Project ID: {project.ProjectId}");
projectId = project.ProjectId;
break;
}

//string balanceId = "";
//foreach (var balance in balanacesResponse.Balances)
//{
// Console.WriteLine($"Balance ID: {balance.BalanceId}");
// balanceId = balance.BalanceId;
// break;
//}
var balanacesResponse = deepgramClient.GetBalances(projectId);
if (balanacesResponse == null)
{
Console.WriteLine("\n\nNo balance found.\n\n");
return;
}
Console.WriteLine($"\n\n{JsonSerializer.Serialize(balanacesResponse, options)}\n\n");

//var balanaceResponse = deepgramClient.GetBalance(projectId, balanceId);
//if (balanaceResponse == null)
//{
// Console.WriteLine("No balance found.");
// return;
//}
string balanceId = "";
foreach (var balance in balanacesResponse.Result.Balances)
{
Console.WriteLine($"Using Balance ID: {balance.BalanceId}");
balanceId = balance.BalanceId;
break;
}

//Console.WriteLine("\n\nBalances:");
//Console.WriteLine(JsonSerializer.Serialize(balanacesResponse));
//Console.WriteLine("\n\n");
var balanceResponse = deepgramClient.GetBalance(projectId, balanceId);
if (balanceResponse == null)
{
Console.WriteLine("\n\nNo balance found.\n\n");
return;
}
Console.WriteLine($"\n\n{JsonSerializer.Serialize(balanceResponse, options)}\n\n");

Console.WriteLine("Press any key to exit.");
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadKey();

// Teardown Library
Expand Down
Loading
Loading