osaasclient

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 10 Imported by: 1

README

Eyevinn OSC Go Client

Go client library for operating with Eyevinn Open Source Cloud

github release license

PRs welcome made with hearth by Eyevinn Slack

Installation

Import library in your project

import "github.com/EyevinnOSC/client-go"

Usage

Example of creating, listing and removing an instance

package main

import "github.com/EyevinnOSC/client-go"
import "fmt"
import "os"

func main() {
  config := &osaasclient.ContextConfig{
	  PersonalAccessToken: os.Getenv("OSC_PAT"),
	  Environment:         "dev",
  }

  ctx, err := osaasclient.NewContext(config)
  if err != nil {
    fmt.Println("Error creating context:", err)
    return
  }

  token, err := ctx.GetServiceAccessToken("encore")
  if err != nil {
    fmt.Println("Error getting service access token:", err)
    return
  }

  instances, err := osaasclient.ListInstances(ctx, "encore", token)

  if err == nil {
    fmt.Printf("instances: %s\n", instances)
  } else {
    fmt.Println("Error listing instances:", err)
  }

  instanceName := "test-instance"

  instance, err := osaasclient.CreateInstance(ctx, "encore", token, map[string]interface{}{
    "name": instanceName,
  })

  if err != nil {
    fmt.Println("Error creating instance:", err)
  } else {
    fmt.Printf("Instance created: %s\n", instance)
  }
  
  err = osaasclient.RemoveInstance(ctx, "encore", instanceName, token)

  if err != nil {
    fmt.Println("Error removing instance:", err)
  } else {
    fmt.Printf("Instance %s removed\n", instanceName)
  }
}


Contributing

See CONTRIBUTING

License

This project is licensed under the MIT License, see LICENSE.

Support

Join our community on Slack where you can post any questions regarding any of our open source projects. Eyevinn's consulting business can also offer you:

  • Further development of this component
  • Customization and integration of this component into your platform
  • Support and maintenance agreement

Contact sales@eyevinn.se if you are interested.

About Eyevinn Technology

Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor. As our way to innovate and push the industry forward we develop proof-of-concepts and tools. The things we learn and the code we write we share with the industry in blogs and by open sourcing the code we have written.

Want to know more about Eyevinn and how it is to work here. Contact us at work@eyevinn.se!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServiceSecret

func AddServiceSecret(ctx *Context, serviceId, secretName, secretData string) error

func CreateInstance

func CreateInstance(ctx *Context, serviceId string, token string,
	body map[string]interface{}) (map[string]interface{}, error)

func GetInstance

func GetInstance(ctx *Context, serviceId string, name string, token string) (map[string]interface{}, error)

func GetLogsForInstance

func GetLogsForInstance(context *Context, serviceId, name, token string) ([]string, error)

func ListInstances

func ListInstances(context *Context, serviceId, token string) ([]map[string]interface{}, error)

func RemoveInstance

func RemoveInstance(ctx *Context, serviceId string, name string, token string) error

Types

type Auth

type Auth struct {
	Header string
	Value  string
}

type Context

type Context struct {
	PersonalAccessToken string
	Environment         string
}

func NewContext

func NewContext(config *ContextConfig) (*Context, error)

func (*Context) ActivateService

func (ctx *Context) ActivateService(serviceId string) error

func (*Context) GetEnvironment

func (ctx *Context) GetEnvironment() string

func (*Context) GetPersonalAccessToken

func (ctx *Context) GetPersonalAccessToken() string

func (*Context) GetServiceAccessToken

func (ctx *Context) GetServiceAccessToken(serviceId string) (string, error)

func (*Context) RefreshServiceAccessToken

func (ctx *Context) RefreshServiceAccessToken(serviceId string) (string, error)

type ContextConfig

type ContextConfig struct {
	PersonalAccessToken string
	Environment         string
}

type FetchError

type FetchError struct {
	HTTPCode int
	Message  string
}

func (FetchError) Error

func (e FetchError) Error() string

type Port

type Port struct {
	ExternalIP   string `json:"externalIp"`
	ExternalPort int    `json:"externalPort"`
	InternalPort int    `json:"internalPort"`
}

func GetPortsForInstance

func GetPortsForInstance(context *Context, serviceId, name, token string) ([]Port, error)

type Service

type Service struct {
	ServiceId              string                  `json:"serviceId"`
	Metadata               ServiceMetadata         `json:"serviceMetadata"`
	ApiUrl                 string                  `json:"apiUrl"`
	ServiceInstanceOptions []ServiceInstanceOption `json:"serviceInstanceOptions"`
	OpenSourceLicense      string                  `json:"openSourceLicense"`
	OpenSourceLicenseText  string                  `json:"openSourceLicenseText"`
	ServiceType            string                  `json:"serviceType"`
	Status                 string                  `json:"status"`
}

func GetService

func GetService(ctx *Context, serviceId string) (*Service, error)

type ServiceAccessToken

type ServiceAccessToken struct {
	ServiceId string `json:"serviceId"`
	Token     string `json:"token"`
	Expiry    int64  `json:"expiry"`
}

type ServiceInstanceOption added in v0.0.4

type ServiceInstanceOption struct {
	Name        string   `json:"name"`
	Label       string   `json:"label"`
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Enum        []string `json:"enums"`
	Mandatory   bool     `json:"mandatory"`
}

type ServiceMetadata added in v0.0.4

type ServiceMetadata struct {
	OwnerTeamId       string          `json:"ownerTeamId"`
	CompanyName       string          `json:"companyName"`
	Title             string          `json:"title"`
	Description       string          `json:"description"`
	DocumentationUrl  string          `json:"documentationUrl"`
	RepoUrl           string          `json:"repoUrl"`
	ImagePreviewUrl   string          `json:"imagePreviewUrl"`
	InstanceNoun      string          `json:"instanceNoun"`
	IndicativePricing string          `json:"indicativePricing"`
	SubscriptionFee   SubscriptionFee `json:"subscriptionFee"`
	ExcludeFromFree   bool            `json:"excludeFromFree"`
	Category          string          `json:"category"`
	Keywords          []string        `json:"keywords"`
}

type SubscriptionFee added in v0.0.4

type SubscriptionFee struct {
	CurrencyCode string  `json:"currencyCode"`
	Value        float64 `json:"value"`
}

type Subscriptions

type Subscriptions struct {
	TeamId   string   `json:"teamId"`
	Services []string `json:"services"`
}

type UnauthorizedError

type UnauthorizedError struct{}

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

Jump to

Keyboard shortcuts

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