gomnia

package module
v1.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 14 Imported by: 0

README

go nexxOMNIA API

Link to documentation

Partial API Implementation for nexxOMNIA. This library is published as it is with no guarantee for support and/or bugfixes.

go get github.com/alex-berlin-tv/nexx_omnia_go

Creating a client

In Omnia go to »Domains« and open the info panel of your Domain. There you will find the information as follows:

Name in Frontend Field in Code
ID <DOMAIN_ID>
API Secret <API_SECRET>
Management API Session <DOMAIN_ID>

Location of the fields in the domain information, see table above

client := omnia.NewClient("<DOMAIN_ID>", "<API_SECRET>", "<SESSION_ID>")

Get an audio file by id

// Get Audio file with ID 2342
rsl, err := client.ById(enum.AudioStreamType, 2342, nil)
if err != nil {
    log.Error(err)
}
fmt.Printf("%+v", rsl.Result)

The structure of rsl.Result depends on the method used. In this instance a omnia.MediaResultItem will be returned.

Change the metadata of a media item

Example for calling the update method:

_, err := client.update(enum.AudioStreamType, 2342, params.Custom{
    "title": "Fnord!",
})
if err != nil {
    log.Error(err)
}

There is currently no hard coded parameter implementation for all available attributes you can change with the update method. The API provides a list with all available fields:

rsl, _ := client.EditableAttributes(enum.VideoStreamType)
fmt.Printf("%+v", rsl.Result)

Documentation

Overview

The omnia package provides a way to interact with the API of the media management platform 3q nexx omnia. More information on the API can be obtained by reading the official API documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Named »ID« in the domain detail view.
	DomainId string `json:"domain_id"`
	// Named »API Secret« in the domain detail view.
	ApiSecret string `json:"api_secret"`
	// Named »Management API Session« in the domain detail view.
	SessionId string `json:"session_id"`
}

Encapsulates the calls to the nexxOmnia API. All implemented API methods are available as a method of this struct. In order to obtain the needed information in omnia go to Domains & Services > Domains and open the detail view (»Details anzeigen«) for the domain you want to wish to control with this package. You find the name of the variables in the documentation of the field.

func NewClient

func NewClient(domainId string, apiSecret string, sessionId string) Client

Returns a new Omnia instance. For mor information on how to obtain the needed parameters please refer to the documentation of the Client type.

func OmniaFromFile

func OmniaFromFile(path string) Client

Reads an Omnia instance from a json file.

func (Client) AddChannel

func (o Client) AddChannel(parameters params.Channel) (*Response[any], error)

Add a new channel. Documentation can be found here.

func (o Client) AddUploadLink(parameters params.UploadLink) (*Response[any], error)

Adds a new UploadLink. UploadsLinks are dynamic URLs, that allow external Users to upload Files to a specific nexxOMNIA Account. Uses the Management API. Documentation can be found here.

func (Client) All

func (o Client) All(streamType enum.StreamType, parameters params.QueryParameters) (*Response[MediaResult], error)

Returns all media items of a given streamtype. Please note that it's not possible to retrieve more than 100 items at once using the API. Thus if you have more than 100 items of a given streamtype you'll should use the Client.AllPaged method in order to get all items.

func (Client) AllPaged

func (o Client) AllPaged(streamType enum.StreamType, parameters params.QueryParameters) (*Response[MediaResult], error)

Joins results of multiple pages if there are more than 100 items and the API starts to use paging.

func (Client) Approve

func (o Client) Approve(
	streamType enum.StreamType,
	id int,
	parameters params.Approve,
) (*Response[any], error)

Approves a media item of a given streamtype and item-id. Uses te Management API. Documentation can be found here.

func (Client) AudioCategories added in v1.6.7

func (o Client) AudioCategories() (*Response[MediaResult], error)

Returns all available audio categories in omnia. Documentation can be found here.

func (Client) ByCodeName

func (o Client) ByCodeName(streamType enum.StreamType, codename string, parameters params.QueryParameters) (*Response[any], error)

