mux

package module
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 11 Imported by: 0

README

Mux Go SDK

Golang SDK for Mux API supporting both Mux Data and Mux Video. Mux Video is an API-first platform, powered by data and designed by video experts to make beautiful video possible for every development team. Mux Data is a platform for monitoring your video streaming performance with just a few lines of code. Get in-depth quality of service analytics on web, mobile, and OTT devices. Not familiar with Mux? Check out https://mux.com/ for more information.

SDK Installation

go get github.com/speakeasy-sdks/mux-go

Authentication

Every request to the API is authenticated via an Access Token, which includes the ID and the secret key. You can think of the Access Token’s ID as its username and secret as the password. Mux only stores a hash of the secret, not the secret itself. If you lose the secret key for your access token, Mux cannot recover it; you will have to create a new Access Token. If the secret key for an Access Token is leaked you should revoke that Access Token on the settings page: https://dashboard.mux.com/settings/access-tokens.

Note that in order to access the settings page for access tokens you must be an admin on the Mux organization.

API requests are authenticated via HTTP Basic Auth, where the username is the Access Token ID, and the password is the Access Token secret key. Due to the use of Basic Authentication and because doing so is just a Really Good Idea™, all API requests must made via HTTPS (to https://api.mux.com).

In this SDK you should be able to pass in the username (Access Token ID) and password (Access Token secret) and the library will handle the details of formatting the header.

SDK Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/mux-go"
	"github.com/speakeasy-sdks/mux-go/pkg/models/shared"
)

