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
}
NewLifecycle creates a new instance of Lifecycle 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"`
}