An open API service indexing awesome lists of open source software.

https://github.com/4players/fleet-sdk-csharp

C# SDK for ODIN Fleet
https://github.com/4players/fleet-sdk-csharp

Last synced: about 2 months ago
JSON representation

C# SDK for ODIN Fleet

Awesome Lists containing this project

README

        

# OdinFleet - a C# library to access the ODIN Fleet API

Introducing the **ODIN Fleet API** by 4Players, enabling developers to deploy game servers globally with just a few lines of
code. [ODIN Fleet](https://odin.4players.io/fleet/), the technology behind 4Netplayers, now empowers developers and publishers to manage their own server
fleets effortlessly. Our streamlined API makes it easy to deploy and manage game servers worldwide. You can find further
technical information on ODIN Fleet in our [developer documentation](https://docs.4players.io/fleet/).

This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project based on our
API specification that can be found [here](https://api.4np.4players.de/b2b/v1/docs/api#/).

For an easier point of entry we have created a simple wrapper `OdinFleetClient` that sets up the correct configuration
and provides a simple interface to the API. If you want to use the API directly, you can use the `OdinFleetApi` class, but
you need to set up the configuration yourself - see the code in `OdinFleetClient` how to set the api token and base path.

## Changing the underlying http library

This API uses built-int httpclient, so you can use it with any .NET project. However, if you want to use the API within
Unity you need to use the `UnityWebRequest` class or a library like `RestSharp`. You can update the underlying
auto-generated code (and thus changing the http client) using the `generate.sh` script in the root of this repository.

In the script you'll find the openapi-generator-cli command that generates the code. You can change the `library` option
to `restsharp` or `unityWebRequest` to generate the code for those libraries. We suggest using the `OdinFleetClient`
wrapper as you don't need to change the code in your project even if you change the underlying http library.

## Getting an API Key

To use the Odin Fleet API, you need an API key. You can get one by signing up in our Console
at [https://console.4players.io](https://console.4players.io). Next
navigate to settings by clicking on profile image at the top right corner and then click on Settings. Navigate to
API-Keys and copy the key
automatically generated for you to get started using the API.

## Frameworks supported

- .NET Core >=1.0
- .NET Framework >=4.6
- Mono/Xamarin >=vNext

Please note, that the SDK is compatible with .NET 4.8 and above. If you need another version, please contact us.

## 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
```

## Installation

Generate the DLL using your preferred tool (e.g. `dotnet build`)

Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:

```csharp
using OdinFleet.Api;
using OdinFleet.Client;
using OdinFleet.Model;
```

## 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;
```

**Please note**: This code refers to the default `httpclient` used in this API per default. If you changed the underlying
http library, this code might not work. Please refer to the documentation of the library you are using (i.e. `RestSharp`
or `UnityWebRequest`).

## Getting Started

To get started easily we have created a simple Wrapper `OdinFleetClient` that sets up the correct configuration and
provides a simple interface to the API.
If you want to use the API directly, you can use the `OdinFleetApi` class, but you need to set up the configuration
yourself - see the code in `OdinFleetClient` how to set the api token and base path.

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

namespace Example
{
public class Example
{
public static void Main()
{
var apiInstance = new OdinFleetClient("__YOUR_API_TOKEN__");

try
{
// Create a list of apps
List apps = apiInstance.GetApps();

// Select the first app in the list so that subsequent calls can use it
App app = apps[0];
apiInstance.SelectApp(app.Id);

// Get all servers for the selected app
List servers = apiInstance.GetServers();

// Create a backup for the first server in the list
var result = client.CreateServerBackup(servers[0].Id, "My Backup");
if (result) {
Debug.Print("Backup created successfully");
}
else {
Debug.Print("Backup creation failed");
}
}
catch (ApiException e)
{
Debug.Print("Exception when calling OdinFleetApi.CreateApp: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}

}
}
}
```

## Documentation for API Endpoints

All URIs are relative to *http://b2b.api.4np.4players.de/api*

Class | Method | HTTP request | Description
----------------|-----------------------------------------------------------------------------------|--------------------------------------------------------|--------------------------------------------------------------------------------------------------
*OdinFleetApi* | [**CreateApp**](docs/OdinFleetApi.md#createapp) | **POST** /apps | Create an app
*OdinFleetApi* | [**CreateAppLocationSetting**](docs/OdinFleetApi.md#createapplocationsetting) | **POST** /apps/{app}/location-settings | Create a new location setting
*OdinFleetApi* | [**CreateBackup**](docs/OdinFleetApi.md#createbackup) | **POST** /services/{service}/backup | Creates a backup of the service
*OdinFleetApi* | [**CreateBinary**](docs/OdinFleetApi.md#createbinary) | **POST** /apps/{app}/binaries | Create a binary and the related file
*OdinFleetApi* | [**CreateDockerRegistry**](docs/OdinFleetApi.md#createdockerregistry) | **POST** /docker-registries | Create a new docker registry
*OdinFleetApi* | [**CreateServerConfig**](docs/OdinFleetApi.md#createserverconfig) | **POST** /apps/{app}/configs | Create a new server config
*OdinFleetApi* | [**DeleteApp**](docs/OdinFleetApi.md#deleteapp) | **DELETE** /apps/{app} | Delete a specific app
*OdinFleetApi* | [**DeleteAppLocationSetting**](docs/OdinFleetApi.md#deleteapplocationsetting) | **DELETE** /app-location-settings/{appLocationSetting} | Delete a location setting
*OdinFleetApi* | [**DeleteAuthToken**](docs/OdinFleetApi.md#deleteauthtoken) | **DELETE** /auth/token | Handles the deletion of a user's authentication tokens
*OdinFleetApi* | [**DeleteBinary**](docs/OdinFleetApi.md#deletebinary) | **DELETE** /binaries/{binary} | Delete a specified binary
*OdinFleetApi* | [**DeleteDockerRegistry**](docs/OdinFleetApi.md#deletedockerregistry) | **DELETE** /docker-registries/{dockerRegistry} | Delete a specific docker registry
*OdinFleetApi* | [**DeleteServerConfig**](docs/OdinFleetApi.md#deleteserverconfig) | **DELETE** /server-configs/{serverConfig} | Delete a specific server config
*OdinFleetApi* | [**GetAppById**](docs/OdinFleetApi.md#getappbyid) | **GET** /apps/{app} | Show a specific app
*OdinFleetApi* | [**GetAppLocationSettings**](docs/OdinFleetApi.md#getapplocationsettings) | **GET** /apps/{app}/location-settings | Show all location settings
*OdinFleetApi* | [**GetApps**](docs/OdinFleetApi.md#getapps) | **GET** /apps | Show all apps
*OdinFleetApi* | [**GetAuthToken**](docs/OdinFleetApi.md#getauthtoken) | **POST** /auth/token | Handles user authentication
*OdinFleetApi* | [**GetBackups**](docs/OdinFleetApi.md#getbackups) | **GET** /services/{service}/backups | List all backups for the specified Docker service
*OdinFleetApi* | [**GetBinaries**](docs/OdinFleetApi.md#getbinaries) | **GET** /apps/{app}/binaries | Show all binaries
*OdinFleetApi* | [**GetBinaryById**](docs/OdinFleetApi.md#getbinarybyid) | **GET** /binaries/{binary} | Show a specific binary
*OdinFleetApi* | [**GetDockerRegistries**](docs/OdinFleetApi.md#getdockerregistries) | **GET** /docker-registries | Show all docker registries
*OdinFleetApi* | [**GetDockerRegistryById**](docs/OdinFleetApi.md#getdockerregistrybyid) | **GET** /docker-registries/{dockerRegistry} | Display a specific docker registry
*OdinFleetApi* | [**GetLocations**](docs/OdinFleetApi.md#getlocations) | **GET** /nodes/locations | Show a unique listing of locations based on active and ready worker nodes
*OdinFleetApi* | [**GetMostRecentBackup**](docs/OdinFleetApi.md#getmostrecentbackup) | **GET** /services/{service}/backup | Display the most recent backup for the specified Docker service
*OdinFleetApi* | [**GetServerBackupDownloadUrl**](docs/OdinFleetApi.md#getserverbackupdownloadurl) | **GET** /services/{service}/backup/download | Generates a presigned URL for downloading a backup from AWS S3 if the backup method is 'archive'
*OdinFleetApi* | [**GetServerById**](docs/OdinFleetApi.md#getserverbyid) | **GET** /apps/{app}/services/{service} | Display a specific DockerService associated with the given App
*OdinFleetApi* | [**GetServerConfigById**](docs/OdinFleetApi.md#getserverconfigbyid) | **GET** /server-configs/{serverConfig} | Show a specific server config
*OdinFleetApi* | [**GetServerConfigs**](docs/OdinFleetApi.md#getserverconfigs) | **GET** /apps/{app}/configs | Show all server configs
*OdinFleetApi* | [**GetServerLogs**](docs/OdinFleetApi.md#getserverlogs) | **GET** /services/{service}/logs | Get stdout and stderr logs from a service or task
*OdinFleetApi* | [**GetServers**](docs/OdinFleetApi.md#getservers) | **GET** /apps/{app}/services | Show all services for a given app
*OdinFleetApi* | [**RestartServer**](docs/OdinFleetApi.md#restartserver) | **POST** /services/{service}/restart | Restarts a specific Docker service
*OdinFleetApi* | [**RestoreBackup**](docs/OdinFleetApi.md#restorebackup) | **POST** /services/{service}/restore | Restore a backup for a specified Docker service
*OdinFleetApi* | [**UpdateAppLocationSetting**](docs/OdinFleetApi.md#updateapplocationsetting) | **PUT** /app-location-settings/{appLocationSetting} | Update a location setting
*OdinFleetApi* | [**UpdateBinary**](docs/OdinFleetApi.md#updatebinary) | **PUT** /binaries/{binary} | Update a binary and the related file
*OdinFleetApi* | [**UpdateDockerRegistry**](docs/OdinFleetApi.md#updatedockerregistry) | **PUT** /docker-registries/{dockerRegistry} | Update a specific docker registry
*OdinFleetApi* | [**UpdateServerConfig**](docs/OdinFleetApi.md#updateserverconfig) | **PUT** /server-configs/{serverConfig} | Update a server config

## Documentation for Models

- [Model.App](docs/App.md)
- [Model.AppLocationSetting](docs/AppLocationSetting.md)
- [Model.Auth](docs/Auth.md)
- [Model.Backup](docs/Backup.md)
- [Model.BackupDownload](docs/BackupDownload.md)
- [Model.BackupType](docs/BackupType.md)
- [Model.Binary](docs/Binary.md)
- [Model.BinaryType](docs/BinaryType.md)
- [Model.ConfigFile](docs/ConfigFile.md)
- [Model.ConfigTemplate](docs/ConfigTemplate.md)
- [Model.Constraints](docs/Constraints.md)
- [Model.CreateAppLocationSettingRequest](docs/CreateAppLocationSettingRequest.md)
- [Model.CreateAppRequest](docs/CreateAppRequest.md)
- [Model.CreateBackupRequest](docs/CreateBackupRequest.md)
- [Model.CreateBinaryRequest](docs/CreateBinaryRequest.md)
- [Model.CreateDockerImage](docs/CreateDockerImage.md)
- [Model.CreateDockerRegistryRequest](docs/CreateDockerRegistryRequest.md)
- [Model.CreateServerConfigRequest](docs/CreateServerConfigRequest.md)
- [Model.DockerCompose](docs/DockerCompose.md)
- [Model.DockerImage](docs/DockerImage.md)
- [Model.DockerRegistry](docs/DockerRegistry.md)
- [Model.DockerRegistryType](docs/DockerRegistryType.md)
- [Model.DockerTaskStatus](docs/DockerTaskStatus.md)
- [Model.EnvironmentVariable](docs/EnvironmentVariable.md)
- [Model.EnvironmentVariableDefinition](docs/EnvironmentVariableDefinition.md)
- [Model.EnvironmentVariableType](docs/EnvironmentVariableType.md)
- [Model.GetAuthTokenRequest](docs/GetAuthTokenRequest.md)
- [Model.GetServerLogs200Response](docs/GetServerLogs200Response.md)
- [Model.ImageStatus](docs/ImageStatus.md)
- [Model.Location](docs/Location.md)
- [Model.ModelOperatingSystem](docs/ModelOperatingSystem.md)
- [Model.Mount](docs/Mount.md)
- [Model.Placement](docs/Placement.md)
- [Model.Port](docs/Port.md)
- [Model.PortDefinition](docs/PortDefinition.md)
- [Model.Protocol](docs/Protocol.md)
- [Model.PublishMode](docs/PublishMode.md)
- [Model.ResourceAllocations](docs/ResourceAllocations.md)
- [Model.Resources](docs/Resources.md)
- [Model.RestartPolicy](docs/RestartPolicy.md)
- [Model.RestartPolicyCondition](docs/RestartPolicyCondition.md)
- [Model.Server](docs/Server.md)
- [Model.ServerConfig](docs/ServerConfig.md)
- [Model.SteamWorks](docs/SteamWorks.md)
- [Model.UpdateAppLocationSettingRequest](docs/UpdateAppLocationSettingRequest.md)
- [Model.UpdateBinaryRequest](docs/UpdateBinaryRequest.md)
- [Model.UpdateDockerRegistryRequest](docs/UpdateDockerRegistryRequest.md)
- [Model.ZipFile](docs/ZipFile.md)

## Documentation for Authorization

Endpoints do not require authorization.