Documentation ¶
Index ¶
- Constants
- Variables
- func SetLogLevel(level LogLevel)
- type AnalyticsEventType
- type AuthEvent
- type AuthEventType
- type AuthenticationFunc
- type AuthenticationFunction
- func (a *AuthenticationFunction) Create(fn AuthenticationFunc) *AuthenticationFunction
- func (a *AuthenticationFunction) Delete(fn AuthenticationFunc) *AuthenticationFunction
- func (a *AuthenticationFunction) Event() EventType
- func (a *AuthenticationFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
- func (a *AuthenticationFunction) Name() string
- func (a *AuthenticationFunction) Resource() string
- type CloudDeployFunction
- type Decoder
- type EventType
- type FirestoreEvent
- type FirestoreEventType
- type FirestoreFunc
- type FirestoreFunction
- func (f *FirestoreFunction) Collection(ref string) *FirestoreFunction
- func (f *FirestoreFunction) Create(data interface{}, fn FirestoreFunc) *FirestoreFunction
- func (f *FirestoreFunction) Delete(data interface{}, fn FirestoreFunc) *FirestoreFunction
- func (f *FirestoreFunction) Document(ref string) *FirestoreFunction
- func (a *FirestoreFunction) Event() EventType
- func (a *FirestoreFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
- func (a *FirestoreFunction) Name() string
- func (f *FirestoreFunction) Path() string
- func (a *FirestoreFunction) Resource() string
- func (f *FirestoreFunction) Update(data interface{}, fn FirestoreFunc) *FirestoreFunction
- func (f *FirestoreFunction) Write(data interface{}, fn FirestoreFunc) *FirestoreFunction
- type FirestoreValue
- type FunctionRegistrar
- func (f *FunctionRegistrar) AllowUnauthenticated(t bool) *FunctionRegistrar
- func (f *FunctionRegistrar) Authentication() *AuthenticationFunction
- func (f *FunctionRegistrar) Deploy() (s string)
- func (f *FunctionRegistrar) DeployCloud() (s string)
- func (f *FunctionRegistrar) DeployHTTP() (s string)
- func (f *FunctionRegistrar) EntryPoint(ctx context.Context, dec *Decoder) error
- func (f *FunctionRegistrar) Firestore() *FirestoreFunction
- func (f *FunctionRegistrar) HTTP(path string, handler http.HandlerFunc) *HttpFunction
- func (f *FunctionRegistrar) HttpEntrypoint(w http.ResponseWriter, r *http.Request)
- func (f *FunctionRegistrar) MiddleWare(wares ...mux.MiddlewareFunc)
- func (f *FunctionRegistrar) PubSub(topic string) *PubSubFunction
- func (f *FunctionRegistrar) RealtimeDB() *RealtimeDBFunction
- func (f *FunctionRegistrar) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (f *FunctionRegistrar) Storage() *StorageFunction
- func (f *FunctionRegistrar) Verbosity(level VerbosityLevel) *FunctionRegistrar
- func (f *FunctionRegistrar) WithProjectID(id string) *FunctionRegistrar
- func (f *FunctionRegistrar) WithRegistrar(name string) *FunctionRegistrar
- func (f *FunctionRegistrar) WithRuntime(runtime Runtime) *FunctionRegistrar
- type HttpFunction
- type LogLevel
- type PubSubEventType
- type PubSubFunc
- type PubSubFunction
- func (a *PubSubFunction) Event() EventType
- func (a *PubSubFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
- func (a *PubSubFunction) Name() string
- func (p *PubSubFunction) Publish(data interface{}, fn PubSubFunc) *PubSubFunction
- func (a *PubSubFunction) Resource() string
- type PubSubMessage
- type RTDBEvent
- type RealtimeDBEventType
- type RealtimeDBFunc
- type RealtimeDBFunction
- func (r *RealtimeDBFunction) Create(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
- func (r *RealtimeDBFunction) Delete(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
- func (a *RealtimeDBFunction) Event() EventType
- func (a *RealtimeDBFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
- func (a *RealtimeDBFunction) Name() string
- func (r *RealtimeDBFunction) Path() string
- func (r *RealtimeDBFunction) Ref(ref string) *RealtimeDBFunction
- func (a *RealtimeDBFunction) Resource() string
- func (r *RealtimeDBFunction) Update(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
- func (r *RealtimeDBFunction) Write(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
- type RemoteConfigEventType
- type Runtime
- type SchedulerEventType
- type StorageEvent
- type StorageEventType
- type StorageFunc
- type StorageFunction
- func (s *StorageFunction) Archive(fn StorageFunc) *StorageFunction
- func (s *StorageFunction) Bucket(path string) *StorageFunction
- func (s *StorageFunction) Delete(fn StorageFunc) *StorageFunction
- func (a *StorageFunction) Event() EventType
- func (s *StorageFunction) Finalize(fn StorageFunc) *StorageFunction
- func (a *StorageFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
- func (s *StorageFunction) MetadataUpdate(fn StorageFunc) *StorageFunction
- func (a *StorageFunction) Name() string
- func (a *StorageFunction) Resource() string
- type VerbosityLevel
Constants ¶
const ( // Google Analytics Firebase event types AnalyticsLogEvent AnalyticsEventType = "providers/google.firebase.analytics/eventTypes/event.log" // Authentication event types AuthenticationUserCreateEvent AuthEventType = "providers/firebase.auth/eventTypes/user.create" AuthenticationUserDeleteEvent AuthEventType = "providers/firebase.auth/eventTypes/user.delete" // Firestore event types FirestoreDocumentCreateEvent FirestoreEventType = "providers/cloud.firestore/eventTypes/document.create" FirestoreDocumentDeleteEvent FirestoreEventType = "providers/cloud.firestore/eventTypes/document.delete" FirestoreDocumentUpdateEvent FirestoreEventType = "providers/cloud.firestore/eventTypes/document.update" FirestoreDocumentWriteEvent FirestoreEventType = "providers/cloud.firestore/eventTypes/document.write" // Pub/Sub event types PubSubPublishEvent PubSubEventType = "google.pubsub.topic.publish" // Realtime Database event types RealtimeDBRefCreateEvent RealtimeDBEventType = "providers/google.firebase.database/eventTypes/ref.create" RealtimeDBRefDeleteEvent RealtimeDBEventType = "providers/google.firebase.database/eventTypes/ref.delete" RealtimeDBRefUpdateEvent RealtimeDBEventType = "providers/google.firebase.database/eventTypes/ref.update" RealtimeDBRefWriteEvent RealtimeDBEventType = "providers/google.firebase.database/eventTypes/ref.write" // Firebase Remote Config event types RemoteConfigUpdateEvent RemoteConfigEventType = "remoteConfig.update" // Scheduler event types SchedulerRunEvent SchedulerEventType = "google.pubsub.topic.publish" // Storage event types StorageObjectArchiveEvent StorageEventType = "google.storage.object.archive" StorageObjectDeleteEvent StorageEventType = "google.storage.object.delete" StorageObjectFinalizeEvent StorageEventType = "google.storage.object.finalize" StorageObjectMetadataUpdateEvent StorageEventType = "google.storage.object.metadataUpdate" )
Variables ¶
var ()
Functions ¶
func SetLogLevel ¶
func SetLogLevel(level LogLevel)
SetLogLevel is a wrapper for setting the logrus.Level
Types ¶
type AnalyticsEventType ¶
type AnalyticsEventType EventType
AnalyticsEventType is the event type for Analytics CloudEvents
func (AnalyticsEventType) String ¶
func (e AnalyticsEventType) String() string
String returns a minimal/readable representation of the event type
func (AnalyticsEventType) Type ¶
func (e AnalyticsEventType) Type() EventType
Type returns the event type
func (AnalyticsEventType) Valid ¶
func (a AnalyticsEventType) Valid() bool
Valid reports whether the AnalyticsEventType is valid
type AuthEvent ¶
type AuthEvent struct { Email string `json:"email"` Metadata struct { CreatedAt time.Time `json:"createdAt"` } `json:"metadata"` ProviderData []struct { Email string `json:"email"` Provider string `json:"providerId"` UID string `json:"uid"` } `json:"providerData"` UID string `json:"uid"` }
AuthEvent is the expected payload for Firestore Auth CloudEvents.
type AuthEventType ¶
type AuthEventType EventType
AuthEventType is the event type for Firebase Authentication CloudEvents
func (AuthEventType) String ¶
func (e AuthEventType) String() string
String returns a minimal/readable representation of the event type
func (AuthEventType) Valid ¶
func (a AuthEventType) Valid() bool
Valid reports whether the AuthEventType is valid
type AuthenticationFunc ¶
AuthenticationFunc is the function signature for the Firebase Authentication CloudEvent
type AuthenticationFunction ¶
type AuthenticationFunction struct {
// contains filtered or unexported fields
}
AuthenticationFunction is a wrapper for the AuthenticationFunc and the parent FunctionRegistrar Implements the CloudEventFunction interface
func (*AuthenticationFunction) Create ¶
func (a *AuthenticationFunction) Create(fn AuthenticationFunc) *AuthenticationFunction
Create registers the specified function to the UserCreated event for the Firebase Authentication CloudEvent providers/firebase.auth/eventTypes/user.create
func (*AuthenticationFunction) Delete ¶
func (a *AuthenticationFunction) Delete(fn AuthenticationFunc) *AuthenticationFunction
Delete registers the specified function to the UserDeleted event for the Firebase Authentication CloudEvent providers/firebase.auth/eventTypes/user.delete
func (*AuthenticationFunction) Event ¶
func (a *AuthenticationFunction) Event() EventType
Event returns the EventType of the function: AuthenticationUserCreateEvent / AuthenticationUserDeleteEvent
func (*AuthenticationFunction) HandleCloudEvent ¶
func (a *AuthenticationFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
HandleCloudEvent handles the Firebase Authentication CloudEvent and calls the registered AuthenticationFunction
func (*AuthenticationFunction) Name ¶
func (a *AuthenticationFunction) Name() string
Name returns the name of the function: "auth.user.{create,delete}"
func (*AuthenticationFunction) Resource ¶
func (a *AuthenticationFunction) Resource() string
Resource returns the resource of the function: "providers/firebase.auth/eventTypes/user.{create,delete}"
type CloudDeployFunction ¶
type CloudDeployFunction interface { HandleCloudEvent(context.Context, *metadata.Metadata, *Decoder) error Name() string Resource() string Event() EventType }
CloudDeployFunction can be implemented by an event handler function
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a helper to retrieve the JSON data from the request
func (*Decoder) UnmarshalJSON ¶
UnmarshalJSON is a custom marshaller for the Decoder
type FirestoreEvent ¶
type FirestoreEvent struct { OldValue FirestoreValue `json:"oldValue"` Value FirestoreValue `json:"value"` UpdateMask struct { FieldPaths []string `json:"fieldPaths"` } `json:"updateMask"` // contains filtered or unexported fields }
FirestoreEvent is the expected payload for Firestore CloudEvents
func (*FirestoreEvent) Copy ¶
func (e *FirestoreEvent) Copy(v interface{}) error
Copy recursively copies the fields received in the FirestoreEvent to the struct provided to the calling FirestoreFunc The struct must have the same fields as the named fields received by the payload
func (*FirestoreEvent) Vars ¶
func (e *FirestoreEvent) Vars() map[string]string
Vars is used to access the segment positions var names for access within the function
type FirestoreEventType ¶
type FirestoreEventType EventType
FirestoreEventType is the event type for Firestore CloudEvents
func (FirestoreEventType) String ¶
func (e FirestoreEventType) String() string
String returns a minimal/readable representation of the event type
func (FirestoreEventType) Type ¶
func (e FirestoreEventType) Type() EventType
Type returns the event type
func (FirestoreEventType) Valid ¶
func (f FirestoreEventType) Valid() bool
Valid reports whether the FirstoreEventType is valid
type FirestoreFunc ¶
type FirestoreFunc func(ctx context.Context, e FirestoreEvent) error
FirestoreFunc is the function signature for Firestore Cloud Events
type FirestoreFunction ¶
type FirestoreFunction struct {
// contains filtered or unexported fields
}
FirestoreFunction is a wrapper for the expected data, FirestoreFunc and the parent FunctionRegistrar Implements the CloudEventFunction interface
func (*FirestoreFunction) Collection ¶
func (f *FirestoreFunction) Collection(ref string) *FirestoreFunction
Collection appends the given path to the ref that the FirestoreFunc is executed on. Will replace existing collection segment if it exists Meant to be chained with .Document()
func (*FirestoreFunction) Create ¶
func (f *FirestoreFunction) Create(data interface{}, fn FirestoreFunc) *FirestoreFunction
Create registers the specified function to the DocumentCreateEvent for Firestore CloudEvent The provided data is used to populate the Value.Fields of the FirestoreEvent received by the function providers/cloud.firestore/eventTypes/document.create
func (*FirestoreFunction) Delete ¶
func (f *FirestoreFunction) Delete(data interface{}, fn FirestoreFunc) *FirestoreFunction
Delete registers the specified function to the DocumentDeleteEvent for Firestore CloudEvent The provided data is used to populate the OldValue.Fields of the FirestoreEvent received by the function providers/cloud.firestore/eventTypes/document.delete
func (*FirestoreFunction) Document ¶
func (f *FirestoreFunction) Document(ref string) *FirestoreFunction
Document appends the given path to the path that the FirestoreFunc is executed on. Will replace existing document segment if it exists Meant to be chained with .Collection()
func (*FirestoreFunction) Event ¶
func (a *FirestoreFunction) Event() EventType
Event returns the EventType of the function:
FirestoreDocumentCreateEvent / FirestoreDocumentUpdateEvent / FirestoreDocumentDeleteEvent /FirestoreDocumentWriteEvent
func (*FirestoreFunction) HandleCloudEvent ¶
func (a *FirestoreFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
HandleCloudEvent handles the Firebase Firestore CloudEvent and calls the registered FirestoreFunction
func (*FirestoreFunction) Name ¶
func (a *FirestoreFunction) Name() string
Name returns the name of the function: "firestore.doc.{create,delete,update,write}"
func (*FirestoreFunction) Path ¶
func (f *FirestoreFunction) Path() string
Path creates a path for the Firestore event that can be used for registering a function returns the path with all wildcard fields replaced with "*" and saves a map of the segment positions var names for access within the function
func (*FirestoreFunction) Resource ¶
func (a *FirestoreFunction) Resource() string
Resource returns the resource of the function: "collection/{document-id}/...."
func (*FirestoreFunction) Update ¶
func (f *FirestoreFunction) Update(data interface{}, fn FirestoreFunc) *FirestoreFunction
Update registers the specified function to the DocumentUpdateEvent for Firestore CloudEvent The provided data is used to populate the Value.Fields and OldValue.Fields of the FirestoreEvent received by the function providers/cloud.firestore/eventTypes/document.update
func (*FirestoreFunction) Write ¶
func (f *FirestoreFunction) Write(data interface{}, fn FirestoreFunc) *FirestoreFunction
Write registers the specified function to the DocumentWriteEvent for Firestore CloudEvent The provided data is used to populate the Value.Fields and OldValue.Fields of the FirestoreEvent received by the function providers/cloud.firestore/eventTypes/document.write
type FirestoreValue ¶
type FirestoreValue struct { CreateTime time.Time `json:"createTime"` // Fields is the data for this value. The type depends on the format of your // database. Log the interface{} value and inspect the result to see a JSON // representation of your database fields. Fields interface{} `json:"fields"` Name string `json:"name"` // the path of the document UpdateTime time.Time `json:"updateTime"` }
FirestoreValue holds Firestore fields.
type FunctionRegistrar ¶
type FunctionRegistrar struct {
// contains filtered or unexported fields
}
FunctionRegistrar is the registrar for functions
func NewRegister ¶
func NewRegister() *FunctionRegistrar
NewRegister creates a new registrar with all top level maps initialized nested maps are intialized when a function is registered
func (*FunctionRegistrar) AllowUnauthenticated ¶ added in v0.0.10
func (f *FunctionRegistrar) AllowUnauthenticated(t bool) *FunctionRegistrar
func (*FunctionRegistrar) Authentication ¶
func (f *FunctionRegistrar) Authentication() *AuthenticationFunction
Authentication returns a new AuthenticationFunction with the FunctionRegistrar set to the parent
func (*FunctionRegistrar) Deploy ¶
func (f *FunctionRegistrar) Deploy() (s string)
func (*FunctionRegistrar) DeployCloud ¶ added in v0.0.9
func (f *FunctionRegistrar) DeployCloud() (s string)
func (*FunctionRegistrar) DeployHTTP ¶ added in v0.0.9
func (f *FunctionRegistrar) DeployHTTP() (s string)
func (*FunctionRegistrar) EntryPoint ¶
func (f *FunctionRegistrar) EntryPoint(ctx context.Context, dec *Decoder) error
The entrypoint for all functions. This is the function that is called when the function is triggered.
f := register.NewRegister() f.PubSub("topic").Publish(&mydata, myPubsubFunc)
now f.Entrypoint can be used as the entrypoint when deploying the function
func (*FunctionRegistrar) Firestore ¶
func (f *FunctionRegistrar) Firestore() *FirestoreFunction
Firestore returns a new FirestoreFunction with the FunctionRegistrar set to the parent
func (*FunctionRegistrar) HTTP ¶
func (f *FunctionRegistrar) HTTP(path string, handler http.HandlerFunc) *HttpFunction
HTTP registers the given path/name to an underlying mux.Router add advanced routing options (Headers, Methods) to the returned HttpFunction The deployment script for functions registered via this method will be in the below format:
~$ gcloud functions deploy --entrypoint "Registrar.HttpEntrypoint" Registrar --trigger-http --allow-unauthenticated
and can be executed like:
~$ curl "https://REGION-PROJECT_ID.cloudfunctions.net/Registrar/{path}"
func (*FunctionRegistrar) HttpEntrypoint ¶
func (f *FunctionRegistrar) HttpEntrypoint(w http.ResponseWriter, r *http.Request)
HttpEntrypoint is the entrypoint for http functions it will route the request to the correct function
func (*FunctionRegistrar) MiddleWare ¶
func (f *FunctionRegistrar) MiddleWare(wares ...mux.MiddlewareFunc)
Middleware registers the given mux.MiddlewareFunc to the underlying mux.Router
func (*FunctionRegistrar) PubSub ¶
func (f *FunctionRegistrar) PubSub(topic string) *PubSubFunction
PubSub registers a function to the specified event, or returns the existing function if one already exists
func (*FunctionRegistrar) RealtimeDB ¶
func (f *FunctionRegistrar) RealtimeDB() *RealtimeDBFunction
RealtimeDB returns a new RealtimeDBFunction with the FunctionRegistrar set to the parent
func (*FunctionRegistrar) ServeHTTP ¶ added in v0.0.9
func (f *FunctionRegistrar) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*FunctionRegistrar) Storage ¶
func (f *FunctionRegistrar) Storage() *StorageFunction
Storage returns a new StorageFunction with the FunctionRegistrar set to the parent
func (*FunctionRegistrar) Verbosity ¶
func (f *FunctionRegistrar) Verbosity(level VerbosityLevel) *FunctionRegistrar
Verbosity sets the verbosity level for the deploy command
func (*FunctionRegistrar) WithProjectID ¶
func (f *FunctionRegistrar) WithProjectID(id string) *FunctionRegistrar
WithProjectID sets the project id for the functions when deploying otherwise it will exclude the --project flag from the deploy command most often the project id is the simply the project name in kebab case eg. my-project-name
func (*FunctionRegistrar) WithRegistrar ¶ added in v0.0.9
func (f *FunctionRegistrar) WithRegistrar(name string) *FunctionRegistrar
WithRegistrar sets the entry point for the functions when deploying this is the actual name of the variable in your source code otherwise it will use the register.SharedEntryPoint again this assumes you have imported this package as register and you have registered your functions using register.Shared
Cloud Functions may fail to deploy if the name provided here is undefined or unexported in the top level of your package being deployed.
For example:
var FancyRegistrar = register.NewRegister().WithRegistrar("FancyRegistrar")
func (*FunctionRegistrar) WithRuntime ¶
func (f *FunctionRegistrar) WithRuntime(runtime Runtime) *FunctionRegistrar
WithRuntime sets the runtime for the functions when deploying
type HttpFunction ¶
type HttpFunction struct {
// contains filtered or unexported fields
}
HttpFunction is a wrapper for mux.Route and the parent FunctionRegistrar
func (*HttpFunction) Headers ¶
func (h *HttpFunction) Headers(pairs ...string) *HttpFunction
Headers registers the given headers to the underlying mux.Route
func (*HttpFunction) Host ¶
func (h *HttpFunction) Host(host string) *HttpFunction
Host registers the given host to the underlying mux.Route
func (*HttpFunction) Methods ¶
func (h *HttpFunction) Methods(methods ...string) *HttpFunction
Methods registers the given methods to the underlying mux.Route
func (*HttpFunction) Queries ¶
func (h *HttpFunction) Queries(queries ...string) *HttpFunction
Queries registers the given queries to the underlying mux.Route
type LogLevel ¶
type LogLevel int
LogLevel is a helper to log at different levels
type PubSubEventType ¶
type PubSubEventType EventType
PubSubEventType is the event type for Pub/Sub CloudEvents
func (PubSubEventType) String ¶
func (e PubSubEventType) String() string
String returns a minimal/readable representation of the event type
func (PubSubEventType) Valid ¶
func (p PubSubEventType) Valid() bool
Valid reports whether the PubSubEventType is valid
type PubSubFunc ¶
type PubSubFunc func(ctx context.Context, m PubSubMessage) error
PubSubFunc is the function signature for the Pub/Sub CloudEvent
type PubSubFunction ¶
type PubSubFunction struct {
// contains filtered or unexported fields
}
PubSubFunction is a wrapper for the PubSubFunc and the parent FunctionRegistrar Implements the CloudEventFunction interface
func (*PubSubFunction) Event ¶
func (a *PubSubFunction) Event() EventType
Event returns the EventType of the function: PubSubPublishEvent
func (*PubSubFunction) HandleCloudEvent ¶
func (a *PubSubFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
HandleCloudEvent handles the PubSub CloudEvent and calls the registered PubSubFunction
func (*PubSubFunction) Name ¶
func (a *PubSubFunction) Name() string
Name returns the name of the function: "pubsub.topic.publish/{topic}"
func (*PubSubFunction) Publish ¶
func (p *PubSubFunction) Publish(data interface{}, fn PubSubFunc) *PubSubFunction
Publish registers the specified function to the specific topic for the Pub/Sub CloudEvent The provided data is used to populate the Data field of the PubSubMessage received by the function google.pubsub.topic.publish
func (*PubSubFunction) Resource ¶
func (a *PubSubFunction) Resource() string
Resource returns the resource of the function: "{topic}"
type PubSubMessage ¶
type PubSubMessage struct { Topic string `json:"topic"` Data interface{} `json:"data"` }
PubSubMessage is the expected payload for Pub/Sub CloudEvents.
type RTDBEvent ¶
type RTDBEvent struct { Data interface{} Delta interface{} // contains filtered or unexported fields }
RTDBEvent is the expected payload of a firebase Realtime Database CloudEvent
type RealtimeDBEventType ¶
type RealtimeDBEventType EventType
RealtimeDBEventType is the event type for Firebase Realtime Database CloudEvents
func (RealtimeDBEventType) String ¶
func (e RealtimeDBEventType) String() string
String returns a minimal/readable representation of the event type
func (RealtimeDBEventType) Type ¶
func (e RealtimeDBEventType) Type() EventType
Type returns the event type
func (RealtimeDBEventType) Valid ¶
func (r RealtimeDBEventType) Valid() bool
Valid reports whether the RealtimeDBEventType is valid
type RealtimeDBFunc ¶
RealtimeDBFunc is the function signature for firebase Realtime Database Cloud Events
type RealtimeDBFunction ¶
type RealtimeDBFunction struct {
// contains filtered or unexported fields
}
RealtimeDBFunction is a wrapper for the expected data, RealtimeDBFunc and the parent FunctionRegistrar Implements the CloudEventFunction interface
func (*RealtimeDBFunction) Create ¶
func (r *RealtimeDBFunction) Create(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
Create registers the specified function to the RefCreateEvent for firebase Realtime Database CloudEvent The provided data is used to populate .Data of the RTDBEvent received by the function providers/google.firebase.database/eventTypes/ref.create
func (*RealtimeDBFunction) Delete ¶
func (r *RealtimeDBFunction) Delete(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
Delete registers the specified function to the RefDeleteEvent for firebase Realtime Database CloudEvent The provided data is used to populate .Delta of the RTDBEvent received by the function providers/google.firebase.database/eventTypes/ref.delete
func (*RealtimeDBFunction) Event ¶
func (a *RealtimeDBFunction) Event() EventType
Event returns the EventType of the function: RealtimeDBRefWriteEvent / RealtimeDBRefCreateEvent / RealtimeDBRefUpdateEvent / RealtimeDBRefDeleteEvent
func (*RealtimeDBFunction) HandleCloudEvent ¶
func (a *RealtimeDBFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
HandleCloudEvent handles the Firebase RealtimeDB CloudEvent and calls the registered RealtimeDBFunction
func (*RealtimeDBFunction) Name ¶
func (a *RealtimeDBFunction) Name() string
Name returns the name of the function: "rtdb.ref.{write,create,delete,update}-{path-segments}"
func (*RealtimeDBFunction) Path ¶
func (r *RealtimeDBFunction) Path() string
Path creates a path for the RealtimeDB event that can be used for registering a function returns the path with all wildcard fields replaced with a * and saves a map of the segment positions var names for access within the function
func (*RealtimeDBFunction) Ref ¶
func (r *RealtimeDBFunction) Ref(ref string) *RealtimeDBFunction
Ref appends the given path to the path that the RealtimeDBFunction is executed on Meant to be chained
func (*RealtimeDBFunction) Resource ¶
func (a *RealtimeDBFunction) Resource() string
Resource returns the resource of the function: "ref/{ref-id}/...."
func (*RealtimeDBFunction) Update ¶
func (r *RealtimeDBFunction) Update(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
Update registers the specified function to the RefUpdateEvent for firebase Realtime Database CloudEvent The provided data is used to populate .Data & .Delta of the RTDBEvent received by the function providers/google.firebase.database/eventTypes/ref.update
func (*RealtimeDBFunction) Write ¶
func (r *RealtimeDBFunction) Write(data interface{}, fn RealtimeDBFunc) *RealtimeDBFunction
Write registers the specified function to the RefWriteEvent for firebase Realtime Database CloudEvent The provided data is used to populate .Data & .Delta of the RTDBEvent received by the function providers/google.firebase.database/eventTypes/ref.write
type RemoteConfigEventType ¶
type RemoteConfigEventType EventType
RemoteConfigEventType is the event type for Firebase Remote Config CloudEvents
func (RemoteConfigEventType) String ¶
func (e RemoteConfigEventType) String() string
String returns a minimal/readable representation of the event type
func (RemoteConfigEventType) Type ¶
func (e RemoteConfigEventType) Type() EventType
Type returns the event type
func (RemoteConfigEventType) Valid ¶
func (r RemoteConfigEventType) Valid() bool
Valid reports whether the RemoteConfigEventType is valid
type SchedulerEventType ¶
type SchedulerEventType PubSubEventType
func (SchedulerEventType) String ¶
func (e SchedulerEventType) String() string
String returns a minimal/readable representation of the event type
func (SchedulerEventType) Type ¶
func (e SchedulerEventType) Type() EventType
Type returns the event type
func (SchedulerEventType) Valid ¶
func (r SchedulerEventType) Valid() bool
Valid reports whether the RemoteConfigEventType is valid
type StorageEvent ¶
type StorageEvent struct { Kind string `json:"kind"` ID string `json:"id"` SelfLink string `json:"selfLink"` Name string `json:"name"` Bucket string `json:"bucket"` Generation string `json:"generation"` Metageneration string `json:"metageneration"` ContentType string `json:"contentType"` TimeCreated time.Time `json:"timeCreated"` Updated time.Time `json:"updated"` TemporaryHold bool `json:"temporaryHold"` EventBasedHold bool `json:"eventBasedHold"` RetentionExpirationTime time.Time `json:"retentionExpirationTime"` StorageClass string `json:"storageClass"` TimeStorageClassUpdated time.Time `json:"timeStorageClassUpdated"` Size string `json:"size"` MD5Hash string `json:"md5Hash"` MediaLink string `json:"mediaLink"` ContentEncoding string `json:"contentEncoding"` ContentDisposition string `json:"contentDisposition"` CacheControl string `json:"cacheControl"` Metadata map[string]interface{} `json:"metadata"` CRC32C string `json:"crc32c"` ComponentCount int `json:"componentCount"` Etag string `json:"etag"` CustomerEncryption struct { EncryptionAlgorithm string `json:"encryptionAlgorithm"` KeySha256 string `json:"keySha256"` } KMSKeyName string `json:"kmsKeyName"` ResourceState string `json:"resourceState"` }
GCSEvent is the expected payload for Google Cloud Storage CloudEvents.
Finalize:
{ "kind":"storage#object", "id":"cleanflo-test-bucket/1 S Morrison.pdf/1642210177215991", "selfLink":"https://www.googleapis.com/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf", "name":"1 S Morrison.pdf", "bucket":"cleanflo-test-bucket", "generation":"1642210177215991", "metageneration":"1", "contentType":"application/pdf", "timeCreated":"2022-01-15T01:29:37.279Z", "updated":"2022-01-15T01:29:37.279Z" "storageClass":"STANDARD", "timeStorageClassUpdated":"2022-01-15T01:29:37.279Z", "size":"79734", "md5Hash":"+ndvErmbIgA5ccSgYOCzxg==", "mediaLink":"https://www.googleapis.com/download/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf?generation=1642210177215991&alt=media", "crc32c":"rZYNFQ==", "etag":"CPfbidLNsvUCEAE=", }
MetadataUpdate:
{ "kind":"storage#object", "id":"cleanflo-test-bucket/1 S Morrison.pdf/1642210177215991", "selfLink":"https://www.googleapis.com/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf", "name":"1 S Morrison.pdf", "bucket":"cleanflo-test-bucket", "generation":"1642210177215991", "metageneration":"3", "contentType":"application/pdf", "timeCreated":"2022-01-15T01:29:37.279Z", "updated":"2022-01-15T01:39:30.599Z" "temporaryHold":false, "eventBasedHold":false, "storageClass":"STANDARD", "timeStorageClassUpdated":"2022-01-15T01:29:37.279Z", "size":"79734", "md5Hash":"+ndvErmbIgA5ccSgYOCzxg==", "mediaLink":"https://www.googleapis.com/download/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf?generation=1642210177215991&alt=media", "metadata":{"ttt":"123"}, "crc32c":"rZYNFQ==", "etag":"CPfbidLNsvUCEAM=", "customTime":"2022-01-18T06:00:00.000Z", }
Delete:
{ "kind":"storage#object", "id":"cleanflo-test-bucket/1 S Morrison.pdf/1642210177215991", "selfLink":"https://www.googleapis.com/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf", "name":"1 S Morrison.pdf", "bucket":"cleanflo-test-bucket", "generation":"1642210177215991", "metageneration":"3", "contentType":"application/pdf", "timeCreated":"2022-01-15T01:29:37.279Z", "updated":"2022-01-15T01:39:30.599Z" "temporaryHold":false, "eventBasedHold":false, "storageClass":"STANDARD", "timeStorageClassUpdated":"2022-01-15T01:29:37.279Z", "size":"79734", "md5Hash":"+ndvErmbIgA5ccSgYOCzxg==", "mediaLink":"https://www.googleapis.com/download/storage/v1/b/cleanflo-test-bucket/o/1%20S%20Morrison.pdf?generation=1642210177215991&alt=media", "metadata":{"ttt":"123"}, "crc32c":"rZYNFQ==", "etag":"CPfbidLNsvUCEAM=", "customTime":"2022-01-18T06:00:00.000Z", }
type StorageEventType ¶
type StorageEventType EventType
StorageEventType is the event type for Storage CloudEvents
func (StorageEventType) String ¶
func (e StorageEventType) String() string
String returns a minimal/readable representation of the event type
func (StorageEventType) Type ¶
func (e StorageEventType) Type() EventType
Type returns the event type
func (StorageEventType) Valid ¶
func (s StorageEventType) Valid() bool
Valid reports whether the StorageEventType is valid
type StorageFunc ¶
type StorageFunc func(ctx context.Context, e StorageEvent) error
StorageFunc is the function signature for Google Cloud Storage Cloud Events
type StorageFunction ¶
type StorageFunction struct {
// contains filtered or unexported fields
}
StorageFunction is a wrapper for the expected data, StorageFunc and the parentFunctionRegistrar Implements the CloudEventFunction interface
func (*StorageFunction) Archive ¶
func (s *StorageFunction) Archive(fn StorageFunc) *StorageFunction
Archive registers the specified function to the ObjectArchiveEvent for Storage CloudEvent google.storage.object.archive
func (*StorageFunction) Bucket ¶
func (s *StorageFunction) Bucket(path string) *StorageFunction
Bucket sets the given path to the bucket that the StorageFunc is executed on
func (*StorageFunction) Delete ¶
func (s *StorageFunction) Delete(fn StorageFunc) *StorageFunction
Delete registers the specified function to the ObjectDeleteEvent for Storage CloudEvent google.storage.object.delete
func (*StorageFunction) Event ¶
func (a *StorageFunction) Event() EventType
Event returns the EventType of the function:
StorageObjectFinalizeEvent / StorageObjectDeleteEvent / StorageObjectArchiveEvent / StorageObjectMetadataUpdateEvent / EventTypeUserDelete
func (*StorageFunction) Finalize ¶
func (s *StorageFunction) Finalize(fn StorageFunc) *StorageFunction
Finalize registers the specified function to the ObjectFinalizeEvent for Storage CloudEvent google.storage.object.finalize
func (*StorageFunction) HandleCloudEvent ¶
func (a *StorageFunction) HandleCloudEvent(ctx context.Context, md *metadata.Metadata, dec *Decoder) error
HandleCloudEvent handles the Google Cloud Storage CloudEvent and calls the registered AuthenticationFunc
func (*StorageFunction) MetadataUpdate ¶
func (s *StorageFunction) MetadataUpdate(fn StorageFunc) *StorageFunction
MetadataUpdate registers the specified function to the ObjectMetadataUpdateEvent for Storage CloudEvent google.storage.object.metadataUpdate
func (*StorageFunction) Name ¶
func (a *StorageFunction) Name() string
Name returns the name of the function: "storageObject{Archive,Delete,Finalize,Metadata}-{bucketref}"
func (*StorageFunction) Resource ¶
func (a *StorageFunction) Resource() string
Resource returns the resource of the function: "{bucketRef}"
type VerbosityLevel ¶
type VerbosityLevel int
VerbosityLevel is for setting the verbosity level for the deploy command
const ( DebugVerbosity VerbosityLevel = iota InfoVerbosity WarningVerbosity // default ErrorVerbosity CriticalVerbosity NoneVerbosity )
func (VerbosityLevel) String ¶
func (v VerbosityLevel) String() string