mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 04:20:46 +00:00
* `PlexApi.LibraryPlaylists.AddPlaylistItems()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryPlaylists.ClearPlaylistItems()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryCollections.MoveCollectionItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryCollections.DeleteCollectionItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryCollections.AddCollectionItems()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetSonicallySimilar()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Butler.StopTask()`: `request` **Changed** **Breaking** ⚠️ * `PlexApi.Butler.StartTask()`: `request` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetSonicPath()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.DownloadQueue.GetItemDecision()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetAllHubs()`: * `request.OnlyTransient` **Changed** * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetContinueWatching()`: `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetPromotedHubs()`: `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetMetadataHubs()`: * `request.OnlyTransient` **Changed** * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetPostplayHubs()`: * `request.OnlyTransient` **Changed** * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetRelatedHubs()`: * `request.OnlyTransient` **Changed** * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Hubs.GetSectionHubs()`: * `request.OnlyTransient` **Changed** * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetAllLeaves()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Content.ListContent()`: * `request` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Search.SearchHubs()`: `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetAlbums()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetLibraryItems()`: * `request.MediaQuery` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.IngestTransientItem()`: * `request` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetLibraryMatches()`: * `request` **Changed** **Breaking** ⚠️ * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetMetadataItem()`: * `request` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetSections()`: `response.mediaContainer.Directory.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.AddSection()`: * `request` **Changed** * `response.mediaContainer.Directory.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetTags()`: * `request.Type` **Changed** **Breaking** ⚠️ * `PlexApi.Content.GetCollectionItems()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetAllItemLeaves()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Status.ListSessions()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.MovePlayQueueItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetExtras()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.DeletePlayQueueItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.Unshuffle()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.ListMatches()`: * `request.Manual` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.ListSonicallySimilar()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.Shuffle()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetRelatedItems()`: `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.ListSimilar()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.ResetPlayQueue()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetItemTree()`: `response.mediaContainer.MetadataItem.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.ClearPlayQueue()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.AddToPlayQueue()`: * `request.Next` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetCommon()`: * `request.MediaQuery` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetPerson()`: `response.mediaContainer.Directory.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.ListPersonMedia()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.PlayQueue.GetPlayQueue()`: * `request` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetLibraryDetails()`: * `request.IncludeDetails` **Changed** * `response.mediaContainer.Directory.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryPlaylists.MovePlaylistItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.Autocomplete()`: * `request.MediaQuery` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Library.GetCollections()`: * `request.MediaQuery` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryPlaylists.GetPlaylistGeneratorItems()`: `response.mediaContainer.Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryPlaylists.DeletePlaylistItem()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Search.VoiceSearchHubs()`: * `request.Type` **Changed** **Breaking** ⚠️ * `response.mediaContainer.Hub.[].Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LibraryPlaylists.CreatePlaylist()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Playlist.GetPlaylistItems()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Playlist.GetPlaylist()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Playlist.ListPlaylists()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Collections.CreateCollection()`: * `request.Type` **Changed** **Breaking** ⚠️ * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.DvRs.TuneChannel()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LiveTv.GetSessions()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.LiveTv.GetLiveTvSession()`: `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Transcoder.MakeDecision()`: * `request` **Changed** * `response.mediaContainer.Metadata.[]` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.GetAllSubscriptions()`: * `request` **Changed** * `response.mediaContainer.MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.CreateSubscription()`: `response.mediaContainer.MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.GetScheduledRecordings()`: `response.mediaContainer.MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.GetTemplate()`: `response.mediaContainer.SubscriptionTemplate.[].MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.GetSubscription()`: * `request` **Changed** * `response.mediaContainer.MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.EditSubscriptionPreferences()`: `response.mediaContainer.MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Subscriptions.ReorderSubscription()`: `response.mediaContainer.MediaSubscription.[].MediaGrabOperation.[].Metadata` **Changed** **Breaking** ⚠️ * `PlexApi.Library.AddSubtitles()`: `request` **Changed** * `PlexApi.LibraryPlaylists.UploadPlaylist()`: * `request.Force` **Changed** * `PlexApi.Transcoder.TranscodeSubtitles()`: `request` **Changed** * `PlexApi.Transcoder.StartTranscodeSession()`: `request` **Changed** * `PlexApi.Library.GetMediaPart()`: * `request.Download` **Changed** * `PlexApi.Library.DetectIntros()`: * `request.Force` **Changed** * `PlexApi.Library.GetSectionImage()`: * `request.MediaQuery` **Changed** * `PlexApi.Library.DeleteMediaItem()`: * `request.Proxy` **Changed** * `PlexApi.Library.RefreshItemsMetadata()`: * `request.MarkUpdated` **Changed** * `PlexApi.Authentication.Post-Users-Sign-In-Data()`: **Added** * `PlexApi.Authentication.GetTokenDetails()`: **Added** * `PlexApi.Library.DetectCredits()`: `request` **Changed** * `PlexApi.Library.SetStreamSelection()`: * `request.AllParts` **Changed** * `PlexApi.Library.UpdateItems()`: * `request.Field.locked` **Changed** * `PlexApi.PlayQueue.CreatePlayQueue()`: `request` **Changed** * `PlexApi.Library.DeleteLibrarySection()`: * `request.Async` **Changed** * `PlexApi.Library.GetAugmentationStatus()`: * `request.Wait` **Changed** * `PlexApi.Transcoder.TranscodeImage()`: `request` **Changed** * `PlexApi.Devices.ModifyDevice()`: * `request.Enabled` **Changed** * `PlexApi.Library.DetectVoiceActivity()`: `request` **Changed** * `PlexApi.Library.GetStream()`: * `request.AutoAdjustSubtitle` **Changed** * `PlexApi.Library.StartBifGeneration()`: * `request.Force` **Changed** * `PlexApi.Library.GetFirstCharacters()`: * `request.MediaQuery` **Changed** * `PlexApi.UltraBlur.GetImage()`: * `request.Noise` **Changed** * `PlexApi.Library.GenerateThumbs()`: * `request.Force` **Changed** * `PlexApi.Updater.ApplyUpdates()`: `request` **Changed** * `PlexApi.Updater.CheckUpdates()`: * `request.Download` **Changed** * `PlexApi.Library.DeleteMetadataItem()`: * `request.Proxy` **Changed** * `PlexApi.Library.OptimizeDatabase()`: * `request.Async` **Changed** * `PlexApi.Library.RefreshSection()`: * `request.Force` **Changed** * `PlexApi.Hubs.UpdateHubVisibility()`: `request` **Changed** * `PlexApi.Hubs.CreateCustomHub()`: `request` **Changed** * `PlexApi.DownloadQueue.AddDownloadQueueItems()`: `request` **Changed** * `PlexApi.Timeline.Report()`: `request` **Changed** * `PlexApi.General.GetSourceConnectionInformation()`: * `request.Refresh` **Changed** * `PlexApi.Plex.Get-Server-Resources()`: **Added** * `PlexApi.Users.Get-Users()`: **Added**
1538 lines
71 KiB
C#
1538 lines
71 KiB
C#
//------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost when
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
//------------------------------------------------------------------------------
|
|
#nullable enable
|
|
namespace LukeHagar.PlexAPI.SDK
|
|
{
|
|
using LukeHagar.PlexAPI.SDK.Hooks;
|
|
using LukeHagar.PlexAPI.SDK.Models.Components;
|
|
using LukeHagar.PlexAPI.SDK.Models.Errors;
|
|
using LukeHagar.PlexAPI.SDK.Models.Requests;
|
|
using LukeHagar.PlexAPI.SDK.Utils;
|
|
using LukeHagar.PlexAPI.SDK.Utils.Retries;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Headers;
|
|
using System.Threading.Tasks;
|
|
|
|
/// <summary>
|
|
/// Media grabbers provide ways for media to be obtained for a given protocol. The simplest ones are `stream` and `download`. More complex grabbers can have associated devices<br/>
|
|
///
|
|
/// <remarks>
|
|
/// <br/>
|
|
/// Network tuners can present themselves on the network using the Simple Service Discovery Protocol and Plex Media Server will discover them. The following XML is an example of the data returned from SSDP. The `deviceType`, `serviceType`, and `serviceId` values must remain as they are in the example in order for PMS to properly discover the device. Other less-obvious fields are described in the parameters section below.<br/>
|
|
/// <br/>
|
|
/// Example SSDP output<br/>
|
|
/// ```<br/>
|
|
/// <root xmlns="urn:schemas-upnp-org:device-1-0"><br/>
|
|
/// <specVersion><br/>
|
|
/// <major>1</major><br/>
|
|
/// <minor>0</minor><br/>
|
|
/// </specVersion><br/>
|
|
/// <device><br/>
|
|
/// <deviceType>urn:plex-tv:device:Media:1</deviceType><br/>
|
|
/// <friendlyName>Turing Hopper 3000</friendlyName><br/>
|
|
/// <manufacturer>Plex, Inc.</manufacturer><br/>
|
|
/// <manufacturerURL>https://plex.tv/</manufacturerURL><br/>
|
|
/// <modelDescription>Turing Hopper 3000 Media Grabber</modelDescription><br/>
|
|
/// <modelName>Plex Media Grabber</modelName><br/>
|
|
/// <modelNumber>1</modelNumber><br/>
|
|
/// <modelURL>https://plex.tv</modelURL><br/>
|
|
/// <UDN>uuid:42fde8e4-93b6-41e5-8a63-12d848655811</UDN><br/>
|
|
/// <serviceList><br/>
|
|
/// <service><br/>
|
|
/// <URLBase>http://10.0.0.5:8088</URLBase><br/>
|
|
/// <serviceType>urn:plex-tv:service:MediaGrabber:1</serviceType><br/>
|
|
/// <serviceId>urn:plex-tv:serviceId:MediaGrabber</serviceId><br/>
|
|
/// </service><br/>
|
|
/// </serviceList><br/>
|
|
/// </device><br/>
|
|
/// </root><br/>
|
|
/// ```<br/>
|
|
/// <br/>
|
|
/// - UDN: (string) A UUID for the device. This should be unique across models of a device at minimum.<br/>
|
|
/// - URLBase: (string) The base HTTP URL for the device from which all of the other endpoints are hosted.<br/>
|
|
///
|
|
/// </remarks>
|
|
/// </summary>
|
|
public interface IDevices
|
|
{
|
|
|
|
/// <summary>
|
|
/// Get available grabbers
|
|
///
|
|
/// <remarks>
|
|
/// Get available grabbers visible to the server
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<GetAvailableGrabbersResponse> GetAvailableGrabbersAsync(GetAvailableGrabbersRequest? request = null);
|
|
|
|
/// <summary>
|
|
/// Get all devices
|
|
///
|
|
/// <remarks>
|
|
/// Get the list of all devices present
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<ListDevicesResponse> ListDevicesAsync();
|
|
|
|
/// <summary>
|
|
/// Add a device
|
|
///
|
|
/// <remarks>
|
|
/// This endpoint adds a device to an existing grabber. The device is identified, and added to the correct grabber.
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<AddDeviceResponse> AddDeviceAsync(AddDeviceRequest? request = null);
|
|
|
|
/// <summary>
|
|
/// Tell grabbers to discover devices
|
|
///
|
|
/// <remarks>
|
|
/// Tell grabbers to discover devices
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<DiscoverDevicesResponse> DiscoverDevicesAsync();
|
|
|
|
/// <summary>
|
|
/// Remove a device
|
|
///
|
|
/// <remarks>
|
|
/// Remove a devices by its id along with its channel mappings
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<RemoveDeviceResponse> RemoveDeviceAsync(RemoveDeviceRequest request);
|
|
|
|
/// <summary>
|
|
/// Get device details
|
|
///
|
|
/// <remarks>
|
|
/// Get a device's details by its id
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<GetDeviceDetailsResponse> GetDeviceDetailsAsync(GetDeviceDetailsRequest request);
|
|
|
|
/// <summary>
|
|
/// Enable or disable a device
|
|
///
|
|
/// <remarks>
|
|
/// Enable or disable a device by its id
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<ModifyDeviceResponse> ModifyDeviceAsync(ModifyDeviceRequest request);
|
|
|
|
/// <summary>
|
|
/// Set a device's channel mapping
|
|
///
|
|
/// <remarks>
|
|
/// Set a device's channel mapping
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<SetChannelmapResponse> SetChannelmapAsync(SetChannelmapRequest request);
|
|
|
|
/// <summary>
|
|
/// Get a device's channels
|
|
///
|
|
/// <remarks>
|
|
/// Get a device's channels by its id
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<GetDevicesChannelsResponse> GetDevicesChannelsAsync(GetDevicesChannelsRequest request);
|
|
|
|
/// <summary>
|
|
/// Set device preferences
|
|
///
|
|
/// <remarks>
|
|
/// Set device preferences by its id
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<SetDevicePreferencesResponse> SetDevicePreferencesAsync(SetDevicePreferencesRequest request);
|
|
|
|
/// <summary>
|
|
/// Tell a device to stop scanning for channels
|
|
///
|
|
/// <remarks>
|
|
/// Tell a device to stop scanning for channels
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<StopScanResponse> StopScanAsync(StopScanRequest request);
|
|
|
|
/// <summary>
|
|
/// Tell a device to scan for channels
|
|
///
|
|
/// <remarks>
|
|
/// Tell a device to scan for channels
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<ScanResponse> ScanAsync(ScanRequest request);
|
|
|
|
/// <summary>
|
|
/// Get device thumb
|
|
///
|
|
/// <remarks>
|
|
/// Get a device's thumb for display to the user
|
|
/// </remarks>
|
|
/// </summary>
|
|
Task<GetThumbResponse> GetThumbAsync(GetThumbRequest request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Media grabbers provide ways for media to be obtained for a given protocol. The simplest ones are `stream` and `download`. More complex grabbers can have associated devices<br/>
|
|
///
|
|
/// <remarks>
|
|
/// <br/>
|
|
/// Network tuners can present themselves on the network using the Simple Service Discovery Protocol and Plex Media Server will discover them. The following XML is an example of the data returned from SSDP. The `deviceType`, `serviceType`, and `serviceId` values must remain as they are in the example in order for PMS to properly discover the device. Other less-obvious fields are described in the parameters section below.<br/>
|
|
/// <br/>
|
|
/// Example SSDP output<br/>
|
|
/// ```<br/>
|
|
/// <root xmlns="urn:schemas-upnp-org:device-1-0"><br/>
|
|
/// <specVersion><br/>
|
|
/// <major>1</major><br/>
|
|
/// <minor>0</minor><br/>
|
|
/// </specVersion><br/>
|
|
/// <device><br/>
|
|
/// <deviceType>urn:plex-tv:device:Media:1</deviceType><br/>
|
|
/// <friendlyName>Turing Hopper 3000</friendlyName><br/>
|
|
/// <manufacturer>Plex, Inc.</manufacturer><br/>
|
|
/// <manufacturerURL>https://plex.tv/</manufacturerURL><br/>
|
|
/// <modelDescription>Turing Hopper 3000 Media Grabber</modelDescription><br/>
|
|
/// <modelName>Plex Media Grabber</modelName><br/>
|
|
/// <modelNumber>1</modelNumber><br/>
|
|
/// <modelURL>https://plex.tv</modelURL><br/>
|
|
/// <UDN>uuid:42fde8e4-93b6-41e5-8a63-12d848655811</UDN><br/>
|
|
/// <serviceList><br/>
|
|
/// <service><br/>
|
|
/// <URLBase>http://10.0.0.5:8088</URLBase><br/>
|
|
/// <serviceType>urn:plex-tv:service:MediaGrabber:1</serviceType><br/>
|
|
/// <serviceId>urn:plex-tv:serviceId:MediaGrabber</serviceId><br/>
|
|
/// </service><br/>
|
|
/// </serviceList><br/>
|
|
/// </device><br/>
|
|
/// </root><br/>
|
|
/// ```<br/>
|
|
/// <br/>
|
|
/// - UDN: (string) A UUID for the device. This should be unique across models of a device at minimum.<br/>
|
|
/// - URLBase: (string) The base HTTP URL for the device from which all of the other endpoints are hosted.<br/>
|
|
///
|
|
/// </remarks>
|
|
/// </summary>
|
|
public class Devices: IDevices
|
|
{
|
|
public SDKConfig SDKConfiguration { get; private set; }
|
|
|
|
private const string _language = Constants.Language;
|
|
private const string _sdkVersion = Constants.SdkVersion;
|
|
private const string _sdkGenVersion = Constants.SdkGenVersion;
|
|
private const string _openapiDocVersion = Constants.OpenApiDocVersion;
|
|
|
|
public Devices(SDKConfig config)
|
|
{
|
|
SDKConfiguration = config;
|
|
}
|
|
|
|
public async Task<GetAvailableGrabbersResponse> GetAvailableGrabbersAsync(GetAvailableGrabbersRequest? request = null)
|
|
{
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getAvailableGrabbers", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
GetAvailableGrabbersResponseBody obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<GetAvailableGrabbersResponseBody>(httpResponseBody, NullValueHandling.Include);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into GetAvailableGrabbersResponseBody.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new GetAvailableGrabbersResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.Object = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<ListDevicesResponse> ListDevicesAsync()
|
|
{
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
|
|
var urlString = baseUrl + "/media/grabbers/devices";
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "listDevices", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new ListDevicesResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<AddDeviceResponse> AddDeviceAsync(AddDeviceRequest? request = null)
|
|
{
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "addDevice", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 400 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Include);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new AddDeviceResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode == 400 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<DiscoverDevicesResponse> DiscoverDevicesAsync()
|
|
{
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
|
|
var urlString = baseUrl + "/media/grabbers/devices/discover";
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "discoverDevices", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new DiscoverDevicesResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<RemoveDeviceResponse> RemoveDeviceAsync(RemoveDeviceRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new RemoveDeviceRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "removeDevice", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
RemoveDeviceResponseBody obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<RemoveDeviceResponseBody>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into RemoveDeviceResponseBody.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new RemoveDeviceResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.Object = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<GetDeviceDetailsResponse> GetDeviceDetailsAsync(GetDeviceDetailsRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new GetDeviceDetailsRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getDeviceDetails", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new GetDeviceDetailsResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<ModifyDeviceResponse> ModifyDeviceAsync(ModifyDeviceRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new ModifyDeviceRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "modifyDevice", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
ModifyDeviceResponseBody obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<ModifyDeviceResponseBody>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into ModifyDeviceResponseBody.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new ModifyDeviceResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.Object = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<SetChannelmapResponse> SetChannelmapAsync(SetChannelmapRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new SetChannelmapRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/channelmap", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "setChannelmap", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new SetChannelmapResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<GetDevicesChannelsResponse> GetDevicesChannelsAsync(GetDevicesChannelsRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new GetDevicesChannelsRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/channels", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getDevicesChannels", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
GetDevicesChannelsResponseBody obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<GetDevicesChannelsResponseBody>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into GetDevicesChannelsResponseBody.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new GetDevicesChannelsResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.Object = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<SetDevicePreferencesResponse> SetDevicePreferencesAsync(SetDevicePreferencesRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new SetDevicePreferencesRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/prefs", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Put, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "setDevicePreferences", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
return new SetDevicePreferencesResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<StopScanResponse> StopScanAsync(StopScanRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new StopScanRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/scan", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Delete, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "stopScan", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new StopScanResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<ScanResponse> ScanAsync(ScanRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new ScanRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/scan", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Post, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "scan", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
if(Utilities.IsContentTypeMatch("application/json", contentType))
|
|
{
|
|
var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
|
|
MediaContainerWithDevice obj;
|
|
try
|
|
{
|
|
obj = ResponseBodyDeserializer.DeserializeNotNull<MediaContainerWithDevice>(httpResponseBody, NullValueHandling.Ignore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithDevice.", httpResponse, httpResponseBody, ex);
|
|
}
|
|
|
|
var response = new ScanResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
response.MediaContainerWithDevice = obj;
|
|
return response;
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
public async Task<GetThumbResponse> GetThumbAsync(GetThumbRequest request)
|
|
{
|
|
if (request == null)
|
|
{
|
|
request = new GetThumbRequest();
|
|
}
|
|
request.Accepts ??= SDKConfiguration.Accepts;
|
|
request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier;
|
|
request.Product ??= SDKConfiguration.Product;
|
|
request.Version ??= SDKConfiguration.Version;
|
|
request.Platform ??= SDKConfiguration.Platform;
|
|
request.PlatformVersion ??= SDKConfiguration.PlatformVersion;
|
|
request.Device ??= SDKConfiguration.Device;
|
|
request.Model ??= SDKConfiguration.Model;
|
|
request.DeviceVendor ??= SDKConfiguration.DeviceVendor;
|
|
request.DeviceName ??= SDKConfiguration.DeviceName;
|
|
request.Marketplace ??= SDKConfiguration.Marketplace;
|
|
|
|
string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl();
|
|
var urlString = URLBuilder.Build(baseUrl, "/media/grabbers/devices/{deviceId}/thumb/{version}", request, null);
|
|
|
|
var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString);
|
|
httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent);
|
|
HeaderSerializer.PopulateHeaders(ref httpRequest, request);
|
|
|
|
if (SDKConfiguration.SecuritySource != null)
|
|
{
|
|
httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest);
|
|
}
|
|
|
|
var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getThumb", null, SDKConfiguration.SecuritySource);
|
|
|
|
httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest);
|
|
|
|
HttpResponseMessage httpResponse;
|
|
try
|
|
{
|
|
httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest);
|
|
int _statusCode = (int)httpResponse.StatusCode;
|
|
|
|
if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error);
|
|
if (_httpResponse != null)
|
|
{
|
|
httpResponse = _httpResponse;
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse);
|
|
|
|
var contentType = httpResponse.Content.Headers.ContentType?.MediaType;
|
|
int responseStatusCode = (int)httpResponse.StatusCode;
|
|
if(responseStatusCode == 200)
|
|
{
|
|
return new GetThumbResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
}
|
|
else if(responseStatusCode == 301)
|
|
{
|
|
return new GetThumbResponse()
|
|
{
|
|
StatusCode = responseStatusCode,
|
|
ContentType = contentType,
|
|
RawResponse = httpResponse
|
|
};
|
|
}
|
|
else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
else if(responseStatusCode >= 500 && responseStatusCode < 600)
|
|
{
|
|
throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
|
|
throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync());
|
|
}
|
|
}
|
|
} |