// Code generated by protoc-gen-pico. DO NOT EDIT.
// source: types.proto
//
// versions:
//     protoc-gen-pico: v0.0.4
//     protoc:          v6.33.2

package macaroon

import (
	time "time"

	picobuf "storj.io/picobuf"
	picoconv "storj.io/picobuf/picoconv"
)

type Caveat struct {
	DisallowReads                              bool           `json:"disallow_reads,omitempty"`
	DisallowWrites                             bool           `json:"disallow_writes,omitempty"`
	DisallowLists                              bool           `json:"disallow_lists,omitempty"`
	DisallowDeletes                            bool           `json:"disallow_deletes,omitempty"`
	DisallowLocks                              bool           `json:"disallow_locks,omitempty"`
	DisallowPutRetention                       bool           `json:"disallow_put_retention,omitempty"`
	DisallowGetRetention                       bool           `json:"disallow_get_retention,omitempty"`
	DisallowPutLegalHold                       bool           `json:"disallow_put_legal_hold,omitempty"`
	DisallowGetLegalHold                       bool           `json:"disallow_get_legal_hold,omitempty"`
	DisallowBypassGovernanceRetention          bool           `json:"disallow_bypass_governance_retention,omitempty"`
	DisallowPutBucketObjectLockConfiguration   bool           `json:"disallow_put_bucket_object_lock_configuration,omitempty"`
	DisallowGetBucketObjectLockConfiguration   bool           `json:"disallow_get_bucket_object_lock_configuration,omitempty"`
	DisallowPutBucketNotificationConfiguration bool           `json:"disallow_put_bucket_notification_configuration,omitempty"`
	DisallowGetBucketNotificationConfiguration bool           `json:"disallow_get_bucket_notification_configuration,omitempty"`
	AllowedPaths                               []*Caveat_Path `json:"allowed_paths,omitempty"`
	NotAfter                                   *time.Time     `json:"not_after,omitempty"`
	NotBefore                                  *time.Time     `json:"not_before,omitempty"`
	MaxObjectTtl                               *time.Duration `json:"max_object_ttl,omitempty"`
	Nonce                                      []byte         `json:"nonce,omitempty"`
}

func (m *Caveat) Encode(c *picobuf.Encoder) bool {
	if m == nil {
		return false
	}
	c.Bool(1, &m.DisallowReads)
	c.Bool(2, &m.DisallowWrites)
	c.Bool(3, &m.DisallowLists)
	c.Bool(4, &m.DisallowDeletes)
	c.Bool(5, &m.DisallowLocks)
	c.Bool(6, &m.DisallowPutRetention)
	c.Bool(7, &m.DisallowGetRetention)
	c.Bool(8, &m.DisallowPutLegalHold)
	c.Bool(9, &m.DisallowGetLegalHold)
	for _, x := range m.AllowedPaths {
		c.AlwaysMessage(10, x.Encode)
	}
	c.Bool(11, &m.DisallowBypassGovernanceRetention)
	c.Bool(12, &m.DisallowPutBucketObjectLockConfiguration)
	c.Bool(13, &m.DisallowGetBucketObjectLockConfiguration)
	c.Bool(14, &m.DisallowPutBucketNotificationConfiguration)
	c.Bool(15, &m.DisallowGetBucketNotificationConfiguration)
	(*picoconv.Timestamp)(m.NotAfter).PicoEncode(c, 20)
	(*picoconv.Timestamp)(m.NotBefore).PicoEncode(c, 21)
	(*picoconv.Duration)(m.MaxObjectTtl).PicoEncode(c, 22)
	c.Bytes(30, &m.Nonce)
	return true
}

func (m *Caveat) Decode(c *picobuf.Decoder) {
	if m == nil {
		return
	}
	c.Bool(1, &m.DisallowReads)
	c.Bool(2, &m.DisallowWrites)
	c.Bool(3, &m.DisallowLists)
	c.Bool(4, &m.DisallowDeletes)
	c.Bool(5, &m.DisallowLocks)
	c.Bool(6, &m.DisallowPutRetention)
	c.Bool(7, &m.DisallowGetRetention)
	c.Bool(8, &m.DisallowPutLegalHold)
	c.Bool(9, &m.DisallowGetLegalHold)
	c.RepeatedMessage(10, func(c *picobuf.Decoder) {
		x := new(Caveat_Path)
		c.Loop(x.Decode)
		m.AllowedPaths = append(m.AllowedPaths, x)
	})
	c.Bool(11, &m.DisallowBypassGovernanceRetention)
	c.Bool(12, &m.DisallowPutBucketObjectLockConfiguration)
	c.Bool(13, &m.DisallowGetBucketObjectLockConfiguration)
	c.Bool(14, &m.DisallowPutBucketNotificationConfiguration)
	c.Bool(15, &m.DisallowGetBucketNotificationConfiguration)
	if c.PendingField() == 20 {
		if m.NotAfter == nil {
			m.NotAfter = new(time.Time)
		}
		(*picoconv.Timestamp)(m.NotAfter).PicoDecode(c, 20)
	}
	if c.PendingField() == 21 {
		if m.NotBefore == nil {
			m.NotBefore = new(time.Time)
		}
		(*picoconv.Timestamp)(m.NotBefore).PicoDecode(c, 21)
	}
	if c.PendingField() == 22 {
		if m.MaxObjectTtl == nil {
			m.MaxObjectTtl = new(time.Duration)
		}
		(*picoconv.Duration)(m.MaxObjectTtl).PicoDecode(c, 22)
	}
	c.Bytes(30, &m.Nonce)
}

type Caveat_Path struct {
	Bucket              []byte `json:"bucket,omitempty"`
	EncryptedPathPrefix []byte `json:"encrypted_path_prefix,omitempty"`
}

func (m *Caveat_Path) Encode(c *picobuf.Encoder) bool {
	if m == nil {
		return false
	}
	c.Bytes(1, &m.Bucket)
	c.Bytes(2, &m.EncryptedPathPrefix)
	return true
}

func (m *Caveat_Path) Decode(c *picobuf.Decoder) {
	if m == nil {
		return
	}
	c.Bytes(1, &m.Bucket)
	c.Bytes(2, &m.EncryptedPathPrefix)
}
