-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathEntityOptions.cs
More file actions
156 lines (127 loc) · 8.32 KB
/
Copy pathEntityOptions.cs
File metadata and controls
156 lines (127 loc) · 8.32 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using CommandLine;
namespace Cli.Commands
{
/// <summary>
/// Command options for entity manipulation.
/// </summary>
public class EntityOptions : Options
{
public EntityOptions(
string entity,
string? sourceType,
IEnumerable<string>? sourceParameters,
IEnumerable<string>? sourceKeyFields,
string? restRoute,
IEnumerable<string>? restMethodsForStoredProcedure,
string? graphQLType,
string? graphQLOperationForStoredProcedure,
IEnumerable<string>? fieldsToInclude,
IEnumerable<string>? fieldsToExclude,
string? policyRequest,
string? policyDatabase,
string? cacheEnabled,
string? cacheTtlSeconds,
string? cacheLevel,
string? healthEnabled,
string? description,
IEnumerable<string>? parametersNameCollection,
IEnumerable<string>? parametersDescriptionCollection,
IEnumerable<string>? parametersRequiredCollection,
IEnumerable<string>? parametersDefaultCollection,
IEnumerable<string>? fieldsNameCollection,
IEnumerable<string>? fieldsAliasCollection,
IEnumerable<string>? fieldsDescriptionCollection,
IEnumerable<bool>? fieldsPrimaryKeyCollection,
string? mcpDmlTools = null,
string? mcpCustomTool = null,
string? config = null
)
: base(config)
{
Entity = entity;
SourceType = sourceType;
SourceParameters = sourceParameters;
SourceKeyFields = sourceKeyFields;
RestRoute = restRoute;
RestMethodsForStoredProcedure = restMethodsForStoredProcedure;
GraphQLType = graphQLType;
GraphQLOperationForStoredProcedure = graphQLOperationForStoredProcedure;
FieldsToInclude = fieldsToInclude;
FieldsToExclude = fieldsToExclude;
PolicyRequest = policyRequest;
PolicyDatabase = policyDatabase;
CacheEnabled = cacheEnabled;
CacheTtlSeconds = cacheTtlSeconds;
CacheLevel = cacheLevel;
HealthEnabled = healthEnabled;
Description = description;
ParametersNameCollection = parametersNameCollection;
ParametersDescriptionCollection = parametersDescriptionCollection;
ParametersRequiredCollection = parametersRequiredCollection;
ParametersDefaultCollection = parametersDefaultCollection;
FieldsNameCollection = fieldsNameCollection;
FieldsAliasCollection = fieldsAliasCollection;
FieldsDescriptionCollection = fieldsDescriptionCollection;
FieldsPrimaryKeyCollection = fieldsPrimaryKeyCollection;
McpDmlTools = mcpDmlTools;
McpCustomTool = mcpCustomTool;
}
// Entity is required but we have made required as false to have custom error message (more user friendly), if not provided.
[Value(0, MetaName = "Entity", Required = false, HelpText = "Name of the entity.")]
public string Entity { get; }
[Option("source.type", Required = false, HelpText = "Type of the database object.Must be one of: [table, view, stored-procedure]")]
public string? SourceType { get; }
[Option("source.params", Required = false, Separator = ',', HelpText = "Dictionary of parameters and their values for Source object.\"param1:val1,param2:value2,..\"")]
public IEnumerable<string>? SourceParameters { get; }
[Option("source.key-fields", Required = false, Separator = ',', HelpText = "The field(s) to be used as primary keys.")]
public IEnumerable<string>? SourceKeyFields { get; }
[Option("rest", Required = false, HelpText = "Route for rest api.")]
public string? RestRoute { get; }
[Option("rest.methods", Required = false, Separator = ',', HelpText = "HTTP actions to be supported for stored procedure. Specify the actions as a comma separated list. Valid HTTP actions are: [get, post, put, patch, delete]")]
public IEnumerable<string>? RestMethodsForStoredProcedure { get; }
[Option("graphql", Required = false, HelpText = "Type of graphQL.")]
public string? GraphQLType { get; }
[Option("graphql.operation", Required = false, HelpText = "GraphQL operation to be supported for stored procedure. Valid operations are: [query, mutation]")]
public string? GraphQLOperationForStoredProcedure { get; }
[Option("fields.include", Required = false, Separator = ',', HelpText = "Fields that are allowed access to permission.")]
public IEnumerable<string>? FieldsToInclude { get; }
[Option("fields.exclude", Required = false, Separator = ',', HelpText = "Fields that are excluded from the action lists.")]
public IEnumerable<string>? FieldsToExclude { get; }
[Option("policy-request", Required = false, HelpText = "Specify the rule to be checked before sending any request to the database.")]
public string? PolicyRequest { get; }
[Option("policy-database", Required = false, HelpText = "Specify an OData style filter rule that will be injected in the query sent to the database.")]
public string? PolicyDatabase { get; }
[Option("cache.enabled", Required = false, HelpText = "Specify if caching is enabled for Entity, default value is false.")]
public string? CacheEnabled { get; }
[Option("cache.ttl-seconds", Required = false, HelpText = "Specify time to live in seconds for cache entries for Entity.")]
public string? CacheTtlSeconds { get; }
[Option("cache.level", Required = false, HelpText = "Cache level for entity. Allowed values: L1, L1L2. Default: L1L2.")]
public string? CacheLevel { get; }
[Option("health.enabled", Required = false, HelpText = "Enable health checks for this entity. Default: true (boolean).")]
public string? HealthEnabled { get; }
[Option("description", Required = false, HelpText = "Description of the entity.")]
public string? Description { get; }
[Option("parameters.name", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter names for stored procedure.")]
public IEnumerable<string>? ParametersNameCollection { get; }
[Option("parameters.description", Required = false, HelpText = "List of parameter descriptions for stored procedure. Provide one value per parameter. Descriptions may contain commas.")]
public IEnumerable<string>? ParametersDescriptionCollection { get; }
[Option("parameters.required", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter required flags (true/false) for stored procedure.")]
public IEnumerable<string>? ParametersRequiredCollection { get; }
[Option("parameters.default", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter default values for stored procedure.")]
public IEnumerable<string>? ParametersDefaultCollection { get; }
[Option("fields.name", Required = false, Separator = ',', HelpText = "Name of the database column to expose as a field.")]
public IEnumerable<string>? FieldsNameCollection { get; }
[Option("fields.alias", Required = false, Separator = ',', HelpText = "Alias for the field.")]
public IEnumerable<string>? FieldsAliasCollection { get; }
[Option("fields.description", Required = false, HelpText = "Description for the field. Descriptions may contain commas.")]
public IEnumerable<string>? FieldsDescriptionCollection { get; }
[Option("fields.primary-key", Required = false, Separator = ',', HelpText = "Set this field as a primary key.")]
public IEnumerable<bool>? FieldsPrimaryKeyCollection { get; }
[Option("mcp.dml-tools", Required = false, HelpText = "Enable MCP DML (Data Manipulation Language) tools for this entity. Allows CRUD operations via MCP. Default value is true.")]
public string? McpDmlTools { get; }
[Option("mcp.custom-tool", Required = false, HelpText = "Enable MCP custom tool for this entity. Only valid for stored procedures. Default value is false.")]
public string? McpCustomTool { get; }
}
}