func NewBucketLogging(l *storage.BucketLogging) *BucketLogging {
	if l == nil {
		return nil
	}
	return &BucketLogging{
		LogBucket:       l.LogBucket,
		LogObjectPrefix: l.LogObjectPrefix,
	}
}
NewBucketLogging creates a new instance of BucketLogging from the storage counterpart
package v1alpha3
import (
	"time"
	"cloud.google.com/go/storage"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)
type ProjectTeam struct {
	ProjectNumber string `json:"projectNumber,omitempty"`
	Team string `json:"team,omitempty"`
}
func NewProjectTeam(pt *storage.ProjectTeam) *ProjectTeam {
	if pt == nil {
		return nil
	}
	return &ProjectTeam{
		ProjectNumber: pt.ProjectNumber,
		Team:          pt.Team,
	}
}
func CopyToProjectTeam(pt *ProjectTeam) *storage.ProjectTeam {
	if pt == nil {
		return nil
	}
	return &storage.ProjectTeam{
		ProjectNumber: pt.ProjectNumber,
		Team:          pt.Team,
	}
}
type ACLRule struct {
	Entity string `json:"entity,omitempty"`
	Role string `json:"role,omitempty"`
	EntityID string `json:"entityId,omitempty"`
	Domain string `json:"domain,omitempty"`
	Email string `json:"email,omitempty"`
	ProjectTeam *ProjectTeam `json:"projectTeam,omitempty"`
}
func NewACLRule(r storage.ACLRule) ACLRule {
	return ACLRule{
		Entity:      string(r.Entity),
		EntityID:    r.EntityID,
		Role:        string(r.Role),
		Domain:      r.Domain,
		Email:       r.Email,
		ProjectTeam: NewProjectTeam(r.ProjectTeam),
	}
}
func CopyToACLRule(ar ACLRule) storage.ACLRule {
	return storage.ACLRule{
		Entity:      storage.ACLEntity(ar.Entity),
		EntityID:    ar.EntityID,
		Role:        storage.ACLRole(ar.Role),
		Domain:      ar.Domain,
		Email:       ar.Email,
		ProjectTeam: CopyToProjectTeam(ar.ProjectTeam),
	}
}
func NewACLRules(r []storage.ACLRule) []ACLRule {
	var rules []ACLRule
	if l := len(r); l > 0 {
		rules = make([]ACLRule, l)
		for i, v := range r {
			rules[i] = NewACLRule(v)
		}
	}
	return rules
}
func CopyToACLRules(r []ACLRule) []storage.ACLRule {
	var rules []storage.ACLRule
	if l := len(r); l > 0 {
		rules = make([]storage.ACLRule, l)
		for i, v := range r {
			rules[i] = CopyToACLRule(v)
		}
	}
	return rules
}
type LifecycleAction struct {
	StorageClass string `json:"storageClass,omitempty"`
	Type string `json:"type,omitempty"`
}
func NewLifecyleAction(la storage.LifecycleAction) LifecycleAction {
	return LifecycleAction{
		Type:         la.Type,
		StorageClass: la.StorageClass,
	}
}
func CopyToLifecyleAction(la LifecycleAction) storage.LifecycleAction {
	return storage.LifecycleAction{
		Type:         la.Type,
		StorageClass: la.StorageClass,
	}
}
type LifecycleCondition struct {
	AgeInDays int64 `json:"ageInDays,omitempty"`
	CreatedBefore *metav1.Time `json:"createdBefore,omitempty"`
	Liveness storage.Liveness `json:"liveness,omitempty"`
	MatchesStorageClasses []string `json:"matchesStorageClasses,omitempty"`
	NumNewerVersions int64 `json:"numNewerVersions,omitempty"`
}
func NewLifecycleCondition(lc storage.LifecycleCondition) LifecycleCondition {
	return LifecycleCondition{
		AgeInDays:             lc.AgeInDays,
		CreatedBefore:         &metav1.Time{Time: lc.CreatedBefore},
		Liveness:              lc.Liveness,
		MatchesStorageClasses: lc.MatchesStorageClasses,
		NumNewerVersions:      lc.NumNewerVersions,
	}
}
func CopyToLifecycleCondition(lc LifecycleCondition) storage.LifecycleCondition {
	slc := storage.LifecycleCondition{
		AgeInDays:             lc.AgeInDays,
		Liveness:              lc.Liveness,
		MatchesStorageClasses: lc.MatchesStorageClasses,
		NumNewerVersions:      lc.NumNewerVersions,
	}
	if !lc.CreatedBefore.IsZero() {
		slc.CreatedBefore = lc.CreatedBefore.Time
	}
	return slc
}
type LifecycleRule struct {
	Action LifecycleAction `json:"action,omitempty"`
	Condition LifecycleCondition `json:"condition,omitempty"`
}
func NewLifecycleRule(lr storage.LifecycleRule) LifecycleRule {
	return LifecycleRule{
		Action:    NewLifecyleAction(lr.Action),
		Condition: NewLifecycleCondition(lr.Condition),
	}
}
func CopyToLifecyleRule(lr LifecycleRule) storage.LifecycleRule {
	return storage.LifecycleRule{
		Action:    CopyToLifecyleAction(lr.Action),
		Condition: CopyToLifecycleCondition(lr.Condition),
	}
}
type Lifecycle struct {
	Rules []LifecycleRule `json:"rules,omitempty"`
}
func NewLifecycle(lf storage.Lifecycle) *Lifecycle {
	lifecycle := &Lifecycle{}
	if l := len(lf.Rules); l > 0 {
		lifecycle.Rules = make([]LifecycleRule, l)
		for i, v := range lf.Rules {
			lifecycle.Rules[i] = NewLifecycleRule(v)
		}
	}
	return lifecycle
}
func CopyToLifecycle(lf Lifecycle) storage.Lifecycle {
	lifecycle := storage.Lifecycle{}
	if l := len(lf.Rules); l > 0 {
		lifecycle.Rules = make([]storage.LifecycleRule, l)
		for i, v := range lf.Rules {
			lifecycle.Rules[i] = CopyToLifecyleRule(v)
		}
	}
	return lifecycle
}
type RetentionPolicy struct {
	RetentionPeriodSeconds int `json:"retentionPeriodSeconds,omitempty"`
}
func NewRetentionPolicy(rp *storage.RetentionPolicy) *RetentionPolicy {
	if rp == nil {
		return nil
	}
	return &RetentionPolicy{
		RetentionPeriodSeconds: int(rp.RetentionPeriod.Seconds()),
	}
}
func CopyToRetentionPolicy(rp *RetentionPolicy) *storage.RetentionPolicy {
	var d time.Duration
	if rp == nil {
		d = time.Duration(0)
	} else {
		d = time.Duration(rp.RetentionPeriodSeconds)
	}
	return &storage.RetentionPolicy{
		RetentionPeriod: d * time.Second,
	}
}
type RetentionPolicyStatus struct {
	EffectiveTime metav1.Time `json:"effectiveTime,omitempty"`
	IsLocked bool `json:"isLocked,omitempty"`
}
func NewRetentionPolicyStatus(r *storage.RetentionPolicy) *RetentionPolicyStatus {
	if r == nil {
		return nil
	}
	return &RetentionPolicyStatus{
		EffectiveTime: metav1.Time{
			Time: r.EffectiveTime,
		},
		IsLocked: r.IsLocked,
	}
}
type BucketEncryption struct {
	DefaultKMSKeyName string `json:"defaultKmsKeyName,omitempty"`
}
func NewBucketEncryption(e *storage.BucketEncryption) *BucketEncryption {
	if e == nil {
		return nil
	}
	return &BucketEncryption{
		DefaultKMSKeyName: e.DefaultKMSKeyName,
	}
}
func CopyToBucketEncryption(e *BucketEncryption) *storage.BucketEncryption {
	if e == nil {
		return nil
	}
	return &storage.BucketEncryption{
		DefaultKMSKeyName: e.DefaultKMSKeyName,
	}
}
type BucketLogging struct {
	LogBucket string `json:"logBucket,omitempty"`
	LogObjectPrefix string `json:"logObjectPrefix,omitempty"`
}