Return a item of a given streamtype by it's code name. Only available for container streamtypes.

func (Client) ByGlobalId

func (o Client) ByGlobalId(streamType enum.StreamType, globalId int, parameters params.QueryParameters) (*Response[MediaResultItem], error)

Return a item of a given streamtype by it's global id.

func (Client) ByHash

func (o Client) ByHash(streamType enum.StreamType, hash string, parameters params.QueryParameters) (*Response[MediaResultItem], error)

Return a item of a given streamtype by it's hash.

func (Client) ById

func (o Client) ById(streamType enum.StreamType, id int, parameters params.QueryParameters) (*Response[MediaResultItem], error)

Return a item of a given streamtype by it's id. Example, get the audio item with the id 72 with the publishing details:

id := 72
client := omnia.NewClient("23", "Secret", "42")
rsl, err := client.ById(enum.AudioStreamType, id, params.Custom{
	"addPublishingDetails": 1,
})

func (Client) ByQuery

func (o Client) ByQuery(streamType enum.StreamType, query string, parameters params.QueryParameters) (*Response[MediaResult], error)

Performs a regular Query on all Items. The "order" Parameters are ignored, if query-mode is set to "fulltext".

func (Client) ByRefNr

func (o Client) ByRefNr(streamType enum.StreamType, reference string, parameters params.QueryParameters) (*Response[any], error)

Return a item of a given streamtype by it's reference number.

func (Client) ByRemoteRef

func (o Client) ByRemoteRef(streamType enum.StreamType, reference string, parameters params.QueryParameters) (*Response[any], error)

Return a item of a given streamtype by it's remote reference number. This Call queries for an Item, that is (possibly) not hosted by nexxOMNIA. The API will call the given Remote Provider for Media Details and implicitly create the Item for future References within nexxOMNIA.

func (Client) BySlug

func (o Client) BySlug(streamType enum.StreamType, slug string, parameters params.QueryParameters) (*Response[any], error)

Return a item of a given streamtype by it's slug.

func (Client) Channels added in v1.6.1

func (o Client) Channels() (*Response[MediaResult], error)

Returns all available channels in omnia. Documentation can be found here.

func (Client) ConnectShow added in v1.6.2

func (o Client) ConnectShow(
	streamType enum.StreamType,
	id int,
	showId int,
) (*Response[any], error)

Connect an media item to a show. Documentation can be found here.

func (Client) EditableAttributes

func (o Client) EditableAttributes(streamType enum.StreamType) (*Response[EditableAttributesResponse], error)

Lists all editable attributes for a given stream type. Documentation can be found here.

This method is needed as there is no other documentation of all the available metadata fields in omnia. Especially useful if you want to know which metadata attributes you can alter using the Client.Update method.

func (Client) Evergreens

func (o Client) Evergreens(streamType enum.StreamType, parameters params.QueryParameters) (*Response[any], error)

Returns all evergreen media items of a given streamtype.

func (Client) ForKids

func (o Client) ForKids(streamType enum.StreamType, parameters params.QueryParameters) (*Response[any], error)

Returns all Items, marked as "created for Kids". This is NOT connected to any Age Restriction.

func (Client) Latest

func (o Client) Latest(streamType enum.StreamType, parameters params.QueryParameters) (*Response[any], error)

Returns all items, sorted by Creation Date (ignores the "order" Parameters).

func (Client) Picked

func (o Client) Picked(streamType enum.StreamType, parameters params.QueryParameters) (*Response[any], error)

Returns all picked media items of a given streamtype. Ignores the order parameter.

func (Client) Publish

func (o Client) Publish(
	streamType enum.StreamType,
	id int,
) (*Response[any], error)

Publish a media item of a given streamtype and item-id. Uses te Management API. Documentation can be found here.

func (Client) Reject

func (o Client) Reject(
	streamType enum.StreamType,
	id int,
	parameters params.Reject,
) (*Response[any], error)

Rejects a media item of a given streamtype and item-id. Uses te Management API. Documentation can be found here.

func (Client) Update

