NBoomackClient
Show / Hide Table of Contents

Class BoomackClient

This class is the actual Boomack API client.

It is instantiated with a ClientConfiguration and features two groups of methods:

  1. API methods
  2. Low-level methods

The API methods represent all the HTTP routes of the Boomack API.

The low-level methods are the foundation for the API methods and you usually will not use them directly. However, in case the Boomack Server has evolved with some API routes, not supported by this library yet, the low-level methods might be a good way to access them without falling back to a bare HttpClient.

Inheritance
object
BoomackClient
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Boomack.Client
Assembly: NBoomackClient.dll
Syntax
public class BoomackClient : IDisposable

Constructors

BoomackClient()

Create a new client with the default configuration.

Declaration
public BoomackClient()

BoomackClient(ClientConfiguration)

Create a new client with the given configuration.

Declaration
public BoomackClient(ClientConfiguration config)
Parameters
Type Name Description
ClientConfiguration config

The configuration for the new client

Exceptions
Type Condition
System.ArgumentNullException

If the configuration is null.

Properties

Builder

The entry point for the fluent API for building a client.

Call the extension method BuildClient(IBoomackClientBuilder) to create the client from the builder.

Declaration
public static IBoomackClientBuilder Builder { get; }
Property Value
Type Description
IBoomackClientBuilder
Examples
    var client = BoomackClient.Builder
        .For("http://my-server:3000")
        .WithToken("<SECRET API TOKEN>")
        .BuildClient();

Methods

AddAction(string, BoomackAction)

Set the definition of a new action with the given ID.

Declaration
public Task<ApiResponse> AddAction(string id, BoomackAction action)
Parameters
Type Name Description
string id

The action ID

BoomackAction action

The action definition

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as UpdateAction(string, BoomackAction).

AddMediaType(string, MediaType)

Set the definition of a new media type with the given ID.

Declaration
public Task<ApiResponse> AddMediaType(string id, MediaType mediaType)
Parameters
Type Name Description
string id

The media type ID

MediaType mediaType

The media type definition

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as UpdateMediaType(string, MediaType).

AddPanel(string, PanelLayout)

Sets the layout of a new panel with the given ID.

Declaration
public Task<ApiResponse> AddPanel(string id, PanelLayout layout)
Parameters
Type Name Description
string id
PanelLayout layout
Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as SetPanelLayout(string, PanelLayout).

AddPreset(string, DisplayOptions)

Set the display options of a new preset with the given ID.

Declaration
public Task<ApiResponse> AddPreset(string id, DisplayOptions options)
Parameters
Type Name Description
string id

The preset ID

DisplayOptions options

The display options

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as UpdatePreset(string, DisplayOptions).

ClearPanel(string)

Send a clear request for a whole panel.

Declaration
public Task<ApiResponse> ClearPanel(string id)
Parameters
Type Name Description
string id

The panel ID

Returns
Type Description
Task<ApiResponse>

The API response

ClearSlot(string, string)

Send a clear request for an individual slot.

Declaration
public Task<ApiResponse> ClearSlot(string panelId, string slotId)
Parameters
Type Name Description
string panelId

The panel ID

string slotId

The slot ID

Returns
Type Description
Task<ApiResponse>

The API response

DeleteAction(string)

Remove an existing action from the server.

Declaration
public Task<ApiResponse> DeleteAction(string id)
Parameters
Type Name Description
string id

The action ID

Returns
Type Description
Task<ApiResponse>

The API response

DeleteMediaType(string)

Remove an existing media type from the server.

Declaration
public Task<ApiResponse> DeleteMediaType(string id)
Parameters
Type Name Description
string id

The media type ID

Returns
Type Description
Task<ApiResponse>

The API response

DeletePanel(string)

Remove an existing panel from the server.

Declaration
public Task<ApiResponse> DeletePanel(string id)
Parameters
Type Name Description
string id

The panel ID

Returns
Type Description
Task<ApiResponse>

The API response

DeletePreset(string)

Remove an existing preset from the server.

Declaration
public Task<ApiResponse> DeletePreset(string id)
Parameters
Type Name Description
string id

The preset ID

Returns
Type Description
Task<ApiResponse>

The API response

DeleteRequest(string)

Low-level method for a DELETE request to the Boomack HTTP API.

Declaration
public Task<ApiResponse> DeleteRequest(string route)
Parameters
Type Name Description
string route

