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

Jira plugin open api #648

Merged
merged 31 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
26b69b0
initial setup
amsacha Apr 19, 2023
0eb897c
remove functions that cant be called because of incomplete jira open …
amsacha Apr 24, 2023
e60bbf6
Update RestApiOperationRunner to not wrap json objects into jsons
amsacha Apr 25, 2023
2c22352
restore program.cs; update the simplified jira schema; rename and mov…
amsacha Apr 25, 2023
ee8e743
make variables generic
amsacha Apr 25, 2023
a47194f
minor name change typo
amsacha Apr 25, 2023
456b139
Merge branch 'main' into JiraPluginOpenAPI
adrianwyatt Apr 25, 2023
a1d33c2
Revert "Update RestApiOperationRunner to not wrap json objects into j…
amsacha Apr 25, 2023
2fd5a42
pr comments addressed
amsacha Apr 25, 2023
745871b
inline functions and remove full open api schema
amsacha Apr 25, 2023
f498e87
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 25, 2023
8e28bae
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 26, 2023
cf43bb3
minor naming and comment change
amsacha Apr 26, 2023
51c1fd9
Update samples/dotnet/kernel-syntax-examples/Example22_b_OpenApiSkill…
amsacha Apr 26, 2023
8aa85df
change example name
amsacha Apr 26, 2023
abc9ced
Update Example22_OpenApiSkill_Jira.cs
amsacha Apr 26, 2023
ab24599
Merge branch 'main' into JiraPluginOpenAPI
adrianwyatt Apr 27, 2023
5342bb6
add readme
amsacha Apr 27, 2023
68c7972
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 27, 2023
f490d3c
update namespaces being used
amsacha Apr 27, 2023
f68d42c
ran dotnet format
amsacha Apr 27, 2023
f955938
readme and comment fixes
amsacha Apr 27, 2023
8f6df5f
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 27, 2023
0239e6f
rename files
amsacha Apr 27, 2023
d84a707
rename all examples after 21
amsacha Apr 27, 2023
d990385
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 28, 2023
455c65d
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 28, 2023
d9497ad
Merge branch 'main' into JiraPluginOpenAPI
amsacha Apr 28, 2023
3e68708
Merge branch 'main' into JiraPluginOpenAPI
amsacha May 1, 2023
dcfce1d
Merge branch 'main' into JiraPluginOpenAPI
dluc May 1, 2023
00f384e
Merge branch 'main' into JiraPluginOpenAPI
amsacha May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using RepoUtils;

// ReSharper disable once InconsistentNaming
public static class Example22_OpenApiSkill
public static class Example22_OpenApiSkill_AzureKeyVault
{
public static async Task RunAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.WebApi.Rest;
using Microsoft.SemanticKernel.Orchestration;
using Microsoft.SemanticKernel.Skills.OpenAPI.Authentication;
using Microsoft.SemanticKernel.Skills.OpenAPI.Skills;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RepoUtils;

public static class Example22_OpenApiSkill_Jira
amsacha marked this conversation as resolved.
Show resolved Hide resolved
{
public static async Task RunAsync()
{
var kernel = new KernelBuilder().WithLogger(ConsoleLogger.Log).Build();
var contextVariables = new ContextVariables();

// Change <your-domain> to a jira instance you have access to with your authentication credentials
string serverUrl = "https://<your-domain>.atlassian.net/rest/api/latest/";
contextVariables.Set("server-url", serverUrl);

IDictionary<string, ISKFunction> jiraSkills;

Check failure on line 29 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The type or namespace name 'ISKFunction' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 29 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The type or namespace name 'ISKFunction' could not be found (are you missing a using directive or an assembly reference?)
var tokenProvider = new BasicAuthenticationProvider(() =>
{
string s = Env.Var("MY_EMAIL_ADDRESS") + ":" + Env.Var("JIRA_API_KEY");
return Task.FromResult(s);
});

// The bool useLocalFile can be used to toggle the ingestion method for the openapi schema between a file path and a URL
bool useLocalFile = true;
if (useLocalFile)
{
var apiSkillFile = "./../../../Skills/JiraSkill/openapi.json";
jiraSkills = await kernel.ImportOpenApiSkillFromFileAsync("jiraSkills", apiSkillFile, tokenProvider.AuthenticateRequestAsync);

Check failure on line 41 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Cannot implicitly convert type 'System.Collections.Generic.IDictionary<string, Microsoft.SemanticKernel.SkillDefinition.ISKFunction>' to 'System.Collections.Generic.IDictionary<string, ISKFunction>'. An explicit conversion exists (are you missing a cast?)

Check failure on line 41 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Cannot implicitly convert type 'System.Collections.Generic.IDictionary<string, Microsoft.SemanticKernel.SkillDefinition.ISKFunction>' to 'System.Collections.Generic.IDictionary<string, ISKFunction>'. An explicit conversion exists (are you missing a cast?)
}
else
{
var apiSkillRawFileURL = new Uri("https://raw.githubusercontent.com/microsoft/PowerPlatformConnectors/dev/certified-connectors/JIRA/apiDefinition.swagger.json");
jiraSkills = await kernel.ImportOpenApiSkillFromUrlAsync("jiraSkills", apiSkillRawFileURL, null, tokenProvider.AuthenticateRequestAsync);

Check failure on line 46 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Cannot implicitly convert type 'System.Collections.Generic.IDictionary<string, Microsoft.SemanticKernel.SkillDefinition.ISKFunction>' to 'System.Collections.Generic.IDictionary<string, ISKFunction>'. An explicit conversion exists (are you missing a cast?)

Check failure on line 46 in samples/dotnet/kernel-syntax-examples/Example22_OpenApiSkill_Jira.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Cannot implicitly convert type 'System.Collections.Generic.IDictionary<string, Microsoft.SemanticKernel.SkillDefinition.ISKFunction>' to 'System.Collections.Generic.IDictionary<string, ISKFunction>'. An explicit conversion exists (are you missing a cast?)
}

// GetIssue Skill
{
//Set Properties for the Get Issue operation in the openAPI.swagger.json
contextVariables.Set("issueKey", "SKTES-2");

//Run operation via the semantic kernel
var result = await kernel.RunAsync(contextVariables, jiraSkills["GetIssue"]);

Console.WriteLine("\n\n\n");
var formattedContent = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(result.Result), Formatting.Indented);
Console.WriteLine("GetIssue jiraSkills response: \n{0}", formattedContent);
}

// AddComment Skill
{
//Set Properties for the AddComment operation in the openAPI.swagger.json
amsacha marked this conversation as resolved.
Show resolved Hide resolved
contextVariables.Set("issueKey", "SKTES-1");
contextVariables.Set("body", "Here is a rad comment");

//Run operation via the semantic kernel
var result = await kernel.RunAsync(contextVariables, jiraSkills["AddComment"]);

Console.WriteLine("\n\n\n");
var formattedContent = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(result.Result), Formatting.Indented);
Console.WriteLine("AddComment jiraSkills response: \n{0}", formattedContent);
}
}
}
5 changes: 4 additions & 1 deletion samples/dotnet/kernel-syntax-examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public static async Task Main()
await Example21_ChatGptPlugins.RunAsync();
Console.WriteLine("== DONE ==");

await Example22_OpenApiSkill.RunAsync();
await Example22_OpenApiSkill_AzureKeyVault.RunAsync();
Console.WriteLine("== DONE ==");

await Example22_OpenApiSkill_Jira.RunAsync();
Console.WriteLine("== DONE ==");

await Example23_ReadOnlyMemoryStore.RunAsync();
Expand Down