Commit 3b789f7b authored by Matija Obreza's avatar Matija Obreza

Initial code

parents
# Ref: https://gist.github.com/kmorcinek/2710267
# Download this file using PowerShell v3 under Windows with the following comand
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
# User-specific files
*.suo
*.user
*.sln.docstates
./nuget
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# OS generated files #
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
modulesbin/
tempbin/
# EPiServer Site file (VPP)
AppData/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# vim
*.txt~
*.swp
*.swo
# svn
.svn
# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac desktop service store files
.DS_Store
# SASS Compiler cache
.sass-cache
# Visual Studio 2014 CTP
**/*.sln.ide
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
4.2.3
\ No newline at end of file
162e08504a7856caaed5309f3ba00b146d189fbe79a5ecc7ebadd37588698813
\ No newline at end of file
#
# Generated by: https://github.com/openapitools/openapi-generator.git
#
language: csharp
mono:
- latest
solution: GRINGlobal.Client.sln
script:
- /bin/sh ./mono_nunit_test.sh
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2C55A4E5-BF3B-492A-A549-094434697895}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Example.Example</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\GRINGlobal.Client\GRINGlobal.Client.csproj">
<Project>{5b451c3c-c1b1-49c5-b34e-719ac91962ba}</Project>
<Name>GRINGlobal.Client</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using GRINGlobal.Client.Api;
using GRINGlobal.Client.Client;
using GRINGlobal.Client.Model;
using RestSharp;
using Newtonsoft.Json;
namespace Example
{
public class Example
{
public static void Main()
{
Configuration.Default.BasePath = "http://192.168.99.1:8080";
ApiClient client = Configuration.Default.ApiClient;
client.RestClient.Authenticator = new JWTAuthenticator(client); // implements IAuthenticator
Configuration.Default.AccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODI2NTUyMzEsInVzZXJfbmFtZSI6ImFkbWluaXN0cmF0b3IiLCJhdXRob3JpdGllcyI6WyJBRE1JTlMiLCJDVFVTRVJTIiwiQUxMVVNFUlMiLCJ3ZWJ0b29scyJdLCJqdGkiOiI4NmNhZDNhYi1jYjZiLTQ5MDMtOGFmNy1jYjNjYTBhZTNkMTUiLCJjbGllbnRfaWQiOiJkZWZhdWx0Y2xpZW50QGxvY2FsaG9zdCIsInNjb3BlIjpbInJlYWQiXX0.sskzAd7FFAfpWftwIJU2ZQRGDiR9Wrjm_Ym3PX1yyd0";
// Configuration.Default.AccessToken = "";
if (Configuration.Default.AccessToken == null || Configuration.Default.AccessToken == "")
{
Console.Out.WriteLine(Configuration.Default.BasePath + "/oauth/authorize?client_id=defaultclient@localhost&scope=read&redirect_url=oob&response_type=code");
string verifierCode = Console.In.ReadLine();
string tokenUrl = Configuration.Default.BasePath + "/oauth/token?grant_type=authorization_code&client_id=defaultclient@localhost&client_secret=changeme&redirect_uri=oob&code=" + verifierCode;
var request = new RestRequest("/oauth/token", RestSharp.Method.POST);
request.AddParameter("grant_type", "authorization_code");
request.AddParameter("client_id", "defaultclient@localhost");
request.AddParameter("client_secret", "changeme");
request.AddParameter("redirect_uri", "oob");
request.AddParameter("code", verifierCode);
var response = client.RestClient.Post(request);
Debug.Write(response.Content);
var tokens = JsonConvert.DeserializeObject(response.Content);
Debug.Write(tokens);
}
// Configuration.Default.AddDefaultHeader("Origin", "https://sandbox.genesys-pgr.org");
var apiInstance = new AccessionApi(Configuration.Default);
var apiTaxonomy = new TaxonomyApi(Configuration.Default);
var instCode = "BEL084"; // string | instCode
// var batch = new List<AccessionHeaderJson>(); // List<AccessionHeaderJson> | batch
try
{
var speciesFilter = new InlineObject2();
var taxonomyFamily = apiTaxonomy.GetFamily(43255);//.FilterSpecies(null, speciesFilter);
Debug.WriteLine(taxonomyFamily);
var speciesList = apiTaxonomy.FilterSpecies(null, speciesFilter);
Debug.WriteLine(speciesList);
foreach (var i in speciesList.Content)
{
Debug.WriteLine(i);
}
}
catch (ApiException e)
{
Debug.Print("Exception when calling: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
if (e.ErrorContent != null)
{
Debug.Print("Content: " + ((object)e.ErrorContent).ToString());
}
Debug.Print("Status Content: " + e.Data);
Debug.Print(e.StackTrace);
}
}
}
internal class JWTAuthenticator : IAuthenticator
{
private ApiClient client;
public JWTAuthenticator(ApiClient client)
{
this.client = client;
}
public void Authenticate(IRestClient restClient, IRestRequest request)
{
request.AddHeader("Authorization", "Bearer " + client.Configuration.AccessToken);
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApplication1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication1")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2c55a4e5-bf3b-492a-a549-094434697895")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" />
<package id="RestSharp" version="105.1.0" targetFramework="net452" />
</packages>
\ No newline at end of file
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GRINGlobal.Client", "src\GRINGlobal.Client\GRINGlobal.Client.csproj", "{DC5B00A0-0AC2-4035-BFE6-B9D27C205BFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GRINGlobal.Client.Test", "src\GRINGlobal.Client.Test\GRINGlobal.Client.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{2C55A4E5-BF3B-492A-A549-094434697895}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DC5B00A0-0AC2-4035-BFE6-B9D27C205BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC5B00A0-0AC2-4035-BFE6-B9D27C205BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC5B00A0-0AC2-4035-BFE6-B9D27C205BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC5B00A0-0AC2-4035-BFE6-B9D27C205BFF}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
{2C55A4E5-BF3B-492A-A549-094434697895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C55A4E5-BF3B-492A-A549-094434697895}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C55A4E5-BF3B-492A-A549-094434697895}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C55A4E5-BF3B-492A-A549-094434697895}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
# GRINGlobal.Client - the C# library for the GRIN-Global CE API
GG-CE API
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 0.0.1-SNAPSHOT
- SDK version: 1.0.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
For more information, please visit [https://www.grin-global.org](https://www.grin-global.org)
## Frameworks supported
- .NET 4.0 or later
- Windows Phone 7.1 (Mango)
## Dependencies
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.2.0 or later
The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
```
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
```
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)
## Installation
Run the following command to generate the DLL
- [Mac/Linux] `/bin/sh build.sh`
- [Windows] `build.bat`
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
```csharp
using GRINGlobal.Client.Api;
using GRINGlobal.Client.Client;
using GRINGlobal.Client.Model;
```
## Packaging
A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages.
This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly:
```
nuget pack -Build -OutputDirectory out GRINGlobal.Client.csproj
```
Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual.
## Getting Started
```csharp
using System.Collections.Generic;
using System.Diagnostics;
using GRINGlobal.Client.Api;
using GRINGlobal.Client.Client;
using GRINGlobal.Client.Model;
namespace Example
{