The API route

Returns
Type Description
Task<ApiResponse>

The response object

DeserializeFromJson<T>(string)

Convenience method for deserializing the given JSON into an object with the JSON library used by the client itself.

Declaration
public static T DeserializeFromJson<T>(string json)
Parameters
Type Name Description
string json

The JSON encoded data

Returns
Type Description
T

The deserialized object

Type Parameters
Name Description
T

The type of the expected object

Display(DisplayRequest)

Send a display request.

Declaration
public Task<ApiResponse> Display(DisplayRequest request)
Parameters
Type Name Description
DisplayRequest request

The display request

Returns
Type Description
Task<ApiResponse>

The response object

Display(params DisplayRequest[])

Send multiple display requests.

Multiple display requests must be encoded as JSON. Therefore, display requests with Stream set are not allowed in this method. Use Display(DisplayRequest) instead.

Declaration
public Task<ApiResponse> Display(params DisplayRequest[] requests)
Parameters
Type Name Description
DisplayRequest[] requests

An array with display requests

Returns
Type Description
Task<ApiResponse>

The response object

Exceptions
Type Condition
System.ArgumentException

If one of the display requests uses a stream source

Display(IEnumerable<DisplayRequest>)

Send multiple display requests.

Multiple display requests must be encoded as JSON. Therefore, display requests with Stream set are not allowed in this method. Use Display(DisplayRequest) instead.

Declaration
public Task<ApiResponse> Display(IEnumerable<DisplayRequest> requests)
Parameters
Type Name Description
IEnumerable<DisplayRequest> requests

An enumerable with display requests

Returns
Type Description
Task<ApiResponse>

The response object

Exceptions
Type Condition
System.ArgumentException

If one of the display requests uses a stream source

Dispose()

Dispose of the underlying HttpClient.

Declaration
public void Dispose()

Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

EncodeUtf8StringToBase64(string)

Encode a given string with UTF8 into a byte sequence first and then encode the byte sequence with BASE64 into a string again.

Declaration
public static string EncodeUtf8StringToBase64(string s)
Parameters
Type Name Description
string s

The string to encode

Returns
Type Description
string

The BASE64 encoded data

Evaluate(EvaluationRequest)

Send an evaluation request.

Declaration
public Task<ApiResponse> Evaluate(EvaluationRequest request)
Parameters
Type Name Description
EvaluationRequest request

The evaluation request

Returns
Type Description
Task<ApiResponse>

The API response

Evaluate(params EvaluationRequest[])

Send one or more evaluation requests.

Multiple evaluation requests must be encoded as JSON. Therefore, evaluation requests with Stream set are not allowed in this method. Use Evaluate(EvaluationRequest) instead.

Declaration
public Task<ApiResponse> Evaluate(params EvaluationRequest[] requests)
Parameters
Type Name Description
EvaluationRequest[] requests

An array with evaluation requests

Returns
Type Description
Task<ApiResponse>

The API response

Exceptions
Type Condition
System.ArgumentException

If one of the evaluation requests uses a stream source

Evaluate(IEnumerable<EvaluationRequest>)

Send one or more evaluation requests.

Multiple evaluation requests must be encoded as JSON. Therefore, evaluation requests with Stream set are not allowed in this method. Use Evaluate(EvaluationRequest) instead.

Declaration
public Task<ApiResponse> Evaluate(IEnumerable<EvaluationRequest> requests)
Parameters
Type Name Description
IEnumerable<EvaluationRequest> requests

An enumerable with evaluation requests

Returns
Type Description
Task<ApiResponse>

The API response

Exceptions
Type Condition
System.ArgumentException

If one of the evaluation requests uses a stream source

ExportAllPanels(ExportRequest)

Export all panels as HTML files to a folder in the filesystem of the server.

Declaration
public Task<ApiResponse> ExportAllPanels(ExportRequest exportRequest = null)
Parameters
Type Name Description
ExportRequest exportRequest

The export request

Returns
Type Description
Task<ApiResponse>

The API response

ExportPanel(string, ExportRequest)

Export a single panel as HTML file to a folder in the filesystem of the server.

Declaration
public Task<ApiResponse> ExportPanel(string panelId, ExportRequest exportRequest = null)
Parameters
Type Name Description
string panelId

The panel ID

ExportRequest exportRequest

The export request

