Skip to content

Commit

Permalink
initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheumann committed Feb 13, 2023
1 parent bcf78da commit b426614
Show file tree
Hide file tree
Showing 14 changed files with 535 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

bin/
obj/
*.glb
output.json
input.json
.vs/
server/
test/Generated/
62 changes: 62 additions & 0 deletions JSONInspector.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONInspector", "src\JSONInspector.csproj", "{12FE4301-D08F-4CE7-9E59-29BC301716BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONInspector.Dependencies", "dependencies\JSONInspector.Dependencies.csproj", "{3C52634B-E933-4382-BF96-61E0E1A23A13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONInspector.Tests", "test\JSONInspector.Tests.csproj", "{DA87AD52-EE47-4554-BA3F-302B358B4B00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|x64.ActiveCfg = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|x64.Build.0 = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|x86.ActiveCfg = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Debug|x86.Build.0 = Debug|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|Any CPU.Build.0 = Release|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|x64.ActiveCfg = Release|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|x64.Build.0 = Release|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|x86.ActiveCfg = Release|Any CPU
{12FE4301-D08F-4CE7-9E59-29BC301716BC}.Release|x86.Build.0 = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|x64.ActiveCfg = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|x64.Build.0 = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|x86.ActiveCfg = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Debug|x86.Build.0 = Debug|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|Any CPU.Build.0 = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|x64.ActiveCfg = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|x64.Build.0 = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|x86.ActiveCfg = Release|Any CPU
{3C52634B-E933-4382-BF96-61E0E1A23A13}.Release|x86.Build.0 = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|x64.ActiveCfg = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|x64.Build.0 = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Debug|x86.Build.0 = Debug|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|Any CPU.Build.0 = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|x64.ActiveCfg = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|x64.Build.0 = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|x86.ActiveCfg = Release|Any CPU
{DA87AD52-EE47-4554-BA3F-302B358B4B00}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


# JSON Inspector

The JSONInspector function.

|Input Name|Type|Description|
|---|---|---|
|JSON|string||


<br>

|Output Name|Type|Description|
|---|---|---|


<br>

## Additional Information









12 changes: 12 additions & 0 deletions dependencies/GenericElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Elements;
using System;
using System.Linq;
using System.Collections.Generic;
using Elements.Geometry;
namespace Elements
{
public class GenericElement : Element
{
public string discriminator { get; set; }
}
}
12 changes: 12 additions & 0 deletions dependencies/JSONInspector.Dependencies.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="1.4.0" />
<PackageReference Include="Hypar.Functions" Version="1.4.0" />
</ItemGroup>

</Project>
53 changes: 53 additions & 0 deletions dependencies/JSONInspectorInputs.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This code was generated by Hypar.
// Edits to this code will be overwritten the next time you run 'hypar init'.
// DO NOT EDIT THIS FILE.

using Elements;
using Elements.GeoJSON;
using Elements.Geometry;
using Elements.Geometry.Solids;
using Elements.Validators;
using Elements.Serialization.JSON;
using Hypar.Functions;
using Hypar.Functions.Execution;
using Hypar.Functions.Execution.AWS;
using Hypar.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using Line = Elements.Geometry.Line;
using Polygon = Elements.Geometry.Polygon;

namespace JSONInspector
{
#pragma warning disable // Disable all warnings

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v12.0.0.0)")]

public class JSONInspectorInputs : S3Args

{
[Newtonsoft.Json.JsonConstructor]

public JSONInspectorInputs(string @jSON, string bucketName, string uploadsBucket, Dictionary<string, string> modelInputKeys, string gltfKey, string elementsKey, string ifcKey):
base(bucketName, uploadsBucket, modelInputKeys, gltfKey, elementsKey, ifcKey)
{
var validator = Validator.Instance.GetFirstValidatorForType<JSONInspectorInputs>();
if(validator != null)
{
validator.PreConstruct(new object[]{ @jSON});
}

this.JSON = @jSON;

if(validator != null)
{
validator.PostConstruct(this);
}
}

[Newtonsoft.Json.JsonProperty("JSON", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string JSON { get; set; }

}
}
32 changes: 32 additions & 0 deletions dependencies/JSONInspectorOutputs.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This code was generated by Hypar.
// Edits to this code will be overwritten the next time you run 'hypar init'.
// DO NOT EDIT THIS FILE.

using Elements;
using Elements.GeoJSON;
using Elements.Geometry;
using Hypar.Functions;
using Hypar.Functions.Execution;
using Hypar.Functions.Execution.AWS;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;

namespace JSONInspector
{
public class JSONInspectorOutputs: SystemResults
{


/// <summary>
/// Construct a JSONInspectorOutputs with default inputs.
/// This should be used for testing only.
/// </summary>
public JSONInspectorOutputs() : base()
{

}


}
}
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"sdk": {
"version": "3.1.100",
"rollForward": "latestMinor"
}
}
19 changes: 19 additions & 0 deletions hypar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://hypar.io/Schemas/Function.json",
"id": "b728b3a9-9518-49b0-923d-15096a053adb",
"name": "JSON Inspector",
"description": "The JSONInspector function.",
"language": "C#",
"input_schema": {
"type": "object",
"properties": {
"JSON": {
"type": "string",
"$hyparStyle": "multiline"
}
}
},
"repository_url": "https://github.com/hypar-io/function",
"last_updated": "0001-01-01T00:00:00",
"cli_version": "1.5.0-alpha.1"
}
73 changes: 73 additions & 0 deletions src/Function.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// This code was generated by Hypar.
// Edits to this code will be overwritten the next time you run 'hypar init'.
// DO NOT EDIT THIS FILE.

using Amazon;
using Amazon.Lambda.Core;
using Hypar.Functions.Execution;
using Hypar.Functions.Execution.AWS;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace JSONInspector
{
public class Function
{
// Cache the model store for use by subsequent
// executions of this lambda.
private IModelStore<JSONInspectorInputs> store;

public async Task<JSONInspectorOutputs> Handler(JSONInspectorInputs args, ILambdaContext context)
{
// Preload dependencies (if they exist),
// so that they are available during model deserialization.

var sw = System.Diagnostics.Stopwatch.StartNew();
var asmLocation = this.GetType().Assembly.Location;
var asmDir = Path.GetDirectoryName(asmLocation);

// Explicitly load the dependencies project, it might have types
// that aren't used in the function but are necessary for correct
// deserialization.
var asmName = Path.GetFileNameWithoutExtension(asmLocation);
var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");
if(File.Exists(depPath))
{
Console.WriteLine($"Loading dependencies assembly from: {depPath}...");
Assembly.LoadFrom(depPath);
Console.WriteLine("Dependencies assembly loaded.");
}

// Load all reference assemblies.
Console.WriteLine($"Loading all referenced assemblies.");
foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies())
{
try
{
Console.WriteLine($"Assembly Name: {asm.FullName}");
Assembly.Load(asm);
}
catch (Exception e)
{
Console.WriteLine($"Failed to load {asm.FullName}");
Console.WriteLine(e.Message);
}
}
sw.Stop();
Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

if(this.store == null)
{
this.store = new S3ModelStore<JSONInspectorInputs>(RegionEndpoint.GetBySystemName("us-west-1"));
}

var l = new InvocationWrapper<JSONInspectorInputs,JSONInspectorOutputs>(store, JSONInspector.Execute);
var output = await l.InvokeAsync(args);
return output;
}
}
}
Loading

0 comments on commit b426614

Please sign in to comment.