Documentation ¶
Index ¶
- Constants
- func CLI(ctx context.Context)
- func LoadAWSConfig(ctx context.Context, profile string, logger logging.Logger, ...) (aws.Config, error)
- type CW
- type Client
- type ICW
- type IS3
- type Manager
- type Metric
- type MetricName
- type MockCW
- type MockS3
- type ObjectMetric
- type OutputType
- type Renderer
- type S3
- type SizeMetric
- type StorageType
Constants ¶
const ( // Version is the current version of s3bytes. Version string = "0.0.7" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
NewS3 is a constructor for the S3 client.
func NewMockClient ¶
NewMockClient is a constructor for the mock client.
type ICW ¶
type ICW interface {
GetMetricData(ctx context.Context, params *cloudwatch.GetMetricDataInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.GetMetricDataOutput, error)
}
ICW is an interface for the cloudwatch client.
type IS3 ¶
type IS3 interface {
ListBuckets(ctx context.Context, params *s3.ListBucketsInput, optFns ...func(*s3.Options)) (*s3.ListBucketsOutput, error)
}
IS3 is an interface for the s3 client.
type Manager ¶
type Manager struct { *Client Buckets []s3types.Bucket Batches [][]cwtypes.MetricDataQuery Metrics []Metric MetricName MetricName StorageType StorageType MaxQueries int Prefix string // filter prefix for bucket names Region string // current region state in process // contains filtered or unexported fields }
Manager is a manager struct for the s3bytes package.
func NewManager ¶
func NewManager(ctx context.Context, client *Client, region, prefix, expr string, metricName MetricName, storageType StorageType) (*Manager, error)
NewManager creates a new manager.
func (*Manager) SetQueries ¶
SetQueries sets the metric data queries for the cloudwatch client. https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html
type MetricName ¶
type MetricName int
MetricName represents the metric name.
const ( // MetricNameBucketSizeBytes represents the bucket size in bytes. MetricNameBucketSizeBytes MetricName = iota // MetricNameNumberOfObjects represents the number of objects in the bucket. MetricNameNumberOfObjects )
func ParseMetricName ¶
func ParseMetricName(s string) (MetricName, error)
ParseMetricName parses the metric name from the string representation.
func (MetricName) MarshalJSON ¶
func (t MetricName) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the metric name.
func (MetricName) String ¶
func (t MetricName) String() string
String returns the string representation of the metric name.
type MockCW ¶
type MockCW struct {
GetMetricDataFunc func(ctx context.Context, params *cloudwatch.GetMetricDataInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.GetMetricDataOutput, error)
}
MockCW is a mock for the cloudwatch client.
func (*MockCW) GetMetricData ¶
func (m *MockCW) GetMetricData(ctx context.Context, params *cloudwatch.GetMetricDataInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.GetMetricDataOutput, error)
GetMetricData is a wrapper for the GetMetricData method.
type MockS3 ¶
type MockS3 struct {
ListBucketsFunc func(ctx context.Context, params *s3.ListBucketsInput, optFns ...func(*s3.Options)) (*s3.ListBucketsOutput, error)
}
MockS3 is a mock for the s3 client.
func (*MockS3) ListBuckets ¶
func (m *MockS3) ListBuckets(ctx context.Context, params *s3.ListBucketsInput, optFns ...func(*s3.Options)) (*s3.ListBucketsOutput, error)
ListBuckets is a wrapper for the ListBuckets method.
type ObjectMetric ¶
type ObjectMetric struct { BucketName string Region string StorageType StorageType Objects float64 }
ObjectMetric is a struct for the object metric.
func (*ObjectMetric) Label ¶ added in v0.0.2
func (t *ObjectMetric) Label() string
Label returns the label of the object metric.
func (*ObjectMetric) Value ¶
func (t *ObjectMetric) Value() float64
Value returns the value of the object metric.
type OutputType ¶
type OutputType int
OutputType represents the output type of the renderer.
const ( // OutputTypeJSON represents the JSON output type. OutputTypeJSON OutputType = iota // OutputTypeText represents the text output type. OutputTypeText // OutputTypeMarkdown represents the markdown output type. OutputTypeMarkdown // OutputTypeBacklog represents the backlog output type. OutputTypeBacklog // OutputTypeTSV represents the TSV output type. OutputTypeTSV )
func ParseOutputType ¶
func ParseOutputType(s string) (OutputType, error)
ParseOutputType parses the output type from the string representation.
func (OutputType) MarshalJSON ¶
func (t OutputType) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the output type.
func (OutputType) String ¶
func (t OutputType) String() string
String returns the string representation of the output type.
type Renderer ¶
type Renderer struct { Metrics []Metric MetricName MetricName OutputType OutputType // contains filtered or unexported fields }
Renderer is a renderer struct for the s3bytes package.
func NewRenderer ¶
func NewRenderer(w io.Writer, metrics []Metric, metricName MetricName, outputType OutputType) *Renderer
NewRenderer creates a new renderer.
type SizeMetric ¶
type SizeMetric struct { BucketName string Region string StorageType StorageType Bytes float64 ReadableBytes string // human readable bytes }
SizeMetric is a struct for the size metric.
func (*SizeMetric) Label ¶ added in v0.0.2
func (t *SizeMetric) Label() string
Label returns the label of the size metric.
func (*SizeMetric) Value ¶
func (t *SizeMetric) Value() float64
Value returns the value of the size metric.
type StorageType ¶
type StorageType int
StorageType represents the storage type. https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html#s3-cloudwatch-metrics
const ( StorageTypeStandardStorage StorageType = iota StorageTypeIntelligentTieringFAStorage StorageTypeIntelligentTieringIAStorage StorageTypeIntelligentTieringAAStorage StorageTypeIntelligentTieringAIAStorage StorageTypeIntelligentTieringDAAStorage StorageTypeStandardIAStorage StorageTypeStandardIASizeOverhead StorageTypeStandardIAObjectOverhead StorageTypeOneZoneIAStorage StorageTypeOneZoneIASizeOverhead StorageTypeReducedRedundancyStorage StorageTypeGlacierIRSizeOverhead StorageTypeGlacierInstantRetrievalStorage StorageTypeGlacierStorage StorageTypeGlacierStagingStorage StorageTypeGlacierObjectOverhead StorageTypeGlacierS3ObjectOverhead StorageTypeDeepArchiveStorage StorageTypeDeepArchiveObjectOverhead StorageTypeDeepArchiveS3ObjectOverhead StorageTypeDeepArchiveStagingStorage StorageTypeAllStorageTypes )
func ParseStorageType ¶
func ParseStorageType(s string) (StorageType, error)
ParseStorageType parses the storage type from the string representation.
func (StorageType) MarshalJSON ¶
func (t StorageType) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the storage type.
func (StorageType) String ¶
func (t StorageType) String() string
String returns the string representation of the storage type.