rest

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

JSON structs for Firebase Hosting API responses

GCS Google Cloud Storage API

Index

Constants

View Source
const REST_PAGE_SIZE = 1000

Variables

View Source
var FlagConn *int
View Source
var StorageFilterImages = func(attrs *storage.ObjectAttrs) bool {
	for _, t := range imageContentTypes {
		if attrs.ContentType == t {
			return true
		}
	}
	return false
}

filter only image types

Functions

This section is empty.

Types

type AuthorizedHTTPClient

type AuthorizedHTTPClient struct {
	*http.Client
	// contains filtered or unexported fields
}

an http client with oauth2 credentials attached

func AuthorizeClientDefault

func AuthorizeClientDefault(ctx context.Context) (*AuthorizedHTTPClient, error)

use ADC creds to authorize the default client

func (*AuthorizedHTTPClient) RestCreateVersion

func (client *AuthorizedHTTPClient) RestCreateVersion(site string) (r VersionCreateReturn, e error)

rest call to create new version on Firebase Hosting

func (*AuthorizedHTTPClient) RestCreateVersionPopulateFiles

func (client *AuthorizedHTTPClient) RestCreateVersionPopulateFiles(stagingDir string, versionId string) (vpfrs []VersionPopulateFilesReturn, err error)

rest populate files

func (*AuthorizedHTTPClient) RestReleasesCreate

func (client *AuthorizedHTTPClient) RestReleasesCreate(site, versionId string) (r ReleasesCreateReturn, e error)

rest call create new release on firebase sites

func (*AuthorizedHTTPClient) RestUploadFile

func (client *AuthorizedHTTPClient) RestUploadFile(bodyFile io.Reader, shaHash, versionId string) error

rest call to upload file contents

func (*AuthorizedHTTPClient) RestUploadFileList

func (client *AuthorizedHTTPClient) RestUploadFileList(versionId string, manifestSet []VersionPopulateFilesReturn, stagingDir string) []error

rest call to upload file list to firebase

func (*AuthorizedHTTPClient) RestVersionSetStatus

func (client *AuthorizedHTTPClient) RestVersionSetStatus(versionId string, status string) (r VersionStatusUpdateReturn, e error)

rest set status to published

func (*AuthorizedHTTPClient) StorageDownload

func (aClient *AuthorizedHTTPClient) StorageDownload(bucket string, prefix string, target string, filter StorageFilter) error

download from GCS storage bucket

type JWTConfig

type JWTConfig struct {
	Type                    string `json:"type"`
	ProjectID               string `json:"project_id"`
	PrivateKeyID            string `json:"private_key_id"`
	PrivateKey              string `json:"private_key"`
	ClientEmail             string `json:"client_email"`
	ClientID                string `json:"client_id"`
	AuthURI                 string `json:"auth_uri"`
	TokenURI                string `json:"token_uri"`
	AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
	ClientX509CertURL       string `json:"client_x509_cert_url"`
	UniverseDomain          string `json:"universe_domain"`
}

type ReleasesCreateReturn

type ReleasesCreateReturn struct {
	Name    string `json:"name"`
	Version struct {
		Name   string `json:"name"`
		Status string `json:"status"`
		Config struct {
			Headers []struct {
				Glob    string `json:"glob"`
				Headers struct {
					CacheControl string `json:"Cache-Control"`
				} `json:"headers"`
			} `json:"headers"`
		} `json:"config"`
	} `json:"version"`
	Type        string    `json:"type"`
	ReleaseTime time.Time `json:"releaseTime"`
}

type ResponseMessage

type ResponseMessage struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Status  string `json:"status"`
	} `json:"error"`
}

type StorageFilter

type StorageFilter func(attrs *storage.ObjectAttrs) bool

client-side filter function

type VersionCreateReturn

type VersionCreateReturn struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Config struct {
		Headers []struct {
			Glob    string `json:"glob"`
			Headers struct {
				CacheControl string `json:"Cache-Control"`
			} `json:"headers"`
		} `json:"headers"`
	} `json:"config"`
}

create version call

type VersionPopulateFilesRequestBody

type VersionPopulateFilesRequestBody struct {
	Files map[string]string `json:"files"`
}

Populate Files request

type VersionPopulateFilesReturn

type VersionPopulateFilesReturn struct {
	UploadRequiredHashes []string `json:"uploadRequiredHashes"`
	UploadURL            string   `json:"uploadUrl"`
}

Populate Files Response

type VersionStatusUpdateRequestBody

type VersionStatusUpdateRequestBody struct {
	Status string `json:"status"`
}

Version Status Update Request

type VersionStatusUpdateReturn

type VersionStatusUpdateReturn struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Config struct {
		Headers []struct {
			Glob    string `json:"glob"`
			Headers struct {
				CacheControl string `json:"Cache-Control"`
			} `json:"headers"`
		} `json:"headers"`
	} `json:"config"`
	CreateTime time.Time `json:"createTime"`
	CreateUser struct {
		Email string `json:"email"`
	} `json:"createUser"`
	FinalizeTime time.Time `json:"finalizeTime"`
	FinalizeUser struct {
		Email string `json:"email"`
	} `json:"finalizeUser"`
	FileCount    string `json:"fileCount"`
	VersionBytes string `json:"versionBytes"`
}

Jump to

Keyboard shortcuts

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