Add logic app sample.
This commit is contained in:
Родитель
e96ab72921
Коммит
3e65496e6e
|
@ -0,0 +1,4 @@
|
|||
module.exports.input = "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/logic/resource-manager/Microsoft.Logic/stable/2016-06-01/logic.json";
|
||||
module.exports.metadata = "samples/logicapp/configuration.json";
|
||||
module.exports.namespace = "azurerm";
|
||||
module.exports.displayModel = "all";
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"name": "Logic App",
|
||||
"spec": "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/logic/resource-manager/Microsoft.Logic/stable/2016-06-01/logic.json",
|
||||
"import": {
|
||||
"fmt": "fmt",
|
||||
"log": "log",
|
||||
"net/http": "net/http",
|
||||
"strings": "strings",
|
||||
"schema": "github.com/hashicorp/terraform/helper/schema",
|
||||
"utils": "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils",
|
||||
"logic": "github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic"
|
||||
},
|
||||
"typepkg": [{
|
||||
"type": "{:**:}",
|
||||
"package": "logic"
|
||||
}],
|
||||
"create": [{
|
||||
"method": "LogicManagementClient/Workflows/CreateOrUpdate",
|
||||
"schema": {
|
||||
"ignore": [
|
||||
"{:p:}/apiVersion", "{:p:}/subscriptionId", "{:p:}/Id", "{:p:}/Type",
|
||||
"{:p:}/workflow/CreatedTime", "{:p:}/workflow/ChangedTime", "{:p:}/workflow/Definition", "{:p:}/workflow/Parameters/Value", "{:p:}/workflow/Parameters/Metadata",
|
||||
"{:p:}/workflow/Sku/Plan/Name", "{:p:}/workflow/Sku/Plan/Type", "{:p:}/workflow/IntegrationAccount/Name", "{:p:}/workflow/IntegrationAccount/Type",
|
||||
"{:r:}/Id", "{:r:}/Etag", "{:r:}/Type",
|
||||
"{:r:}/CreatedTime", "{:r:}/ChangedTime", "{:r:}/Sku/Plan/{:**:}", "{:r:}/IntegrationAccount/{:**:}", "{:r:}/Definition", "{:r:}/Parameters/Value", "{:r:}/Parameters/Metadata"
|
||||
],
|
||||
"flatten": [{
|
||||
"source": "{:p:}/workflow/Sku/{:**:}",
|
||||
"target": "/sku/"
|
||||
}, {
|
||||
"source": "{:r:}/Sku/{:**:}",
|
||||
"target": "/sku/"
|
||||
}, {
|
||||
"source": "{:p:}/workflow/Sku/Plan/Id",
|
||||
"target": "/sku/keyvault_id",
|
||||
"priority": "High"
|
||||
}, {
|
||||
"source": "{:p:}/workflow/IntegrationAccount/Id",
|
||||
"target": "/integration_account/keyvault_id",
|
||||
"priority": "High"
|
||||
}, {
|
||||
"source": "{:**:}",
|
||||
"target": "/",
|
||||
"priority": "Lowest"
|
||||
}]
|
||||
},
|
||||
"setId": true
|
||||
}],
|
||||
"read": [{
|
||||
"method": "LogicManagementClient/Workflows/Get",
|
||||
"schema": {
|
||||
"ignore": [
|
||||
"{:p:}/apiVersion", "{:p:}/subscriptionId", "{:p:}/Id", "{:p:}/Type", "{:r:}/Id", "{:r:}/Etag", "{:r:}/Type", "{:r:}/CreatedTime", "{:r:}/ChangedTime", "{:r:}/Sku/{:**:}", "{:r:}/Definition", "{:r:}/Parameters/Value", "{:r:}/Parameters/Metadata"
|
||||
],
|
||||
"flatten": [{
|
||||
"source": "{:p:}/workflow/Sku/{:**:}",
|
||||
"target": "/sku/"
|
||||
}, {
|
||||
"source": "{:**:}",
|
||||
"target": "/",
|
||||
"priority": "Lowest"
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"update": [{
|
||||
"method": "LogicManagementClient/Workflows/CreateOrUpdate",
|
||||
"schema": {
|
||||
"ignore": [
|
||||
"{:p:}/apiVersion", "{:p:}/subscriptionId", "{:p:}/Id", "{:p:}/Type",
|
||||
"{:p:}/workflow/CreatedTime", "{:p:}/workflow/ChangedTime", "{:p:}/workflow/Definition", "{:p:}/workflow/Parameters/Value", "{:p:}/workflow/Parameters/Metadata",
|
||||
"{:p:}/workflow/Sku/Plan/Name", "{:p:}/workflow/Sku/Plan/Type", "{:p:}/workflow/IntegrationAccount/Name", "{:p:}/workflow/IntegrationAccount/Type",
|
||||
"{:r:}/Id", "{:r:}/Etag", "{:r:}/Type",
|
||||
"{:r:}/CreatedTime", "{:r:}/ChangedTime", "{:r:}/Sku/Plan/{:**:}", "{:r:}/IntegrationAccount/{:**:}", "{:r:}/Definition", "{:r:}/Parameters/Value", "{:r:}/Parameters/Metadata"
|
||||
],
|
||||
"flatten": [{
|
||||
"source": "{:p:}/workflow/Sku/{:**:}",
|
||||
"target": "/sku/"
|
||||
}, {
|
||||
"source": "{:r:}/Sku/{:**:}",
|
||||
"target": "/sku/"
|
||||
}, {
|
||||
"source": "{:p:}/workflow/Sku/Plan/Id",
|
||||
"target": "/sku/keyvault_id",
|
||||
"priority": "High"
|
||||
}, {
|
||||
"source": "{:p:}/workflow/IntegrationAccount/Id",
|
||||
"target": "/integration_account/keyvault_id",
|
||||
"priority": "High"
|
||||
}, {
|
||||
"source": "{:**:}",
|
||||
"target": "/",
|
||||
"priority": "Lowest"
|
||||
}]
|
||||
}
|
||||
}],
|
||||
"delete": [{
|
||||
"method": "LogicManagementClient/Workflows/Delete",
|
||||
"schema": {
|
||||
"ignore": ["{:p:}/apiVersion", "{:p:}/subscriptionId"],
|
||||
"flatten": [{
|
||||
"source": "{:**:}",
|
||||
"target": "/",
|
||||
"priority": "Lowest"
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -48,7 +48,7 @@
|
|||
{
|
||||
fieldVarName = "tmpRespOf" + GetNonTerminalBaseVariableName();
|
||||
@:@(Indentation)@(fieldVarName) := make(map[string]interface{})
|
||||
Model.FieldDefs.Peek().Add(Model.Data.BackingField.PropertyPath, fieldVarName);
|
||||
Model.FieldDefs.Peek().TryAdd(Model.Data.BackingField.PropertyPath, fieldVarName);
|
||||
}
|
||||
foreach (var prop in Model.Data.Properties)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@
|
|||
|
||||
Indentation.Indent();
|
||||
Model.FieldDefs.Push(new Dictionary<string, string>());
|
||||
Model.FieldDefs.Peek().Add(Model.Data.BackingField.PropertyPath, valVarName);
|
||||
Model.FieldDefs.Peek().TryAdd(Model.Data.BackingField.PropertyPath, valVarName);
|
||||
if (!valueType.IsSimple)
|
||||
{
|
||||
if (!valueType.Chain.Any())
|
||||
|
|
|
@ -2,6 +2,7 @@ using AutoRest.Core.Utilities;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using static AutoRest.Terraform.TfProviderMetadata;
|
||||
|
||||
namespace AutoRest.Terraform
|
||||
{
|
||||
|
@ -25,10 +26,10 @@ namespace AutoRest.Terraform
|
|||
private void SetupRules()
|
||||
{
|
||||
RenameRules.Clear();
|
||||
RenameRules.AddRange(from r in Settings.Metadata.SDKTunings.Renames
|
||||
RenameRules.AddRange(from r in Settings.Metadata.SDKTunings?.Renames ?? Enumerable.Empty<SDKRenameDefinition>()
|
||||
select (r.SourcePath.ToPropertyPathRegex(), r.TargetName));
|
||||
TypeRedefineRules.Clear();
|
||||
TypeRedefineRules.AddRange(from t in Settings.Metadata.SDKTunings.TypeDefinitions
|
||||
TypeRedefineRules.AddRange(from t in Settings.Metadata.SDKTunings?.TypeDefinitions ?? Enumerable.Empty<SDKTypeDefinition>()
|
||||
let pattern = t.FieldPath.ToPropertyPathRegex()
|
||||
select (pattern, GoSDKTypeChain.Parse(t.TargetType), GoSDKTypeChain.Parse(t.GenerateType)));
|
||||
}
|
||||
|
|
|
@ -27,48 +27,50 @@ namespace AutoRest.Terraform
|
|||
|
||||
private static void AppendDisplayString(this Method method, IndentedStringBuilder builder)
|
||||
{
|
||||
var displayedTypes = new HashSet<string>();
|
||||
|
||||
builder.AppendLine($"{method.Flavor} {method.Qualifier} \"{method.Name}\"; Transformations [{method.InputParameterTransformation.Count}]; Parameters [{method.Parameters.Count}]; Responses [{method.Responses.Count}]");
|
||||
builder.Indent();
|
||||
method.Parameters.ForEach(p => p.AppendDisplayString(builder));
|
||||
method.Parameters.ForEach(p => p.AppendDisplayString(builder, displayedTypes));
|
||||
builder.Outdent();
|
||||
|
||||
builder.Indent();
|
||||
method.Responses.ForEach(r => r.Value.AppendDisplayString(builder, r.Key));
|
||||
method.Responses.ForEach(r => r.Value.AppendDisplayString(builder, r.Key, displayedTypes));
|
||||
builder.Outdent();
|
||||
}
|
||||
|
||||
private static void AppendDisplayString(this Parameter parameter, IndentedStringBuilder builder)
|
||||
private static void AppendDisplayString(this Parameter parameter, IndentedStringBuilder builder, ISet<string> displayedTypes)
|
||||
{
|
||||
builder.AppendLine($"{parameter.Location} {parameter.Qualifier} \"{parameter.GetClientName()}\"; " +
|
||||
$"Type: {parameter.ModelType.ToSummaryString()}; {(parameter.IsRequired ? "Required" : "Optional")}");
|
||||
builder.Indent();
|
||||
parameter.ModelType.AppendDisplayString(builder);
|
||||
parameter.ModelType.AppendDisplayString(builder, displayedTypes);
|
||||
builder.Outdent();
|
||||
}
|
||||
|
||||
private static void AppendDisplayString(this Response response, IndentedStringBuilder builder, HttpStatusCode status)
|
||||
private static void AppendDisplayString(this Response response, IndentedStringBuilder builder, HttpStatusCode status, ISet<string> displayedTypes)
|
||||
{
|
||||
var name = $"HTTP {status} ({(int)status})";
|
||||
builder.AppendLine($"Response \"HTTP {status} ({(int)status})\" Header: {response.Headers?.ToSummaryString() ?? "None"}, Body: {response.Body?.ToSummaryString() ?? "None"}");
|
||||
builder.Indent();
|
||||
response.Headers?.AppendDisplayString(builder);
|
||||
response.Body?.AppendDisplayString(builder);
|
||||
response.Headers?.AppendDisplayString(builder, displayedTypes);
|
||||
response.Body?.AppendDisplayString(builder, displayedTypes);
|
||||
builder.Outdent();
|
||||
}
|
||||
|
||||
private static void AppendDisplayString(this CompositeType composite, IndentedStringBuilder builder)
|
||||
private static void AppendDisplayString(this CompositeType composite, IndentedStringBuilder builder, ISet<string> displayedTypes)
|
||||
{
|
||||
var propertiesSet = new HashSet<Property>(composite.Properties);
|
||||
composite.Properties.ForEach(p => p.AppendDisplayString(builder));
|
||||
composite.ComposedProperties.Where(p => !propertiesSet.Contains(p)).ForEach(p => p.AppendDisplayString(builder, true));
|
||||
composite.Properties.ForEach(p => p.AppendDisplayString(builder, displayedTypes));
|
||||
composite.ComposedProperties.Where(p => !propertiesSet.Contains(p)).ForEach(p => p.AppendDisplayString(builder, displayedTypes, true));
|
||||
}
|
||||
|
||||
private static void AppendDisplayString(this Property property, IndentedStringBuilder builder, bool isComposed = false)
|
||||
private static void AppendDisplayString(this Property property, IndentedStringBuilder builder, ISet<string> displayedTypes, bool isComposed = false)
|
||||
{
|
||||
builder.AppendLine($"{(isComposed ? "Composed " : string.Empty)}{property.Qualifier} \"{property.GetClientName()}\"; " +
|
||||
$"Type: {property.ModelType.ToSummaryString()}; {(property.IsRequired ? "Required" : "Optional")}");
|
||||
builder.Indent();
|
||||
property.ModelType.AppendDisplayString(builder);
|
||||
property.ModelType.AppendDisplayString(builder, displayedTypes);
|
||||
builder.Outdent();
|
||||
}
|
||||
|
||||
|
@ -87,25 +89,29 @@ namespace AutoRest.Terraform
|
|||
}
|
||||
}
|
||||
|
||||
private static void AppendDisplayString(this IModelType type, IndentedStringBuilder builder)
|
||||
private static void AppendDisplayString(this IModelType type, IndentedStringBuilder builder, ISet<string> displayedTypes)
|
||||
{
|
||||
switch (type)
|
||||
if (!displayedTypes.Contains(type.Name))
|
||||
{
|
||||
case PrimaryType p:
|
||||
case EnumType e:
|
||||
break;
|
||||
case CompositeType composite:
|
||||
composite.AppendDisplayString(builder);
|
||||
break;
|
||||
case SequenceType sequence:
|
||||
sequence.ElementType.AppendDisplayString(builder);
|
||||
break;
|
||||
case DictionaryType dictionary:
|
||||
dictionary.ValueType.AppendDisplayString(builder);
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine("UNKNOWN TYPE");
|
||||
break;
|
||||
displayedTypes.Add(type.Name);
|
||||
switch (type)
|
||||
{
|
||||
case PrimaryType p:
|
||||
case EnumType e:
|
||||
break;
|
||||
case CompositeType composite:
|
||||
composite.AppendDisplayString(builder, displayedTypes);
|
||||
break;
|
||||
case SequenceType sequence:
|
||||
sequence.ElementType.AppendDisplayString(builder, displayedTypes);
|
||||
break;
|
||||
case DictionaryType dictionary:
|
||||
dictionary.ValueType.AppendDisplayString(builder, displayedTypes);
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine("UNKNOWN TYPE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче