-
Notifications
You must be signed in to change notification settings - Fork 545
Expand file tree
/
Copy pathAzureTerraformBestPracticesGetCommand.cs
More file actions
48 lines (42 loc) · 1.94 KB
/
Copy pathAzureTerraformBestPracticesGetCommand.cs
File metadata and controls
48 lines (42 loc) · 1.94 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Net;
using System.Reflection;
using Microsoft.Mcp.Core.Commands;
using Microsoft.Mcp.Core.Helpers;
using Microsoft.Mcp.Core.Models.Command;
namespace Azure.Mcp.Tools.AzureTerraformBestPractices.Commands;
[CommandMetadata(
Id = "5bd36575-6313-4bf4-aa26-a79fe0fa32a8",
Name = "get",
Title = "Get Terraform Best Practices for Azure",
Description = """
Returns Terraform best practices for Azure. Call this command and follow its guidance before
generating or suggesting any Terraform code specific to Azure. If this tool needs to be categorized, it belongs to
the Azure Best Practices category.
""",
Destructive = false,
Idempotent = true,
OpenWorld = false,
ReadOnly = true,
Secret = false,
LocalRequired = false)]
public sealed class AzureTerraformBestPracticesGetCommand() : BaseCommand<EmptyOptions, List<string>>
{
private static readonly string s_bestPracticesText = LoadBestPracticesText();
private static string GetBestPracticesText() => s_bestPracticesText;
private static string LoadBestPracticesText()
{
Assembly assembly = typeof(AzureTerraformBestPracticesGetCommand).Assembly;
string resourceName = EmbeddedResourceHelper.FindEmbeddedResource(assembly, "terraform-best-practices-for-azure.txt");
return EmbeddedResourceHelper.ReadEmbeddedResource(assembly, resourceName);
}
public override Task<CommandResponse> ExecuteAsync(CommandContext context, EmptyOptions options, CancellationToken cancellationToken)
{
var bestPractices = GetBestPracticesText();
context.Response.Status = HttpStatusCode.OK;
context.Response.Results = ResponseResult.Create([bestPractices], AzureTerraformBestPracticesJsonContext.Default.ListString);
context.Response.Message = string.Empty;
return Task.FromResult(context.Response);
}
}