go_gcp_service

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 21 Imported by: 0

README

go_gcp_service

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomFileName

func GenerateRandomFileName() string

GenerateRandomFileName genrates the fileName with unique time

func GetFileName

func GetFileName(filename string) (string, error)

Types

type BillingClient

type BillingClient struct {
	*cloudbilling.APIService
}

func NewGCPBillingClient

func NewGCPBillingClient(config BillingClientConfig) BillingClient

NewGCPBillingClient creates a new gcp billing api client

type BillingClientConfig

type BillingClientConfig struct {
	Logger       billingClientLogger
	ClientOption *option.ClientOption
}

type BillingService

type BillingService struct {
	ProjectName       string
	BillingAccountID  string
	BudgetDisplayName string
	BudgetAmount      int64
	Logger            billingServiceLogger
	GcpBilling        BillingClient
	BudgetClient      BudgetClient
}

BillingService -> handles the gcp billing related functions

func NewGCPBillingService

func NewGCPBillingService(
	configService BillingService,
) BillingService

NewGCPBillingService for the GCPBilling struct

func (BillingService) CreateBudget

func (s BillingService) CreateBudget(ctx context.Context) (*budgetspb.Budget, error)

func (BillingService) CreateOrUpdateBudget

func (s BillingService) CreateOrUpdateBudget(ctx context.Context) (*budgetspb.Budget, error)

func (BillingService) EditBudget

func (s BillingService) EditBudget(ctx context.Context, budget *budgetspb.Budget) (*budgetspb.Budget, error)

func (BillingService) GetBillingInfo

func (s BillingService) GetBillingInfo() (*cloudbilling.ProjectBillingInfo, error)

GetBillingInfo Get Billing info for certain date

func (BillingService) GetBudgetCreateUpdateRequest

func (s BillingService) GetBudgetCreateUpdateRequest() *budgetspb.Budget

func (BillingService) GetExistingBudgetList

func (s BillingService) GetExistingBudgetList(
	ctx context.Context,
) (*budgetspb.Budget, error)

GetExistingBudgetList Get Billing info for certain date

type BucketClient

type BucketClient struct {
	*storage.Client
}

func NewGCPBucketClient

func NewGCPBucketClient(config BucketClientConfig) BucketClient

NewGCPBucketClient creates a new gcp bucket api client

type BucketClientConfig

type BucketClientConfig struct {
	Logger            bucketClientLogger
	StorageBucketName string
	ClientOption      *option.ClientOption
}

type BudgetClient

type BudgetClient struct {
	*budgets.BudgetClient
}

func NewGCPBudgetClient

func NewGCPBudgetClient(clientConfig BudgetClientConfig) BudgetClient

type BudgetClientConfig

type BudgetClientConfig struct {
	Logger       budgetClientLogger
	ClientOption *option.ClientOption
}

type StorageBucketService

type StorageBucketService struct {
	Client            BucketClient
	Logger            storageBucketLogger
	StorageBucketName string
}

StorageBucketService the file upload/download functions

func NewStorageBucketService

func NewStorageBucketService(
	client BucketClient,
	logger storageBucketLogger,
	storageBucketName string,
) StorageBucketService

NewStorageBucketService for the StorageBucketService struct

func (StorageBucketService) GetImageUrl

func (service StorageBucketService) GetImageUrl(
	ctx context.Context, image multipart.File, imageFileHeader *multipart.FileHeader,
) (uploadedUrl string, err error)

func (StorageBucketService) RemoveObject

func (service StorageBucketService) RemoveObject(objectName string) error

RemoveObject removes the file from the storage bucket

func (StorageBucketService) UploadBinary

func (service StorageBucketService) UploadBinary(
	ctx context.Context,
	file []byte,
	fileName string,
) (string, error)

UploadBinary the binary to the cloud storage

func (StorageBucketService) UploadFile

func (service StorageBucketService) UploadFile(
	ctx context.Context,
	file io.Reader,
	fileName string,
) (string, error)

UploadFile uploads the file to the cloud storage

func (StorageBucketService) UploadThumbnailFile

func (service StorageBucketService) UploadThumbnailFile(
	ctx context.Context,
	file image.Image,
	fileName string, extension string,
) (string, error)

Jump to

Keyboard shortcuts

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