models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2015 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceApp       int = 1
	ResourceBundle    int = 2
	ResourceAuthority int = 3
)
View Source
const (
	ActionCreate   int = 1
	ActionDelete   int = 2
	ActionDownload int = 3
)
View Source
const (
	PlistFileName                   = "test.plist"
	AssetKind                       = "software-package"
	DefaultMetadataBundleIdentifier = "com.example.test"
	MetadataKind                    = "software"
)
View Source
const (
	SignatureExpireDuration      = 15 * time.Minute
	SignaturePermittedHttpMethod = "GET"
)

Variables

This section is empty.

Functions

func CreateApp

func CreateApp(txn gorp.SqlExecutor, s *GoogleService, app *App) error

func CreateAudit

func CreateAudit(txn gorp.SqlExecutor, audit *Audit) error

func CreateBundle

func CreateBundle(txn gorp.SqlExecutor, bundle *Bundle) error

func CreateOAuthConfig

func CreateOAuthConfig(config *WebApplicationConfig, tokenCache oauth.Cache) *oauth.Config

func CreateUser

func CreateUser(txn gorp.SqlExecutor, user *User) error

func GenerateApiDocumentHtml

func GenerateApiDocumentHtml(srcPath string) (string, error)

func GetServiceAccountToken

func GetServiceAccountToken(config *ServiceAccountConfig) (*oauth.Token, error)

func IsExistAuthorityForEmail

func IsExistAuthorityForEmail(txn gorp.SqlExecutor, email string) (bool, error)

func NewToken

func NewToken() string

func ParseGoogleApiError

func ParseGoogleApiError(apiErr error) (int, string, error)

func RenderMarkdown

func RenderMarkdown(md string) (string, error)

func Transact

func Transact(dbm *gorp.DbMap, f func(gorp.SqlExecutor) error) error

Types

type App

