<commit_before>package cloudwatch

import (
	"time"

	SDK "github.com/aws/aws-sdk-go/service/cloudwatch"

	"github.com/evalphobia/aws-sdk-go-wrapper/private/pointers"
)

type MetricStatisticsInput struct {
	StartTime          time.Time
	EndTime            time.Time
	Period             int64
	MetricName         string
	Namespace          string
	Unit               string
	Statistics         []string
	ExtendedStatistics []string

	Dimensions []Dimension
	// Key: Dimension.Name, Value: Dimension.Value.
	// If you use same key and differenct values, then use Dimensions.
	DimensionsMap map[string]string
}

func (o MetricStatisticsInput) ToInput() *SDK.GetMetricStatisticsInput {
	in := &SDK.GetMetricStatisticsInput{}
	if !o.StartTime.IsZero() {
		in.StartTime = &o.StartTime
	}
	if !o.EndTime.IsZero() {
		in.EndTime = &o.EndTime
	}
	if o.Period != 0 {
		in.Period = &o.Period
	}
	if o.MetricName != "" {
		in.MetricName = &o.MetricName
	}
	if o.Namespace != "" {
		in.Namespace = &o.Namespace
	}
	if o.Unit != "" {
		in.Unit = &o.Unit
	}
	in.Statistics = sliceStringToPointer(o.Statistics)
	in.ExtendedStatistics = sliceStringToPointer(o.ExtendedStatistics)

	in.Dimensions = make([]*SDK.Dimension, 0, len(o.DimensionsMap)+len(o.Dimensions))
	for key, val := range o.DimensionsMap {
		in.Dimensions = append(in.Dimensions, &SDK.Dimension{
			Name:  pointers.String(key),
			Value: pointers.String(val),
		})
	}
	for _, v := range o.Dimensions {
		in.Dimensions = append(in.Dimensions, &SDK.Dimension{
			Name:  pointers.String(v.Name),
			Value: pointers.String(v.Value),
		})
	}
	return in
}

type Dimension struct {
	Name  string
	Value string
}

func sliceStringToPointer(list []string) []*string {
	if len(list) == 0 {
		return nil
	}

	result := make([]*string, len(list))
	for i, v := range list {
		result[i] = &v
	}
	return result
}<commit_msg>[cloudwatch] Fix  slice pointers of Statistics on GetMetricStatistics (#47)<commit_after>package cloudwatch

import (
	"time"

	SDK "github.com/aws/aws-sdk-go/service/cloudwatch"

	"github.com/evalphobia/aws-sdk-go-wrapper/private/pointers"
)

type MetricStatisticsInput struct {
	StartTime          time.Time
	EndTime            time.Time
	Period             int64
	MetricName         string
	Namespace          string
	Unit               string
	Statistics         []string
	ExtendedStatistics []string

	Dimensions []Dimension
	// Key: Dimension.Name, Value: Dimension.Value.
	// If you use same key and differenct values, then use Dimensions.
	DimensionsMap map[string]string
}

func (o MetricStatisticsInput) ToInput() *SDK.GetMetricStatisticsInput {
	in := &SDK.GetMetricStatisticsInput{}
	if !o.StartTime.IsZero() {
		in.StartTime = &o.StartTime
	}
	if !o.EndTime.IsZero() {
		in.EndTime = &o.EndTime
	}
	if o.Period != 0 {
		in.Period = &o.Period
	}
	if o.MetricName != "" {
		in.MetricName = &o.MetricName
	}
	if o.Namespace != "" {
		in.Namespace = &o.Namespace
	}
	if o.Unit != "" {
		in.Unit = &o.Unit
	}
	in.Statistics = sliceStringToPointer(o.Statistics)
	in.ExtendedStatistics = sliceStringToPointer(o.ExtendedStatistics)

	in.Dimensions = make([]*SDK.Dimension, 0, len(o.DimensionsMap)+len(o.Dimensions))
	for key, val := range o.DimensionsMap {
		in.Dimensions = append(in.Dimensions, &SDK.Dimension{
			Name:  pointers.String(key),
			Value: pointers.String(val),
		})
	}
	for _, v := range o.Dimensions {
		in.Dimensions = append(in.Dimensions, &SDK.Dimension{
			Name:  pointers.String(v.Name),
			Value: pointers.String(v.Value),
		})
	}
	return in
}

type Dimension struct {
	Name  string
	Value string
}

func sliceStringToPointer(list []string) []*string {
	if len(list) == 0 {
		return nil
	}

	result := make([]*string, len(list))
	for i, v := range list {
		result[i] = pointers.String(v)
	}
	return result
}
{'fraction_non_alphanumeric': 0.13106540084388185, 'fraction_numerical': 0.0031645569620253164, 'mean_word_length': 3.354764638346728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6058084', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1315, 'n_words': 284}