sources

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SOURCEREDIRECT represents the host address configuration name
	SOURCEREDIRECT = "source.redirect"
	//REDIRECT represents a query parameter that can be set to change source.redirect
	REDIRECT = "redirect"
)

Variables

This section is empty.

Functions

func ParseRecipe

func ParseRecipe(htmlFile io.Reader, fileID recipes.RecipeID) (*recipes.Recipe, map[string]*recipes.RecipePicture, error)

ParseRecipe transforms a html file to the Recipe format

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API related sourceDescription data

func NewSourceAPI

func NewSourceAPI(sources Sources, recipes recipes.RecipeDB) API

NewSourceAPI creates the API for sources

func (API) PrepareAPI

func (s API) PrepareAPI(router core.Handler, sources Sources, recipes recipes.RecipeDB)

PrepareAPI registers all api endpoints

type DefaultSources

type DefaultSources struct {
	// contains filtered or unexported fields
}

DefaultSources is the default implementation of a sourceClient repository

func (*DefaultSources) Add

func (s *DefaultSources) Add(sourceMeta *SourceDescription, source SourceClient) error

Add a sourceClient to the default sourceClient

func (*DefaultSources) Client

func (s *DefaultSources) Client(id SourceID) (SourceClient, error)

Client by id returns the corresponding sourceClient implementations

func (*DefaultSources) Description

func (s *DefaultSources) Description(id SourceID) (*SourceDescription, error)

Description will return a sourceClient's SourceDescription

func (*DefaultSources) JSON

func (s *DefaultSources) JSON() ([]byte, error)

JSON returns all sources as JSON

func (*DefaultSources) List

func (s *DefaultSources) List() (map[SourceID]*SourceDescription, error)

List all sources and the corresponding sourceDescription information

func (*DefaultSources) Remove

func (s *DefaultSources) Remove(source *SourceDescription) error

Remove will delete the given element from the repository. The deletion will use the sourceClient's id for this purpose.

func (*DefaultSources) RemoveByID

func (s *DefaultSources) RemoveByID(id SourceID) error

RemoveByID will delete the element with ID id from the repository

type DriveClient

type DriveClient struct {
	// contains filtered or unexported fields
}

DriveClient is handling the interaction with Drive

func OpenNewGoogleDriveConnection

func OpenNewGoogleDriveConnection() *DriveClient

OpenNewGoogleDriveConnection with an empty cache of recipes

func (*DriveClient) ConnectOAuth

func (c *DriveClient) ConnectOAuth(code string) (err error)

ConnectOAuth gets a new initial Token

func (*DriveClient) Connected

func (c *DriveClient) Connected() bool

Connected returns true if there is a connection established to Drive

func (*DriveClient) ID

func (c *DriveClient) ID() SourceID

ID of this SourceClient

func (*DriveClient) Name

func (c *DriveClient) Name() string

Name of this SourceClient

func (*DriveClient) OAuthLoginConfig

func (c *DriveClient) OAuthLoginConfig() (*oauth2.Config, error)

OAuthLoginConfig returns the configuration for the Authentication endpoint

func (*DriveClient) Recipes

func (c *DriveClient) Recipes() recipes.Recipes

Recipes of this SourceClient

func (*DriveClient) Refresh

func (c *DriveClient) Refresh() (err error)

Refresh cleans the internal cache of recipes and refreshes the token from file

func (*DriveClient) Version

func (c *DriveClient) Version() string

Version of this SourceClient

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source struct that combines SourceDescriptions with the SourceClient implementation

type SourceClient

type SourceClient interface {
	ConnectOAuth(code string) error
	Connected() bool
	Recipes() recipes.Recipes
	OAuthLoginConfig() (*oauth2.Config, error)
}

SourceClient interface

type SourceDescription

type SourceDescription struct {
	ID          SourceID       `json:"id"`
	Name        string         `json:"name"`
	Connected   bool           `json:"connected"`
	Version     string         `json:"version"`
	OAuthConfig *oauth2.Config `json:"-"`
}

SourceDescription describes the sourceClient in detail

func NewInvalidSourceDescription

func NewInvalidSourceDescription() *SourceDescription

NewInvalidSourceDescription returns a SourceDescription with all fields set to invalid values

func NewSourceDescription

func NewSourceDescription(id SourceID, name string, version string, oauthConfig *oauth2.Config) *SourceDescription

NewSourceDescription is the designated way to create a SourceDescription

type SourceID

type SourceID uuid.UUID

SourceID represents a unique id of a sourceClient

func SourceIDFromString

func SourceIDFromString(s string) (SourceID, error)

SourceIDFromString represents a unique id of a sourceClient

func (SourceID) String

func (s SourceID) String() string

String representation of a sourceClient's id

type SourceOAuthConnectResponse

type SourceOAuthConnectResponse struct {
	ID       string `json:"id"`
	OAuthURL string `json:"oAuthURL"`
}

SourceOAuthConnectResponse informs about the oAuth url

type SourceResponse

type SourceResponse struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Connected bool   `json:"connected"`
	Version   string `json:"version"`
}

SourceResponse describes a sourceClient in detail

type Sources

type Sources interface {
	JSON() ([]byte, error)
	List() (map[SourceID]*SourceDescription, error)
	Add(sourceMeta *SourceDescription, source SourceClient) error
	RemoveByID(id SourceID) error
	Remove(source *SourceDescription) error
	Description(id SourceID) (*SourceDescription, error)
	Client(id SourceID) (SourceClient, error)
}

Sources is the interface for all sourceClient repository implementations

func NewSources

func NewSources() Sources

NewSources creates and returns a new sourceClient repository

Jump to

Keyboard shortcuts

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