Skip to content

Commit

Permalink
Merge pull request #6 from databox/release/0.3.15-sdk.2/1720094676654
Browse files Browse the repository at this point in the history
[SDK release] Generated SDK code based on data-link 0.3.15-sdk.2 API changes
  • Loading branch information
slavkor authored Jul 4, 2024
2 parents 53a9f72 + 1d2a1a8 commit 15a831b
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 5 deletions.
160 changes: 160 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Databox - the C# library for the Static OpenAPI document of Push API resource

Push API resources Open API documentation

This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.0
- SDK version: 0.0.2
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

<a id="frameworks-supported"></a>
## Frameworks supported

<a id="dependencies"></a>
## Dependencies

- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 13.0.2 or later
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.8.0 or later
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 5.0.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 Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations
```
<a id="installation"></a>
## 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 Databox.Api;
using Databox.Client;
using Databox.Model;
```
<a id="packaging"></a>
## 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 Databox.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.

<a id="usage"></a>
## Usage

To use the API client with a HTTP proxy, setup a `System.Net.WebProxy`
```csharp
Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
```

### Connections
Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method.

To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see [here](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net) for details). To use your own HttpClient instance just pass it to the ApiClass constructor.

```csharp
HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);
```

If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory.

```csharp
HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient);
```
You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available.

Here an example of DI setup in a sample web project:

```csharp
services.AddHttpClient<YourApiClass>(httpClient =>
new PetApi(httpClient));
```


<a id="getting-started"></a>
## Getting Started

```csharp
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using Databox.Api;
using Databox.Client;
using Databox.Model;

namespace Example
{
public class Example
{
public static void Main()
{

Configuration config = new Configuration();
config.BasePath = "http://localhost:8080/q/openapi";
// create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
HttpClient httpClient = new HttpClient();
HttpClientHandler httpClientHandler = new HttpClientHandler();
var apiInstance = new DefaultApi(httpClient, config, httpClientHandler);
var payloadModel = new PayloadModel?(); // PayloadModel? | (optional)
try
{
apiInstance.RootPost(payloadModel);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.RootPost: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}

}
}
}
```

<a id="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints

All URIs are relative to *http://localhost:8080/q/openapi*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**RootPost**](docs/DefaultApi.md#rootpost) | **POST** / |


<a id="documentation-for-models"></a>
## Documentation for Models

- [Model.ApiResponse](docs/ApiResponse.md)
- [Model.PayloadDataModel](docs/PayloadDataModel.md)
- [Model.PayloadModel](docs/PayloadModel.md)


<a id="documentation-for-authorization"></a>
## Documentation for Authorization


Authentication schemes defined for the API:
<a id="basicAuth"></a>
### basicAuth

- **Type**: HTTP basic authentication

10 changes: 5 additions & 5 deletions src/Databox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Databox", "src\Databox\Databox.csproj", "{C0B0E438-CB79-49E2-86F0-1153235518FE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Databox", "src\Databox\Databox.csproj", "{0DEDE14F-8852-43F9-AC99-C5304C96F2C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Databox.Test", "src\Databox.Test\Databox.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
Expand All @@ -12,10 +12,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0B0E438-CB79-49E2-86F0-1153235518FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0B0E438-CB79-49E2-86F0-1153235518FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0B0E438-CB79-49E2-86F0-1153235518FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0B0E438-CB79-49E2-86F0-1153235518FE}.Release|Any CPU.Build.0 = Release|Any CPU
{0DEDE14F-8852-43F9-AC99-C5304C96F2C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DEDE14F-8852-43F9-AC99-C5304C96F2C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DEDE14F-8852-43F9-AC99-C5304C96F2C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DEDE14F-8852-43F9-AC99-C5304C96F2C5}.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
Expand Down

0 comments on commit 15a831b

Please sign in to comment.