Returns
Type Description
Task<ApiResponse>

The API response

ExportSlot(string, string, ExportRequest)

Export a single slot as HTML file to a folder in the filesystem of the server.

Declaration
public Task<ApiResponse> ExportSlot(string panelId, string slotId, ExportRequest exportRequest = null)
Parameters
Type Name Description
string panelId

The panel ID

string slotId

The slot ID

ExportRequest exportRequest

The export request

Returns
Type Description
Task<ApiResponse>

The API response

GetAction(string)

Get the definition of an action as a parsed structure.

Declaration
public Task<BoomackActionResponse> GetAction(string id)
Parameters
Type Name Description
string id

The preset ID

Returns
Type Description
Task<BoomackActionResponse>

The parsed response

GetActionIds()

Get the IDs of all existing actions on the server.

Declaration
public Task<IdListResponse> GetActionIds()
Returns
Type Description
Task<IdListResponse>

An enumerable of the action IDs.

GetActionRaw(string, string)

Get the definition of an action as raw response string.

Specify the preferred format with the acceptMimeType. Supported are at least: text/plain, application/json, and text/html.

Declaration
public Task<ApiResponse> GetActionRaw(string id, string acceptMimeType = "text/plain")
Parameters
Type Name Description
string id

The action ID

string acceptMimeType

The preferred content type for the response

Returns
Type Description
Task<ApiResponse>

The API response

GetMediaType(string)

Get the definition of a media type as a parsed structure.

Declaration
public Task<MediaTypeResponse> GetMediaType(string mimeType)
Parameters
Type Name Description
string mimeType
Returns
Type Description
Task<MediaTypeResponse>

The parsed response

GetMediaTypeIds()

Get the IDs of all existing media types on the server.

Declaration
public Task<IdListResponse> GetMediaTypeIds()
Returns
Type Description
Task<IdListResponse>

An enumerable of the media type IDs.

GetMediaTypeRaw(string, string)

Get the definition of a media type as raw response string.

Specify the preferred format with the acceptMimeType. Supported are at least: text/plain, application/json, and text/html.

Declaration
public Task<ApiResponse> GetMediaTypeRaw(string mimeType, string acceptMimeType = "text/plain")
Parameters
Type Name Description
string mimeType
string acceptMimeType

The preferred content type for the response

Returns
Type Description
Task<ApiResponse>

The API response

GetPanel(string)

Get the definition of a panel as a parsed structure.

Declaration
public Task<PanelLayoutResponse> GetPanel(string id)
Parameters
Type Name Description
string id

The panel ID

Returns
Type Description
Task<PanelLayoutResponse>

The parsed response

GetPanelIds()

Get the IDs of all existing panels on the server.

Declaration
public Task<IdListResponse> GetPanelIds()
Returns
Type Description
Task<IdListResponse>

An enumerable of the panel IDs.

GetPanelRaw(string, string)

Get the definition of a panel as raw response string.

Specify the preferred format with the acceptMimeType. Supported are at least: text/plain, application/json, and text/html.

Declaration
public Task<ApiResponse> GetPanelRaw(string id, string acceptMimeType = "text/plain")
Parameters
Type Name Description
string id

The panel ID

string acceptMimeType

The preferred content type for the response

Returns
Type Description
Task<ApiResponse>

The API response

GetPreset(string)

Get the definition of a preset as a parsed structure.

Declaration
public Task<DisplayOptionsResponse> GetPreset(string id)
Parameters
Type Name Description
string id

The preset ID

Returns
Type Description
Task<DisplayOptionsResponse>

The parsed response

GetPresetIds()

Get the IDs of all existing presets on the server.

Declaration
public Task<IdListResponse> GetPresetIds()
Returns
Type Description
Task<IdListResponse>

An enumerable of the preset IDs.

GetPresetRaw(string, string)

Get the definition of a preset as raw response string.

Specify the preferred format with the acceptMimeType. Supported are at least: text/plain, application/json, and text/html.

Declaration
public Task<ApiResponse> GetPresetRaw(string id, string acceptMimeType = "text/plain")
Parameters
Type Name Description
string id

The preset ID

string acceptMimeType

The preferred content type for the response

Returns
Type Description
Task<ApiResponse>

The API response

GetRequest(string, MediaTypeWithQualityHeaderValue)

Low-level method for a GET request to the Boomack HTTP API.

