p

package
v0.0.0-...-6c61967 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

The function deletebackup.go is created and tested for GCP Function gen 2 and works in collaboration with PUB/SUB
The PUB?SUB topic message is a JSON with 5 parameters
project - project name
location - backups location
operation - "DELETE" or "LIST" - the latter can be used for tests
cluster - AlloyDB cluster name or "ALL" for all backups in the project
retention - retention in days, the backups older than the retention will be deleted 

Here is an example of a message to delete all backups of the test-alloydb-01 cluster in the sandbox project older than 107 days:
{ "project":"sandbox",  "location":"us-central1", "operation":"DELETE", "cluster":"test-alloydb-01", "retention":107}
To list backups 
{ "project":"sandbox",  "location":"us-central1", "operation":"DELETE", "cluster":"test-alloydb-01", "retention":107}
to create a new backup for a cluster
{ "project":"sandbox",  "location":"us-central1", "operation":"CREATE", "cluster":"test-alloydb-01", "retention":0}

Documentation

Overview

Copyright 2022 Gleb Otochkin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. / Package p contains a Pub/Sub Cloud Function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ManageAlloyDBBackups

func ManageAlloyDBBackups(ctx context.Context, m PubSubMessage) error

Types

type Backup

type Backup struct {
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	Uid         string `json:"uid"`
	CreateTime  string `json:"createTime"`
	UpdateTime  string `json:"updateTime"`
	State       string `json:"state"`
	DeleteTime  string `json:"deleteTime"`
	Description string `json:"description"`
	ClusterName string `json:"clusterName"`
	Reconciling bool   `json:"reconciling"`
	Etag        string `json:"etag"`
}

type Backups

type Backups struct {
	Backups []Backup `json:"backups"`
}

type Parameters

type Parameters struct {
	Project   string `json:"project"`
	Location  string `json:"location"`
	Operation string `json:"operation"`
	Cluster   string `json:"cluster"`
	Retention int    `json:"retention"`
}

type PubSubMessage

type PubSubMessage struct {
	Data []byte `json:"data"`
}

PubSubMessage is the payload of a Pub/Sub event. Please refer to the docs for additional information regarding Pub/Sub events.

Jump to

Keyboard shortcuts

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