Skip to content

lab5e/csharp-spanapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Com.Lab5e.Span - the C# library for the The Span API

API for device, collection, output and firmware management

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 5.0.3 pitch-dark-elza
  • SDK version: 5.0.3
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://lab5e.com

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

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:

using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out Com.Lab5e.Span.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

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

            Configuration config = new Configuration();
            config.BasePath = "https://api.lab5e.com";
            // Configure API key authorization: APIToken
            config.ApiKey.Add("X-API-Token", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("X-API-Token", "Bearer");

            var apiInstance = new BlobsApi(config);
            var collectionId = "collectionId_example";  // string | 
            var blobId = "blobId_example";  // string | 

            try
            {
                // Remove a blob stored on a collection
                Object result = apiInstance.DeleteBlob(collectionId, blobId);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling BlobsApi.DeleteBlob: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.lab5e.com

Class Method HTTP request Description
BlobsApi DeleteBlob DELETE /span/collections/{collectionId}/blobs/{blobId} Remove a blob stored on a collection
BlobsApi ListBlobs GET /span/collections/{collectionId}/blobs List the blobs for a collection
CertificatesApi CreateCertificate POST /span/collections/{collectionId}/certificates/create Create certificate
CertificatesApi RetrieveCertificateChain GET /span/collections/{collectionId}/certificates Get certificate chain
CertificatesApi SignCertificate POST /span/collections/{collectionId}/certificates/sign Sign certificate
CertificatesApi VerifyCertificate POST /span/collections/{collectionId}/certificates/verify Verify certificate
CollectionsApi CreateCollection POST /span/collections Create collection
CollectionsApi DeleteCollection DELETE /span/collections/{collectionId} Delete collection
CollectionsApi ListCollectionData GET /span/collections/{collectionId}/data Retrieve data from devices
CollectionsApi ListCollections GET /span/collections List collections
CollectionsApi RetrieveCollection GET /span/collections/{collectionId} Retrieve collection
CollectionsApi RetrieveCollectionStats GET /span/collections/{collectionId}/stats Retrieve collection statistics
CollectionsApi UpdateCollection PATCH /span/collections/{collectionId} Update collection
DevicesApi AddDownstreamMessage POST /span/collections/{collectionId}/devices/{deviceId}/outbox Add message to oubox
DevicesApi CreateDevice POST /span/collections/{collectionId}/devices Create device
DevicesApi DeleteDevice DELETE /span/collections/{collectionId}/devices/{deviceId} Remove device.
DevicesApi DeleteDownstreamMessage DELETE /span/collections/{collectionId}/devices/{deviceId}/outbox/{messageId} Delete outgoing message
DevicesApi DeviceCertificate GET /span/collections/{collectionId}/devices/{deviceId}/certs Get issued certificate(s) for device
DevicesApi ListDeviceData GET /span/collections/{collectionId}/devices/{deviceId}/data Retrieve data from device
DevicesApi ListDevices GET /span/collections/{collectionId}/devices List devices in collection.
DevicesApi ListDownstreamMessages GET /span/collections/{collectionId}/devices/{deviceId}/outbox List the messages in the outbox
DevicesApi ListUpstreamMessages GET /span/collections/{collectionId}/devices/{deviceId}/inbox List incoming messages
DevicesApi RetrieveDevice GET /span/collections/{collectionId}/devices/{deviceId} Retrieve device
DevicesApi RetrieveDeviceStats GET /span/collections/{collectionId}/devices/{deviceId}/stats Retrieve device statistics
DevicesApi UpdateDevice PATCH /span/collections/{existingCollectionId}/devices/{deviceId} Update device
FotaApi ClearFirmwareError DELETE /span/collections/{collectionId}/devices/{deviceId}/fwerror Clear FOTA error
FotaApi CreateFirmware POST /span/collections/{collectionId}/firmware Create firmware
FotaApi DeleteFirmware DELETE /span/collections/{collectionId}/firmware/{imageId} Delete firmware
FotaApi FirmwareUsage GET /span/collections/{collectionId}/firmware/{imageId}/usage Firmware usage
FotaApi ListFirmware GET /span/collections/{collectionId}/firmware List firmware
FotaApi RetrieveFirmware GET /span/collections/{collectionId}/firmware/{imageId} Retrieve firmware
FotaApi RetrieveFirmwareStats GET /span/collections/{collectionId}/firmware/{imageId}/stats Retrieve firmware statistics
FotaApi UpdateFirmware PATCH /span/collections/{existingCollectionId}/firmware/{imageId} Update firmware
GatewaysApi CreateGateway POST /span/collections/{collectionId}/gateways Create gateway
GatewaysApi DeleteGateway DELETE /span/collections/{collectionId}/gateways/{gatewayId} Delete gateway
GatewaysApi GatewayCertificates GET /span/collections/{collectionId}/gateways/{gatewayId}/certs Get issued certificate(s) for gateway
GatewaysApi ListGateways GET /span/collections/{collectionId}/gateways List gateways
GatewaysApi RetrieveGateway GET /span/collections/{collectionId}/gateways/{gatewayId} Retrieve gateway
GatewaysApi RetrieveGatewayStats GET /span/collections/{collectionId}/gateways/{gatewayId}/stats Retrieve gateway statistics
GatewaysApi UpdateGateway PATCH /span/collections/{existingCollectionId}/gateways/{gatewayId} Update gateway
OutputsApi CreateOutput POST /span/collections/{collectionId}/outputs Create output
OutputsApi DeleteOutput DELETE /span/collections/{collectionId}/outputs/{outputId} Delete output
OutputsApi ListOutputs GET /span/collections/{collectionId}/outputs List outputs
OutputsApi Logs GET /span/collections/{collectionId}/outputs/{outputId}/logs Output logs
OutputsApi RetrieveOutput GET /span/collections/{collectionId}/outputs/{outputId} Retrieve output
OutputsApi RetrieveOutputStats GET /span/collections/{collectionId}/outputs/{outputId}/stats Retrieve output statistics
OutputsApi Status GET /span/collections/{collectionId}/outputs/{outputId}/status Output status
OutputsApi UpdateOutput PATCH /span/collections/{existingCollectionId}/outputs/{outputId} Update output
SpanApi GetSystemInfo GET /span/system System information

Documentation for Models

Documentation for Authorization

APIToken

  • Type: API key
  • API key parameter name: X-API-Token
  • Location: HTTP header

Packages

No packages published

Languages