func (o Client) Update(
	streamType enum.StreamType,
	id int,
	parameters params.Custom,
) (*Response[any], error)

Will update the general Metadata of a Media Item. Uses the Management API. Documentation can be found here. Example, change the title of the video item with the id 72:

client := omnia.NewClient("23", "Secret", "42")
client.Update(enums.VideoStreamType, 72, params.Custom{
	"title": "My cool new title",
})

As you see using a params.Custom map you can alter all the available metadata fields. You can use the Client.EditableAttributes method to get a list of all fields which are available and editable for an media item in omnia.

func (Client) VideoCategories added in v1.6.3

func (o Client) VideoCategories() (*Response[MediaResult], error)

Returns all available video categories in omnia. Documentation can be found here.

func (Client) YouTubeCategories added in v1.6.5

func (o Client) YouTubeCategories() (*Response[YouTubeCategories], error)

Get the available YouTube-Categories. Documentation can be found here.

type EditableAttributesProperties

type EditableAttributesProperties struct {
	Type         string `json:"type"`
	MaxLength    int    `json:"maxlength"`
	Format       string `json:"format,omitempty"`
	Hint         string `json:"hint,omitempty"`
	AllowedInUgc int    `json:"allowedInUGC"`
}

EditableAttributesProperties contains information about the editable properties of an attribute.

type EditableAttributesResponse

type EditableAttributesResponse map[string]EditableAttributesProperties

EditableAttributesResponse is a map that associates attribute names with their editable properties.

type MediaResult

type MediaResult []MediaResultItem

MediaResult is a collection of MediaResultItem instances, each representing a media result. The decision for using a dedicated type for a slice of [MediaResultItem]s was made to ease the further work with results outside this package.

type MediaResultConnectedMedia

type MediaResultConnectedMedia struct {
	Shows []MediaResultGeneral `json:"shows"`
}

MediaResultConnectedMedia represents connected media items associated with a media item.

type MediaResultGeneral

type MediaResultGeneral struct {
	Id                       int                `json:"ID"`
	Gid                      int                `json:"GID"`
	Hash                     string             `json:"hash"`
	Title                    string             `json:"title"`
	Subtitle                 string             `json:"subtitle"`
	GenreRaw                 string             `json:"genre_raw"`
	Genre                    string             `json:"genre"`
	ContentModerationAspects string             `json:"contentModerationAspects"`
	Uploaded                 types.UnixTS       `json:"uploaded"`
	Created                  types.UnixTS       `json:"created"`
	Released                 types.UnixTS       `json:"releasedate"`
	AudioType                string             `json:"audiotype"`
	Runtime                  string             `json:"runtime"`
	IsPicked                 enum.Bool          `json:"isPicked"`
	ForKids                  enum.Bool          `json:"forKids"`
	Channel                  int                `json:"channel,omitempty"` // Optional field.
	IsPay                    enum.Bool          `json:"isPay"`
	IsUgc                    enum.Bool          `json:"isUGC"`
	CategoryRaw              types.StringOrZero `json:"category_raw"`
	Category                 string             `json:"category"`
	Description              string             `json:"description"`
	ReferenceNumber          string             `json:"refnr"`
}

MediaResultGeneral provides general information about a media item, including its ID, title, and more.

Some fields (like Channel) are optional (or as omnia calls them »additional«) fields. You have to use the »additionalFields« parameter for the request. For example:

client := omnia.NewClient("23", "Secret", "42")
rsl, err := client.All(enum.AudioStreamType, id, params.Custom{
	"additionalFields": "channel",
})

In order to get all additional fields use the keyword »all«.

type MediaResultImageData