func main() {
    s := mux.New(
        mux.WithSecurity(shared.Security{
            Password: "",
            Username: "",
        }),
    )

    ctx := context.Background()
    res, err := s.Assets.CreateAsset(ctx, shared.CreateAssetRequest{
        Input: []shared.InputSettings{
            shared.InputSettings{
                ClosedCaptions: mux.Bool(false),
                EndTime: mux.Float64(5928.45),
                LanguageCode: mux.String("distinctio"),
                Name: mux.String("Stuart Stiedemann"),
                OverlaySettings: &shared.InputSettingsOverlaySettings{
                    Height: mux.String("vel"),
                    HorizontalAlign: shared.InputSettingsOverlaySettingsHorizontalAlignCenter.ToPointer(),
                    HorizontalMargin: mux.String("deserunt"),
                    Opacity: mux.String("suscipit"),
                    VerticalAlign: shared.InputSettingsOverlaySettingsVerticalAlignMiddle.ToPointer(),
                    VerticalMargin: mux.String("magnam"),
                    Width: mux.String("debitis"),
                },
                Passthrough: mux.String("ipsa"),
                StartTime: mux.Float64(9636.63),
                TextType: shared.InputSettingsTextTypeSubtitles.ToPointer(),
                Type: shared.InputSettingsTypeVideo.ToPointer(),
                URL: mux.String("suscipit"),
            },
            shared.InputSettings{
                ClosedCaptions: mux.Bool(false),
                EndTime: mux.Float64(4776.65),
                LanguageCode: mux.String("minus"),
                Name: mux.String("Ken Kshlerin"),
                OverlaySettings: &shared.InputSettingsOverlaySettings{
                    Height: mux.String("recusandae"),
                    HorizontalAlign: shared.InputSettingsOverlaySettingsHorizontalAlignRight.ToPointer(),
                    HorizontalMargin: mux.String("ab"),
                    Opacity: mux.String("quis"),
                    VerticalAlign: shared.InputSettingsOverlaySettingsVerticalAlignTop.ToPointer(),
                    VerticalMargin: mux.String("deserunt"),
                    Width: mux.String("perferendis"),
                },
                Passthrough: mux.String("ipsam"),
                StartTime: mux.Float64(8326.2),
                TextType: shared.InputSettingsTextTypeSubtitles.ToPointer(),
                Type: shared.InputSettingsTypeText.ToPointer(),
                URL: mux.String("quo"),
            },
            shared.InputSettings{
                ClosedCaptions: mux.Bool(false),
                EndTime: mux.Float64(1403.5),
                LanguageCode: mux.String("at"),
                Name: mux.String("Emilio Krajcik"),
                OverlaySettings: &shared.InputSettingsOverlaySettings{
                    Height: mux.String("esse"),
                    HorizontalAlign: shared.InputSettingsOverlaySettingsHorizontalAlignCenter.ToPointer(),
                    HorizontalMargin: mux.String("porro"),
                    Opacity: mux.String("dolorum"),
                    VerticalAlign: shared.InputSettingsOverlaySettingsVerticalAlignTop.ToPointer(),
                    VerticalMargin: mux.String("nam"),
                    Width: mux.String("officia"),
                },
                Passthrough: mux.String("occaecati"),
                StartTime: mux.Float64(1433.53),
                TextType: shared.InputSettingsTextTypeSubtitles.ToPointer(),
                Type: shared.InputSettingsTypeAudio.ToPointer(),
                URL: mux.String("hic"),
            },
        },
        MasterAccess: shared.CreateAssetRequestMasterAccessTemporary.ToPointer(),
        Mp4Support: shared.CreateAssetRequestMp4SupportStandard.ToPointer(),
        NormalizeAudio: mux.Bool(false),
        Passthrough: mux.String("beatae"),
        PerTitleEncode: mux.Bool(false),
        PlaybackPolicy: []shared.PlaybackPolicy{
            shared.PlaybackPolicyPublic,
            shared.PlaybackPolicyPublic,
        },
        Test: mux.Bool(false),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.AssetResponse != nil {
        // handle response
    }
}

Available Resources and Operations

Assets
DeliveryUsage
Dimensions
DirectUploads
Errors
Exports
Filters
Incidents
LiveStreams
Metrics
Monitoring
PlaybackID
PlaybackRestrictions
RealTime
Spaces
TranscriptionVocabularies
URLSigningKeys
VideoViews

Issues

If you run into problems, please raise a GitHub issue,. We'll take a look as soon as possible.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release !

SDK Generated by Speakeasy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{

	"https://api.mux.com",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool added in v1.14.0

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32 added in v1.14.0

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64 added in v1.14.0

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int added in v1.14.0

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64 added in v1.14.0

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func String added in v1.4.0

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for suplying the SDK with a custom HTTP client

type Mux

type Mux struct {
	// Assets - An asset refers to a piece of media content that is stored or is being live streamed through the Mux system. An asset always has a duration and one or more tracks (audio, video, and text data).
	//
	// The media content of an asset cannot be updated once created, however an asset can be used to create another asset, and can be modified within that process.
	Assets *assets
	// DeliveryUsage - The Delivery Usage API allows you to get delivery/streaming usage details for each asset and across all assets. Delivery usage details are aggregated every hour at the top of the hour and can be requested for a specified time window within the last 90 days starting at 12 hours prior to when the request is made.
	//
	// Assets are ordered by delivery usage starting with the one with the highest usage. Only assets with delivery usage greater than 0 seconds are returned in the response.
	DeliveryUsage *deliveryUsage
	// Dimensions - Dimensions are the types of metadata that can be collected for a video view. Some dimensions are collected automatically based on the playback or device, such as the viewer's Country or the device information. Other dimensions are specified by the developer when configuring a Mux Data video view such as the video title. The Dimensions APIs allow you to get a list of the supported dimensions and their values.
	Dimensions *dimensions
	// DirectUploads - Direct upload allows you to push assets directly to Mux storage instead of needing to go through your own first. When you create a new direct upload, we'll give you back a signed URL for a Google Cloud Storage bucket. Their storage API is S3 compatible, so whatever tool you use to upload to either GCS or S3 should work, just remember you're probably uploading large video files and should [take advantage of things like resumable or multipart uploads](https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload).
	//
	// Particularly for customers that deal with a lot of user-generated content, it's common to expect quite a few abandoned uploads. To keep those abandoned uploads from cluttering up your asset lists, we don't create an asset for you until the upload is complete. Once that asset is created, you can expect all of the normal asset-related webhooks.
	DirectUploads *directUploads
	// Errors - Playback errors are tracked and aggregated by Mux Data. Errors can be listed by the API, which contains data about the error code, message, and how often the error occurred.
	Errors *errors
	// Exports - Exports allow you to download the daily CSV files that are generated from the video views that occurred in the previous day. Please contact [support](mailto:support@mux.com) for information about enabling exports for your organization.
	Exports *exports
	// Filters - Deprecated, please refer to the Dimensions APIs.
	Filters *filters
	// Incidents - Incidents occur when an anomaly alert is triggered in Mux Data. The Incidents API provides operations related to the raising and managing of alerting incidents.
	Incidents *incidents
	// LiveStreams - A Live Stream represents a unique live stream of video being pushed to Mux. It includes configuration details (a Stream Key) for live broadcasting software/hardware and a Playback ID for playing the stream anywhere. Currently, RTMP is the only supported method of ingesting video. Use rtmp://global-live.mux.com:5222/app with the Live Stream's Stream Key for getting the video into Mux, and use https://stream.mux.com with the Live Stream's Playback ID for playback.
	//
	// A Live Stream can be used once for a specific event, or re-used forever. If you're building an application like Facebook Live or Twitch, you could create one Live Stream per user. This allows them to configure their broadcasting software once, and the Live Stream Playback ID will always show their latest stream.
	//
	// Each RTMP session creates a new video asset automatically. You can set up a webhook to be notified each time a broadcast (or Live Stream RTMP session) begins or ends with the video.live_stream.active and video.live_stream.idle events respectively. Assets that are created from a Live Stream have the same behavior as other Assets you create.
	//
	// Learn more about [how to go live in our guides](https://docs.mux.com/docs/live-streaming).
	LiveStreams *liveStreams
	// Metrics - Historical metrics are used for tracking KPIs, diagnosing issues, and
	// measuring viewers' quality of experience. Metrics are calculated using the
	// video views that have been completed and are bucketed on the view end time
	// for quality of experience metrics and view start time for engagement
	// metrics. Historical metrics provide a large collection of dimensions that
	// can be used to aggregate quality of experience based on view metadata. You
	// can also easily compare experiences across viewer populations to, for
	// example, find issues with specific devices or geographies.
	//
	// Historical metrics are similar but not directly comparable to the real-time
	// metrics in the Real-time APIs. These metrics are aggregated for long-term
	// storage historical reporting and are generated using different viewer
	// populations.
	//
	Metrics *metrics
	// Monitoring - Monitoring metrics are used for operational monitoring of a video platform.
	// The metrics are aggregated in five second intervals, across the views that
	// are currently being watched. The real-time metrics' timeline, breakdown,
	// and histogram representations are available via the APIs.
	//
	// Monitoring metrics are similar but not directly comparable to the historical
	// metrics in the Metrics APIs. These metrics are aggregated to provide the most
	// operational detail possible used for resolving operational issues.
	//
	Monitoring *monitoring
	// PlaybackID - Operations related to the manipulation of playback IDs, through which users are able to stream videos and live streams from Mux.
	PlaybackID *playbackID
	// PlaybackRestrictions - Playback Restrictions allows you to set additional rules for playing videos. You can set the domains/hostnames allowed to play your videos. For instance, viewers can play videos embedded on the `https://example.com` website when you set the Playback Restrictions with `example.com` as an allowed domain. Any Video requests from other websites are denied.
	PlaybackRestrictions *playbackRestrictions
	// RealTime - The Mux Data Real-time API has been deprecated, please refer to the
	// Mux Data `Monitoring` APIs which provide the same functionality.
	//
	RealTime *realTime
	// Spaces - Spaces allow developers to build real-time video and audio experiences into their applications via the [Real-Time Video product.](https://mux.com/real-time-video)
	//
	// Composited video of space sessions can be sent to live streams using broadcasts.
	//
	// To add real-time video to an application, you'll also need to integrate one of our [Real-Time Video SDKs](/guides/video/build-real-time-video-experiences#5-integrate-a-real-time-video-sdk).
	//
	// Learn more in the [Real-Time Video guides](/guides/video/build-real-time-video-experiences).
	Spaces *spaces
	// TranscriptionVocabularies - Transcription Vocabularies allows you to provide collections of phrases like proper nouns, technical jargon, and uncommon words as part of captioning workflows. When using Auto-Generated Captions, Transcription Vocabularies increase the likelihood of correct speech recognition for these words and phrases.
	TranscriptionVocabularies *transcriptionVocabularies
	// URLSigningKeys - A URL signing key is used as the secret when signing any Mux URL. Mux requires a [JSON Web Token](https://jwt.io/) as the value of the token query parameter. The token query parameter must be set for URLs that reference a playback ID with a signed playback policy.
	URLSigningKeys *urlSigningKeys
	// VideoViews - An individual video view tracked by Mux Data. For the full list of properties for each view please refer to the table of data fields in the [Export raw video view data guide](https://docs.mux.com/guides/data/export-raw-video-view-data).
	VideoViews *videoViews
	// contains filtered or unexported fields
}

Mux - Mux API: Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.

func New

func New(opts ...SDKOption) *Mux

New creates a new instance of the SDK with the provided options

type SDKOption

type SDKOption func(*Mux)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithSecurity

func WithSecurity(security shared.Security) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithServerIndex added in v1.19.0

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL added in v1.9.3

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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