type App struct {
	Id          int       `db:"id"`
	Title       string    `db:"title"`
	FileId      string    `db:"file_id"`
	ApiToken    string    `db:"api_token"`
	Description string    `db:"description"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

https://github.com/coopernurse/gorp#mapping-structs-to-tables

func GetApp

func GetApp(txn gorp.SqlExecutor, id int) (*App, error)

func GetAppByApiToken

func GetAppByApiToken(txn gorp.SqlExecutor, apiToken string) (*App, error)

func GetApps

func GetApps(txn gorp.SqlExecutor, fileIds []string) ([]*App, error)

func (*App) Authorities

func (app *App) Authorities(txn gorp.SqlExecutor) ([]*Authority, error)

func (*App) Bundles

func (app *App) Bundles(txn gorp.SqlExecutor) ([]*Bundle, error)

func (*App) BundlesByPlatformType

func (app *App) BundlesByPlatformType(txn gorp.SqlExecutor, platformType BundlePlatformType) ([]*Bundle, error)

func (*App) BundlesWithPager

func (app *App) BundlesWithPager(txn gorp.SqlExecutor, page, limit int) (Bundles, int, error)

func (*App) CreateAuthority

func (app *App) CreateAuthority(txn gorp.SqlExecutor, s *GoogleService, authority *Authority) error

func (*App) CreateBundle

func (app *App) CreateBundle(dbm *gorp.DbMap, s *GoogleService, bundle *Bundle) error

func (*App) Delete

func (app *App) Delete(txn gorp.SqlExecutor, s *GoogleService) error

func (*App) DeleteAuthorities

func (app *App) DeleteAuthorities(txn gorp.SqlExecutor) error

func (*App) DeleteAuthority

func (app *App) DeleteAuthority(txn gorp.SqlExecutor, s *GoogleService, authority *Authority) error

func (*App) DeleteBundles

func (app *App) DeleteBundles(txn gorp.SqlExecutor) error

func (*App) DeleteFromDB

func (app *App) DeleteFromDB(txn gorp.SqlExecutor) error

func (*App) DeleteFromGoogleDrive

func (app *App) DeleteFromGoogleDrive(s *GoogleService) error

func (*App) GetMaxRevisionByBundleVersion

func (app *App) GetMaxRevisionByBundleVersion(txn gorp.SqlExecutor, bundleVersion string) (int, error)

func (*App) HasAuthorityForEmail

func (app *App) HasAuthorityForEmail(txn gorp.SqlExecutor, email string) (bool, error)

func (*App) ParentReference

func (app *App) ParentReference() *drive.ParentReference

func (*App) PreUpdate

func (app *App) PreUpdate(s gorp.SqlExecutor) error

func (*App) RefreshToken

func (app *App) RefreshToken(txn gorp.SqlExecutor) error

func (*App) Save

func (app *App) Save(txn gorp.SqlExecutor) error

func (*App) Update

func (app *App) Update(txn gorp.SqlExecutor) error

type Asset

type Asset struct {
	Kind string `plist:"kind"`
	Url  string `plist:"url"`
}

type Audit

type Audit struct {
	Id         int       `db:"id"`
	UserId     int       `db:"user_id"`
	Resource   int       `db:"resource"`
	ResourceId int       `db:"resource_id"`
	Action     int       `db:"action"`
	CreatedAt  time.Time `db:"created_at"`
	UpdatedAt  time.Time `db:"updated_at"`
}

func GetAudit

func GetAudit(txn gorp.SqlExecutor, id int) (*Audit, error)

func (*Audit) Delete

func (audit *Audit) Delete(txn gorp.SqlExecutor) error

func (*Audit) PreInsert

func (audit *Audit) PreInsert(s gorp.SqlExecutor) error

func (*Audit) PreUpdate

func (audit *Audit) PreUpdate(s gorp.SqlExecutor) error

func (*Audit) Save

func (audit *Audit) Save(txn gorp.SqlExecutor) error

func (*Audit) Update

func (audit *Audit) Update(txn gorp.SqlExecutor) error

func (*Audit) Validate

func (audit *Audit) Validate(v *revel.Validation)

type Authority

type Authority struct {
	Id           int       `db:"id"`
	AppId        int       `db:"app_id"`
	PermissionId string    `db:"permission_id"`
	Email        string    `db:"email"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

func GetAuthority

func GetAuthority(txn gorp.SqlExecutor, id int) (*Authority, error)

func (*Authority) DeleteFromDB

func (authority *Authority) DeleteFromDB(txn gorp.SqlExecutor) error

func (*Authority) PreInsert

func (authority *Authority) PreInsert(s gorp.SqlExecutor) error

func (*Authority) PreUpdate

func (authority *Authority) PreUpdate(s gorp.SqlExecutor) error

func (*Authority) Save

func (authority *Authority) Save(txn gorp.SqlExecutor) error

type Bundle

type Bundle struct {
	Id               int                `db:"id"`
	AppId            int                `db:"app_id"`
	FileId           string             `db:"file_id"`
	PlatformType     BundlePlatformType `db:"platform_type"`
	BundleVersion    string             `db:"bundle_version"`
	BundleIdentifier string             `db:"bundle_identifier"`
	Revision         int                `db:"revision"`
	Description      string             `db:"description"`
	CreatedAt        time.Time          `db:"created_at"`
	UpdatedAt        time.Time          `db:"updated_at"`

	BundleInfo *BundleInfo `db:"-"`
	File       *os.File    `db:"-"`
	FileName   string      `db:"-"`
}

func GetBundle

func GetBundle(txn gorp.SqlExecutor, id int) (*Bundle, error)

func GetBundleByFileId

func GetBundleByFileId(txn gorp.SqlExecutor, fileId string) (*Bundle, error)

func (*Bundle) App

func (bundle *Bundle) App(txn gorp.SqlExecutor) (*App, error)

func (*Bundle) BuildFileName

func (bundle *Bundle) BuildFileName() string

func (*Bundle) Delete

func (bundle *Bundle) Delete(txn gorp.SqlExecutor, s *GoogleService) error

func (*Bundle) DeleteFromDB

func (bundle *Bundle) DeleteFromDB(txn gorp.SqlExecutor) error

func (*Bundle) DeleteFromGoogleDrive

func (bundle *Bundle) DeleteFromGoogleDrive(s *GoogleService) error

func (*Bundle) IsApk

func (bundle *Bundle) IsApk() bool

func (*Bundle) IsIpa

func (bundle *Bundle) IsIpa() bool

func (*Bundle) JsonResponse

func (bundle *Bundle) JsonResponse(ub UriBuilder) (*BundleJsonResponse, error)

func (*Bundle) Plist

func (bundle *Bundle) Plist(txn gorp.SqlExecutor, ipaUrl *url.URL) (*Plist, error)

func (*Bundle) PlistReader

func (bundle *Bundle) PlistReader(txn gorp.SqlExecutor, ipaUrl *url.URL) (io.Reader, error)

func (*Bundle) PreInsert

func (bundle *Bundle) PreInsert(s gorp.SqlExecutor) error

func (*Bundle) PreUpdate

func (bundle *Bundle) PreUpdate(s gorp.SqlExecutor) error

func (*Bundle) Save

func (bundle *Bundle) Save(txn gorp.SqlExecutor) error

func (*Bundle) Update

func (bundle *Bundle) Update(txn gorp.SqlExecutor) error

type BundleFileExtension

type BundleFileExtension string
const (
	BundleFileExtensionAndroid BundleFileExtension = ".apk"
	BundleFileExtensionIOS     BundleFileExtension = ".ipa"
)

func (BundleFileExtension) IsValid

func (ext BundleFileExtension) IsValid() bool

func (BundleFileExtension) PlatformType

func (ext BundleFileExtension) PlatformType() BundlePlatformType

type BundleInfo

type BundleInfo struct {
	Version      string
	Identifier   string
	PlatformType BundlePlatformType
}

a BundleInfo is information of an application package(apk file, ipa file, etc.)

func NewBundleInfo

func NewBundleInfo(file *os.File, platformType BundlePlatformType) (*BundleInfo, error)

type BundleJsonResponse

type BundleJsonResponse struct {
	FileId       string `json:"file_id"`
	Version      string `json:"version"`
	Revision     int    `json:"revision"`
	InstallUrl   string `json:"install_url"`
	QrCodeUrl    string `json:"qr_code_url"`
	PlatformType string `json:"platform_type"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
}

type BundleParseError

type BundleParseError struct {
	Offset int64
}

func (*BundleParseError) Error

func (e *BundleParseError) Error() string

type BundlePlatformType

type BundlePlatformType int
const (
	BundlePlatformTypeAndroid BundlePlatformType = 1 + iota
	BundlePlatformTypeIOS
)

func (BundlePlatformType) Extention

func (platformType BundlePlatformType) Extention() BundleFileExtension

func (BundlePlatformType) String

func (platformType BundlePlatformType) String() string

type Bundles

type Bundles []*Bundle

func (Bundles) JsonResponse

func (bundles Bundles) JsonResponse(ub UriBuilder) ([]*BundleJsonResponse, error)

type BundlesJsonResponse

type BundlesJsonResponse struct {
	TotalCount int                   `json:"total_count"`
	Page       int                   `json:"page"`
	Limit      int                   `json:"limit"`
	Bundles    []*BundleJsonResponse `json:"bundles"`
}

type CapacityInfo

type CapacityInfo struct {
	Used               string
	Total              string
	PercentageRemained string
}

type GoogleService

type GoogleService struct {
	AccessToken        string
	Client             *http.Client
	OAuth2Service      *oauth2.Service
	DriveService       *drive.Service
	AboutService       *drive.AboutService
	FilesService       *drive.FilesService
	PermissionsService *drive.PermissionsService
}

func NewGoogleService

func NewGoogleService(token *oauth.Token) (*GoogleService, error)

func (*GoogleService) CreateFolder

func (s *GoogleService) CreateFolder(folderName string) (*drive.File, error)

func (*GoogleService) CreateUserPermission

func (s *GoogleService) CreateUserPermission(email string, role string) *drive.Permission

func (*GoogleService) DeleteAllFiles

func (s *GoogleService) DeleteAllFiles() error

func (*GoogleService) DeleteFile

func (s *GoogleService) DeleteFile(fileId string) error

func (*GoogleService) DeletePermission

func (s *GoogleService) DeletePermission(fileId string, permissionId string) error

func (*GoogleService) DownloadFile

func (s *GoogleService) DownloadFile(fileId string) (*http.Response, *drive.File, error)

func (*GoogleService) GetAbout

func (s *GoogleService) GetAbout() (*drive.About, error)

func (*GoogleService) GetCapacityInfo

func (s *GoogleService) GetCapacityInfo() (*CapacityInfo, error)

func (*GoogleService) GetFile

func (s *GoogleService) GetFile(fileId string) (*drive.File, error)

func (*GoogleService) GetFileList

func (s *GoogleService) GetFileList() (*drive.FileList, error)

func (*GoogleService) GetPermissionList

func (s *GoogleService) GetPermissionList(fileId string) (*drive.PermissionList, error)

func (*GoogleService) GetSharedFileList

func (s *GoogleService) GetSharedFileList(ownerEmail string) (*drive.FileList, error)

func (*GoogleService) GetTokenInfo

func (s *GoogleService) GetTokenInfo() (*oauth2.Tokeninfo, error)

func (*GoogleService) GetUserInfo

func (s *GoogleService) GetUserInfo() (*oauth2.Userinfoplus, error)

func (*GoogleService) InsertFile

func (s *GoogleService) InsertFile(file *os.File, filename string, parent *drive.ParentReference) (*drive.File, error)

func (*GoogleService) InsertPermission

func (s *GoogleService) InsertPermission(fileId string, permission *drive.Permission) (*drive.Permission, error)

func (*GoogleService) UpdateFileTitle

func (s *GoogleService) UpdateFileTitle(fileId string, title string) error

func (*GoogleService) UpdatePermission

func (sa *GoogleService) UpdatePermission(fileId string, permissionId string, permission *drive.Permission) (*drive.Permission, error)

type Item

type Item struct {
	Assets   []*Asset  `plist:"assets"`
	Metadata *Metadata `plist:"metadata"`
}

type LimitedTimeSignatureInfo

type LimitedTimeSignatureInfo struct {
	Signature   string
	ParamToSign *ParamToSign
}

func NewLimitedTimeSignatureInfo

func NewLimitedTimeSignatureInfo(host, path string) *LimitedTimeSignatureInfo

func (*LimitedTimeSignatureInfo) IsExpired

func (signatureInfo *LimitedTimeSignatureInfo) IsExpired() (bool, error)

func (*LimitedTimeSignatureInfo) IsValid

func (signatureInfo *LimitedTimeSignatureInfo) IsValid(key string) (bool, error)

func (*LimitedTimeSignatureInfo) RefreshSignature

func (signatureInfo *LimitedTimeSignatureInfo) RefreshSignature(key string)

func (*LimitedTimeSignatureInfo) UrlValues

func (signatureInfo *LimitedTimeSignatureInfo) UrlValues() *url.Values

type Metadata

type Metadata struct {
	BundleIdentifier string `plist:"bundle-identifier"`
	BundleVersion    string `plist:"bundle-version"`
	Kind             string `plist:"kind"`
	Title            string `plist:"title"`
}

type ParamToSign

type ParamToSign struct {
	Method string
	Host   string
	Path   string
	Token  string
	Limit  string
}

func (*ParamToSign) String

func (param *ParamToSign) String() string

type Plist

type Plist struct {
	Items []*Item `plist:"items"`
}

func NewPlist

func NewPlist(title, version, identifier, ipaUrl string) *Plist

func (*Plist) Marshall

func (p *Plist) Marshall() ([]byte, error)

func (*Plist) Reader

func (p *Plist) Reader() (io.Reader, error)

type ServiceAccountConfig

type ServiceAccountConfig struct {
	ClientEmail string
	PrivateKey  string
	Scope       []string
}

type UriBuilder

type UriBuilder interface {
	UriFor(string) (*url.URL, error)
}

type User

type User struct {
	Id        int       `db:"id"`
	Email     string    `db:"email"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func FindOrCreateUser

func FindOrCreateUser(txn gorp.SqlExecutor, email string) (*User, error)

func GetUser

func GetUser(txn gorp.SqlExecutor, id int) (*User, error)

func GetUserFromEmail

func GetUserFromEmail(txn gorp.SqlExecutor, email string) (*User, error)

func (*User) Delete

func (user *User) Delete(txn gorp.SqlExecutor) error

func (*User) PreInsert

func (user *User) PreInsert(s gorp.SqlExecutor) error

func (*User) PreUpdate

func (user *User) PreUpdate(s gorp.SqlExecutor) error

func (*User) Save

func (user *User) Save(txn gorp.SqlExecutor) error

func (*User) Update

func (user *User) Update(txn gorp.SqlExecutor) error

func (*User) Validate

func (user *User) Validate(v *revel.Validation)

type WebApplicationConfig

type WebApplicationConfig struct {
	ClientId     string
	ClientSecret string
	CallbackUrl  string
	Scope        []string
}

Jump to

Keyboard shortcuts

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