Declaration
public Task<ApiResponse> GetRequest(string route, MediaTypeWithQualityHeaderValue accept)
Parameters
Type Name Description
string route

The API route

MediaTypeWithQualityHeaderValue accept

The accepted response type

Returns
Type Description
Task<ApiResponse>

The response object

LookupMediaType(string, string)

Use the media type mapping from the client configuration, to find a media type for the given filename.

If the mainType is set, only mapping for media types with the given main type are considered.

Declaration
public string LookupMediaType(string filename, string mainType = null)
Parameters
Type Name Description
string filename

A filename or a path

string mainType

A main media type like &quot;text&quot; or &quot;image&quot; to restrict the search

Returns
Type Description
string

The media type or null

Examples
    client.LookupMediaType("C:\\Users\\Me\\Pictures\\vacation.jpeg")
    client.LookupMediaType("C:\\Users\\Me\\some-file.log", "text")

PostEmptyRequest(string)

Low-level method for a POST request with an empty body to the Boomack HTTP API.

Declaration
public Task<ApiResponse> PostEmptyRequest(string route)
Parameters
Type Name Description
string route

The API route

Returns
Type Description
Task<ApiResponse>

The response object

PostJsonRequest(string, object)

Low-level method for a POST request with a JSON body to the Boomack HTTP API.

Declaration
public Task<ApiResponse> PostJsonRequest(string route, object payload)
Parameters
Type Name Description
string route

The API route

object payload

The object to serialize as JSON for the body

Returns
Type Description
Task<ApiResponse>

The response object

PostStreamRequest(string, Stream, IDictionary<string, string>)

Low-level method for a POST request with the body from a stream to the Boomack HTTP API.

Declaration
public Task<ApiResponse> PostStreamRequest(string route, Stream stream, IDictionary<string, string> headers)
Parameters
Type Name Description
string route

The API route

Stream stream

The stream to read the body from

IDictionary<string, string> headers

A dictionary with HTTP headers

Returns
Type Description
Task<ApiResponse>

The response object

Remarks

Disposes the given stream.

PutJsonRequest(string, object)

Low-level method for a PUT request with a JSON body to the Boomack HTTP API.

Declaration
public Task<ApiResponse> PutJsonRequest(string route, object payload)
Parameters
Type Name Description
string route

The API route

object payload

The object to serialize as JSON for the bod

Returns
Type Description
Task<ApiResponse>

The response object

SerializeToJson(object, bool)

Convenience method for serializing an object to JSON with the JSON library used by the client itself.

Declaration
public static string SerializeToJson(object o, bool compact = false)
Parameters
Type Name Description
object o

An object

bool compact

A flag to activate compact JSON formatting without indentation

Returns
Type Description
string

The serialization result

SetPanelLayout(string, PanelLayout)

Update the layout of an existing panel.

Declaration
public Task<ApiResponse> SetPanelLayout(string id, PanelLayout layout)
Parameters
Type Name Description
string id

The panel ID

PanelLayout layout

The new layout for the panel

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as AddPanel(string, PanelLayout).

UpdateAction(string, BoomackAction)

Update the definition of an existing action.

Declaration
public Task<ApiResponse> UpdateAction(string id, BoomackAction action)
Parameters
Type Name Description
string id

The action ID

BoomackAction action
Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as AddAction(string, BoomackAction).

UpdateMediaType(string, MediaType)

Update the definition of an existing media type.

Declaration
public Task<ApiResponse> UpdateMediaType(string id, MediaType mediaType)
Parameters
Type Name Description
string id

The media type ID

MediaType mediaType

The new definition for the media type

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as AddMediaType(string, MediaType).

UpdatePreset(string, DisplayOptions)

Update the display options of an existing preset.

Declaration
public Task<ApiResponse> UpdatePreset(string id, DisplayOptions options)
Parameters
Type Name Description
string id

The preset ID

DisplayOptions options

The new display options for the preset

Returns
Type Description
Task<ApiResponse>

The API response

Remarks

Behaves exactly the same as AddPreset(string, DisplayOptions).

Implements

System.IDisposable

Extension Methods

BoomackClientExtensions.Display(BoomackClient, Action<IDisplayRequestBuilder>)
BoomackClientExtensions.Evaluate(BoomackClient, Action<IEvaluationRequestBuilder>)
In This Article
Back to top
Boomack Homepage