type MediaResultImageData struct {
	Language          string `json:"language"`
	Thumb             string `json:"thumb"`
	ThumbHasXS        int    `json:"thumb_hasXS"`
	ThumbHasXL        int    `json:"thumb_hasXL"`
	ThumbHasX2        int    `json:"thumb_hasX2"`
	ThumbHasX3        int    `json:"thumb_hasX3"`
	CoversShowTitle   int    `json:"coversShowTitle"`
	Description       string `json:"description"`
	ThumbAction       string `json:"thumb_action"`
	DescriptionAction string `json:"description_action"`
	ThumbBanner       string `json:"thumb_banner"`
	ThumbQuad         string `json:"thumb_quad"`
	ThumbAbt          string `json:"thumb_abt"`
	DescriptionAbt    string `json:"description_abt"`
	Waveform          string `json:"waveform"`
}

MediaResultImageData contains image-related data for a media item, including thumbnails and descriptions.

type MediaResultItem

type MediaResultItem struct {
	General        MediaResultGeneral        `json:"general"`
	ImageData      MediaResultImageData      `json:"imagedata"`
	ConnectedMedia MediaResultConnectedMedia `json:"connectedmedia"`
}

MediaResultItem holds detailed information about a single media result item.

type Response

type Response[T any] struct {
	Metadata ResponseMetadata `json:"metadata"`
	Result   T
	Paging   *ResponsePaging `json:"paging"`
}

Response represents the response structure obtained from a nexxOmnia API call. It encapsulates the metadata, result, and paging information as documented here.

func Call

func Call[T any](
	o Client,
	method string,
	streamType enum.StreamType,
	operation string,
	args []string,
	parameters params.QueryParameters,
	pagingStart int,
	response Response[T],
) (*Response[T], error)

Generic call to the Omnia Media API. Won't work with the management API's.

func DomainDataCall added in v1.6.1

func DomainDataCall[T any](
	o Client,
	method string,
	operation string,
	args []string,
	parameters params.QueryParameters,
	response Response[T],
) (*Response[T], error)

Generic call to omnia's domain data API.

func ManagementCall

func ManagementCall[T any](
	o Client,
	method string,
	streamType enum.StreamType,
	operation string,
	args []string,
	parameters params.QueryParameters,
	response Response[T],
) (*Response[T], error)

Generic call to the Omnia management API.

func SystemCall

func SystemCall[T any](
	o Client,
	method string,
	operation string,
	args []string,
	response Response[T],
) (*Response[T], error)

Generic call to the Omnia system API

type ResponseMetadata

type ResponseMetadata struct {
	// The HTTP Status for this Call.
	Status int `json:"status"` // OK
	// Version of the API.
	ApiVersion string `json:"apiversion,omitempty"` // OK
	// The used HTTP Verb.
	Verb string `json:"verb"` // OK
	// Internal Duration, needed to create the response.
	ProcessingTime float64 `json:"processingtime"` // OK
	// The called Endpoint and Parameter.
	CalledWith *string `json:"calledwith,omitempty"`
	// The `cfo` Parameter from the API Call.
	CalledFor *string `json:"calledfor,omitempty"`
	// The calling Domain ID.
	ForDomain *int `json:"fordomain,omitempty"`
	// The result was created by a Stage or Productive Server.
	FromStage *int `json:"fromstage,omitempty"`
	// If the Call uses deprecated Functionality, find here a Hint, what Attributes
	// should be changed.
	Notice *string `json:"notice"`
	// If the Call failed, a Hint for the Failure Reason.
	ErrorHint *string `json:"errorhint,omitempty"`
	// States whether result came from cache
	FromCache *int `json:"fromcache,omitempty"`
}

Metadata part of an API response.

type ResponsePaging

type ResponsePaging struct {
	// The Start of the Query Range.
	Start int `json:"start"`
	// The given maximal Item List Length.
	Limit int `json:"limit"`
	// The maximally available Number of Items.
	ResultCount int `json:"resultcount"`
}

Information on the paging of an result.

type YouTubeCategories added in v1.6.5

type YouTubeCategories map[int]string

The available YouTube categories. An id mapped to the name of the category.

Directories

Path Synopsis
Contains all the preset enumerations as defined and used in the API.
Contains all the preset enumerations as defined and used in the API.
Additional types which are used in requests to the API but are not built-ins and thus not implemented by the json package.
Additional types which are used in requests to the API but are not built-ins and thus not implemented by the json package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL