// Code generated by protoc-gen-go. DO NOT EDIT.
// source: chromite/api/payload.proto

package api

import (
	context "context"
	fmt "fmt"
	proto "github.com/golang/protobuf/proto"
	chromiumos "go.chromium.org/chromiumos/infra/proto/go/chromiumos"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
	math "math"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

// Defines a single build directory in storage.
type Build struct {
	// The board of the image "x86-mario", etc.
	BuildTarget *chromiumos.BuildTarget `protobuf:"bytes,1,opt,name=build_target,json=buildTarget,proto3" json:"build_target,omitempty"`
	// The version of the image. "0.14.23.2", "3401.0.0", etc.
	Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	// The bucket of the image. "chromeos-releases" as default.
	Bucket string `protobuf:"bytes,3,opt,name=bucket,proto3" json:"bucket,omitempty"`
	// The channel of the image "stable-channel", "nplusone", etc.
	Channel              string   `protobuf:"bytes,4,opt,name=channel,proto3" json:"channel,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *Build) Reset()         { *m = Build{} }
func (m *Build) String() string { return proto.CompactTextString(m) }
func (*Build) ProtoMessage()    {}
func (*Build) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{0}
}

func (m *Build) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Build.Unmarshal(m, b)
}
func (m *Build) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Build.Marshal(b, m, deterministic)
}
func (m *Build) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Build.Merge(m, src)
}
func (m *Build) XXX_Size() int {
	return xxx_messageInfo_Build.Size(m)
}
func (m *Build) XXX_DiscardUnknown() {
	xxx_messageInfo_Build.DiscardUnknown(m)
}

var xxx_messageInfo_Build proto.InternalMessageInfo

func (m *Build) GetBuildTarget() *chromiumos.BuildTarget {
	if m != nil {
		return m.BuildTarget
	}
	return nil
}

func (m *Build) GetVersion() string {
	if m != nil {
		return m.Version
	}
	return ""
}

func (m *Build) GetBucket() string {
	if m != nil {
		return m.Bucket
	}
	return ""
}

func (m *Build) GetChannel() string {
	if m != nil {
		return m.Channel
	}
	return ""
}

// Define a DLC image archived.
type DLCImage struct {
	// An instance of Build that defines the build artifacts directory.
	Build *Build `protobuf:"bytes,1,opt,name=build,proto3" json:"build,omitempty"`
	// The name of the DLC (e.g. 'terminal-dlc').
	DlcId string `protobuf:"bytes,2,opt,name=dlc_id,json=dlcId,proto3" json:"dlc_id,omitempty"`
	// The name of the DLC package (e.g. 'package').
	DlcPackage string `protobuf:"bytes,3,opt,name=dlc_package,json=dlcPackage,proto3" json:"dlc_package,omitempty"`
	// The name of the DLC image (e.g. 'dlc.img').
	DlcImage             string   `protobuf:"bytes,4,opt,name=dlc_image,json=dlcImage,proto3" json:"dlc_image,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *DLCImage) Reset()         { *m = DLCImage{} }
func (m *DLCImage) String() string { return proto.CompactTextString(m) }
func (*DLCImage) ProtoMessage()    {}
func (*DLCImage) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{1}
}

func (m *DLCImage) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_DLCImage.Unmarshal(m, b)
}
func (m *DLCImage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_DLCImage.Marshal(b, m, deterministic)
}
func (m *DLCImage) XXX_Merge(src proto.Message) {
	xxx_messageInfo_DLCImage.Merge(m, src)
}
func (m *DLCImage) XXX_Size() int {
	return xxx_messageInfo_DLCImage.Size(m)
}
func (m *DLCImage) XXX_DiscardUnknown() {
	xxx_messageInfo_DLCImage.DiscardUnknown(m)
}

var xxx_messageInfo_DLCImage proto.InternalMessageInfo

func (m *DLCImage) GetBuild() *Build {
	if m != nil {
		return m.Build
	}
	return nil
}

func (m *DLCImage) GetDlcId() string {
	if m != nil {
		return m.DlcId
	}
	return ""
}

func (m *DLCImage) GetDlcPackage() string {
	if m != nil {
		return m.DlcPackage
	}
	return ""
}

func (m *DLCImage) GetDlcImage() string {
	if m != nil {
		return m.DlcImage
	}
	return ""
}

// Define a signed ChromeOS image archived.
type SignedImage struct {
	// An instance of Build that defines the build artifacts directory.
	Build *Build `protobuf:"bytes,1,opt,name=build,proto3" json:"build,omitempty"`
	// The type of the image. Currently, "recovery" or "base" types are supported.
	ImageType chromiumos.ImageType `protobuf:"varint,2,opt,name=image_type,json=imageType,proto3,enum=chromiumos.ImageType" json:"image_type,omitempty"`
	// The key the image was signed with. "premp", "mp", "mp-v2". This is not the
	// board specific key name, but the general value used in image/payload names.
	Key                  string   `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *SignedImage) Reset()         { *m = SignedImage{} }
func (m *SignedImage) String() string { return proto.CompactTextString(m) }
func (*SignedImage) ProtoMessage()    {}
func (*SignedImage) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{2}
}

func (m *SignedImage) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_SignedImage.Unmarshal(m, b)
}
func (m *SignedImage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_SignedImage.Marshal(b, m, deterministic)
}
func (m *SignedImage) XXX_Merge(src proto.Message) {
	xxx_messageInfo_SignedImage.Merge(m, src)
}
func (m *SignedImage) XXX_Size() int {
	return xxx_messageInfo_SignedImage.Size(m)
}
func (m *SignedImage) XXX_DiscardUnknown() {
	xxx_messageInfo_SignedImage.DiscardUnknown(m)
}

var xxx_messageInfo_SignedImage proto.InternalMessageInfo

func (m *SignedImage) GetBuild() *Build {
	if m != nil {
		return m.Build
	}
	return nil
}

func (m *SignedImage) GetImageType() chromiumos.ImageType {
	if m != nil {
		return m.ImageType
	}
	return chromiumos.ImageType_IMAGE_TYPE_UNDEFINED
}

func (m *SignedImage) GetKey() string {
	if m != nil {
		return m.Key
	}
	return ""
}

// Define a unsigned ChromeOS image archived.
type UnsignedImage struct {
	// An instance of Build that defines the build artifacts directory.
	Build *Build `protobuf:"bytes,1,opt,name=build,proto3" json:"build,omitempty"`
	/// The type of the image. Currently one of "test", "recovery", or "base".
	ImageType chromiumos.ImageType `protobuf:"varint,2,opt,name=image_type,json=imageType,proto3,enum=chromiumos.ImageType" json:"image_type,omitempty"`
	// The most recent branch corresponding to the version; "R19" etc.
	Milestone            string   `protobuf:"bytes,3,opt,name=milestone,proto3" json:"milestone,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *UnsignedImage) Reset()         { *m = UnsignedImage{} }
func (m *UnsignedImage) String() string { return proto.CompactTextString(m) }
func (*UnsignedImage) ProtoMessage()    {}
func (*UnsignedImage) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{3}
}

func (m *UnsignedImage) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_UnsignedImage.Unmarshal(m, b)
}
func (m *UnsignedImage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_UnsignedImage.Marshal(b, m, deterministic)
}
func (m *UnsignedImage) XXX_Merge(src proto.Message) {
	xxx_messageInfo_UnsignedImage.Merge(m, src)
}
func (m *UnsignedImage) XXX_Size() int {
	return xxx_messageInfo_UnsignedImage.Size(m)
}
func (m *UnsignedImage) XXX_DiscardUnknown() {
	xxx_messageInfo_UnsignedImage.DiscardUnknown(m)
}

var xxx_messageInfo_UnsignedImage proto.InternalMessageInfo

func (m *UnsignedImage) GetBuild() *Build {
	if m != nil {
		return m.Build
	}
	return nil
}

func (m *UnsignedImage) GetImageType() chromiumos.ImageType {
	if m != nil {
		return m.ImageType
	}
	return chromiumos.ImageType_IMAGE_TYPE_UNDEFINED
}

func (m *UnsignedImage) GetMilestone() string {
	if m != nil {
		return m.Milestone
	}
	return ""
}

// Request payload generation to be done with a source and target image.
type GenerationRequest struct {
	// Source image properties, must be either full_update or the same type as
	// the included tgt_image_oneof. full_update indicates the lack of a source.
	//
	// Types that are valid to be assigned to SrcImageOneof:
	//	*GenerationRequest_FullUpdate
	//	*GenerationRequest_SrcSignedImage
	//	*GenerationRequest_SrcUnsignedImage
	//	*GenerationRequest_SrcDlcImage
	SrcImageOneof isGenerationRequest_SrcImageOneof `protobuf_oneof:"src_image_oneof"`
	// Target image properties.
	//
	// Types that are valid to be assigned to TgtImageOneof:
	//	*GenerationRequest_TgtSignedImage
	//	*GenerationRequest_TgtUnsignedImage
	//	*GenerationRequest_TgtDlcImage
	TgtImageOneof isGenerationRequest_TgtImageOneof `protobuf_oneof:"tgt_image_oneof"`
	// The destination bucket (defaults to "chromeos-releases").
	Bucket string `protobuf:"bytes,6,opt,name=bucket,proto3" json:"bucket,omitempty"`
	// Should we run verification?
	Verify bool `protobuf:"varint,7,opt,name=verify,proto3" json:"verify,omitempty"`
	// The keyset to sign with (e.g. "coral-mp-v16"), if empty do not sign,
	// and may be ignored for certain request types (e.g. dlc).
	Keyset string `protobuf:"bytes,8,opt,name=keyset,proto3" json:"keyset,omitempty"`
	// Do not sign images or upload artifacts.
	Dryrun               bool     `protobuf:"varint,9,opt,name=dryrun,proto3" json:"dryrun,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *GenerationRequest) Reset()         { *m = GenerationRequest{} }
func (m *GenerationRequest) String() string { return proto.CompactTextString(m) }
func (*GenerationRequest) ProtoMessage()    {}
func (*GenerationRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{4}
}

func (m *GenerationRequest) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_GenerationRequest.Unmarshal(m, b)
}
func (m *GenerationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_GenerationRequest.Marshal(b, m, deterministic)
}
func (m *GenerationRequest) XXX_Merge(src proto.Message) {
	xxx_messageInfo_GenerationRequest.Merge(m, src)
}
func (m *GenerationRequest) XXX_Size() int {
	return xxx_messageInfo_GenerationRequest.Size(m)
}
func (m *GenerationRequest) XXX_DiscardUnknown() {
	xxx_messageInfo_GenerationRequest.DiscardUnknown(m)
}

var xxx_messageInfo_GenerationRequest proto.InternalMessageInfo

type isGenerationRequest_SrcImageOneof interface {
	isGenerationRequest_SrcImageOneof()
}

type GenerationRequest_FullUpdate struct {
	FullUpdate bool `protobuf:"varint,1,opt,name=full_update,json=fullUpdate,proto3,oneof"`
}

type GenerationRequest_SrcSignedImage struct {
	SrcSignedImage *SignedImage `protobuf:"bytes,2,opt,name=src_signed_image,json=srcSignedImage,proto3,oneof"`
}

type GenerationRequest_SrcUnsignedImage struct {
	SrcUnsignedImage *UnsignedImage `protobuf:"bytes,3,opt,name=src_unsigned_image,json=srcUnsignedImage,proto3,oneof"`
}

type GenerationRequest_SrcDlcImage struct {
	SrcDlcImage *DLCImage `protobuf:"bytes,10,opt,name=src_dlc_image,json=srcDlcImage,proto3,oneof"`
}

func (*GenerationRequest_FullUpdate) isGenerationRequest_SrcImageOneof() {}

func (*GenerationRequest_SrcSignedImage) isGenerationRequest_SrcImageOneof() {}

func (*GenerationRequest_SrcUnsignedImage) isGenerationRequest_SrcImageOneof() {}

func (*GenerationRequest_SrcDlcImage) isGenerationRequest_SrcImageOneof() {}

func (m *GenerationRequest) GetSrcImageOneof() isGenerationRequest_SrcImageOneof {
	if m != nil {
		return m.SrcImageOneof
	}
	return nil
}

func (m *GenerationRequest) GetFullUpdate() bool {
	if x, ok := m.GetSrcImageOneof().(*GenerationRequest_FullUpdate); ok {
		return x.FullUpdate
	}
	return false
}

func (m *GenerationRequest) GetSrcSignedImage() *SignedImage {
	if x, ok := m.GetSrcImageOneof().(*GenerationRequest_SrcSignedImage); ok {
		return x.SrcSignedImage
	}
	return nil
}

func (m *GenerationRequest) GetSrcUnsignedImage() *UnsignedImage {
	if x, ok := m.GetSrcImageOneof().(*GenerationRequest_SrcUnsignedImage); ok {
		return x.SrcUnsignedImage
	}
	return nil
}

func (m *GenerationRequest) GetSrcDlcImage() *DLCImage {
	if x, ok := m.GetSrcImageOneof().(*GenerationRequest_SrcDlcImage); ok {
		return x.SrcDlcImage
	}
	return nil
}

type isGenerationRequest_TgtImageOneof interface {
	isGenerationRequest_TgtImageOneof()
}

type GenerationRequest_TgtSignedImage struct {
	TgtSignedImage *SignedImage `protobuf:"bytes,4,opt,name=tgt_signed_image,json=tgtSignedImage,proto3,oneof"`
}

type GenerationRequest_TgtUnsignedImage struct {
	TgtUnsignedImage *UnsignedImage `protobuf:"bytes,5,opt,name=tgt_unsigned_image,json=tgtUnsignedImage,proto3,oneof"`
}

type GenerationRequest_TgtDlcImage struct {
	TgtDlcImage *DLCImage `protobuf:"bytes,11,opt,name=tgt_dlc_image,json=tgtDlcImage,proto3,oneof"`
}

func (*GenerationRequest_TgtSignedImage) isGenerationRequest_TgtImageOneof() {}

func (*GenerationRequest_TgtUnsignedImage) isGenerationRequest_TgtImageOneof() {}

func (*GenerationRequest_TgtDlcImage) isGenerationRequest_TgtImageOneof() {}

func (m *GenerationRequest) GetTgtImageOneof() isGenerationRequest_TgtImageOneof {
	if m != nil {
		return m.TgtImageOneof
	}
	return nil
}

func (m *GenerationRequest) GetTgtSignedImage() *SignedImage {
	if x, ok := m.GetTgtImageOneof().(*GenerationRequest_TgtSignedImage); ok {
		return x.TgtSignedImage
	}
	return nil
}

func (m *GenerationRequest) GetTgtUnsignedImage() *UnsignedImage {
	if x, ok := m.GetTgtImageOneof().(*GenerationRequest_TgtUnsignedImage); ok {
		return x.TgtUnsignedImage
	}
	return nil
}

func (m *GenerationRequest) GetTgtDlcImage() *DLCImage {
	if x, ok := m.GetTgtImageOneof().(*GenerationRequest_TgtDlcImage); ok {
		return x.TgtDlcImage
	}
	return nil
}

func (m *GenerationRequest) GetBucket() string {
	if m != nil {
		return m.Bucket
	}
	return ""
}

func (m *GenerationRequest) GetVerify() bool {
	if m != nil {
		return m.Verify
	}
	return false
}

func (m *GenerationRequest) GetKeyset() string {
	if m != nil {
		return m.Keyset
	}
	return ""
}

func (m *GenerationRequest) GetDryrun() bool {
	if m != nil {
		return m.Dryrun
	}
	return false
}

// XXX_OneofWrappers is for the internal use of the proto package.
func (*GenerationRequest) XXX_OneofWrappers() []interface{} {
	return []interface{}{
		(*GenerationRequest_FullUpdate)(nil),
		(*GenerationRequest_SrcSignedImage)(nil),
		(*GenerationRequest_SrcUnsignedImage)(nil),
		(*GenerationRequest_SrcDlcImage)(nil),
		(*GenerationRequest_TgtSignedImage)(nil),
		(*GenerationRequest_TgtUnsignedImage)(nil),
		(*GenerationRequest_TgtDlcImage)(nil),
	}
}

// Result of a payload generation.
type GenerationResponse struct {
	// Whether we've completed successfully.
	Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	// If successful we may have a local artifact available. Generally this takes
	// the form of '/tmp/ioadwjoawjd/delta.bin'.
	LocalPath string `protobuf:"bytes,2,opt,name=local_path,json=localPath,proto3" json:"local_path,omitempty"`
	// If successful we may have uploaded an artifact to google storage.
	RemoteUri            string   `protobuf:"bytes,3,opt,name=remote_uri,json=remoteUri,proto3" json:"remote_uri,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *GenerationResponse) Reset()         { *m = GenerationResponse{} }
func (m *GenerationResponse) String() string { return proto.CompactTextString(m) }
func (*GenerationResponse) ProtoMessage()    {}
func (*GenerationResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_0ecdf1e4e8bef7a4, []int{5}
}

func (m *GenerationResponse) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_GenerationResponse.Unmarshal(m, b)
}
func (m *GenerationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_GenerationResponse.Marshal(b, m, deterministic)
}
func (m *GenerationResponse) XXX_Merge(src proto.Message) {
	xxx_messageInfo_GenerationResponse.Merge(m, src)
}
func (m *GenerationResponse) XXX_Size() int {
	return xxx_messageInfo_GenerationResponse.Size(m)
}
func (m *GenerationResponse) XXX_DiscardUnknown() {
	xxx_messageInfo_GenerationResponse.DiscardUnknown(m)
}

var xxx_messageInfo_GenerationResponse proto.InternalMessageInfo

func (m *GenerationResponse) GetSuccess() bool {
	if m != nil {
		return m.Success
	}
	return false
}

func (m *GenerationResponse) GetLocalPath() string {
	if m != nil {
		return m.LocalPath
	}
	return ""
}

func (m *GenerationResponse) GetRemoteUri() string {
	if m != nil {
		return m.RemoteUri
	}
	return ""
}

func init() {
	proto.RegisterType((*Build)(nil), "chromite.api.Build")
	proto.RegisterType((*DLCImage)(nil), "chromite.api.DLCImage")
	proto.RegisterType((*SignedImage)(nil), "chromite.api.SignedImage")
	proto.RegisterType((*UnsignedImage)(nil), "chromite.api.UnsignedImage")
	proto.RegisterType((*GenerationRequest)(nil), "chromite.api.GenerationRequest")
	proto.RegisterType((*GenerationResponse)(nil), "chromite.api.GenerationResponse")
}

func init() { proto.RegisterFile("chromite/api/payload.proto", fileDescriptor_0ecdf1e4e8bef7a4) }

var fileDescriptor_0ecdf1e4e8bef7a4 = []byte{
	// 688 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xcd, 0x4e, 0xdb, 0x4a,
	0x14, 0x8e, 0x81, 0x84, 0xe4, 0x18, 0x02, 0xcc, 0x15, 0xe0, 0x1b, 0xb8, 0x82, 0x9b, 0x15, 0x77,
	0x93, 0x48, 0xdc, 0xaa, 0xaa, 0xaa, 0xae, 0x28, 0x55, 0x83, 0xda, 0x05, 0x32, 0xb0, 0xe9, 0x26,
	0x9a, 0x8c, 0x4f, 0x9c, 0x51, 0x1c, 0x8f, 0x3b, 0x1e, 0x53, 0x65, 0xd7, 0x75, 0x17, 0xed, 0x3b,
	0xf5, 0x49, 0xfa, 0x02, 0x7d, 0x87, 0x6a, 0x7e, 0x42, 0x6c, 0x50, 0x8b, 0xba, 0xe9, 0xce, 0xe7,
	0x3b, 0x67, 0xbe, 0xf9, 0xbe, 0xe3, 0x33, 0x07, 0x3a, 0x6c, 0x22, 0xc5, 0x8c, 0x2b, 0xec, 0xd3,
	0x8c, 0xf7, 0x33, 0x3a, 0x4f, 0x04, 0x8d, 0x7a, 0x99, 0x14, 0x4a, 0x90, 0x8d, 0x45, 0xae, 0x47,
	0x33, 0xde, 0x39, 0xac, 0x54, 0x8e, 0x0a, 0x9e, 0x44, 0x43, 0x9a, 0x71, 0x5b, 0xdb, 0xd9, 0xb7,
	0xd9, 0x62, 0x26, 0xf2, 0x3e, 0x13, 0xb3, 0x99, 0x48, 0x6d, 0xa2, 0xfb, 0xc5, 0x83, 0xfa, 0x99,
	0x2e, 0x26, 0xcf, 0x61, 0xc3, 0x9e, 0x52, 0x54, 0xc6, 0xa8, 0x02, 0xef, 0xd8, 0x3b, 0xf1, 0x4f,
	0xf7, 0x7b, 0xcb, 0x93, 0x3d, 0x53, 0x78, 0x6d, 0xd2, 0xa1, 0x3f, 0x5a, 0x06, 0x24, 0x80, 0xf5,
	0x5b, 0x94, 0x39, 0x17, 0x69, 0xb0, 0x72, 0xec, 0x9d, 0xb4, 0xc2, 0x45, 0x48, 0xf6, 0xa0, 0x31,
	0x2a, 0xd8, 0x14, 0x55, 0xb0, 0x6a, 0x12, 0x2e, 0xd2, 0x27, 0xd8, 0x84, 0xa6, 0x29, 0x26, 0xc1,
	0x9a, 0x3d, 0xe1, 0xc2, 0xee, 0x27, 0x0f, 0x9a, 0xe7, 0x6f, 0x5f, 0x5e, 0xcc, 0x68, 0x8c, 0xe4,
	0x3f, 0xa8, 0x9b, 0x7b, 0x9c, 0x9a, 0xbf, 0x7a, 0x65, 0xcf, 0x56, 0x4f, 0x68, 0x2b, 0xc8, 0x2e,
	0x34, 0xa2, 0x84, 0x0d, 0x79, 0xe4, 0x24, 0xd4, 0xa3, 0x84, 0x5d, 0x44, 0xe4, 0x08, 0x7c, 0x0d,
	0x67, 0x94, 0x4d, 0x69, 0x8c, 0x4e, 0x05, 0x44, 0x09, 0xbb, 0xb4, 0x08, 0x39, 0x80, 0x96, 0x39,
	0xa7, 0xef, 0x73, 0x5a, 0x9a, 0xfa, 0xa8, 0x8e, 0xbb, 0x1f, 0x3d, 0xf0, 0xaf, 0x78, 0x9c, 0x62,
	0xf4, 0xdb, 0x7a, 0x9e, 0x00, 0x18, 0xce, 0xa1, 0x9a, 0x67, 0x68, 0x34, 0xb5, 0x4f, 0x77, 0xcb,
	0xdd, 0x34, 0x8c, 0xd7, 0xf3, 0x0c, 0xc3, 0x16, 0x5f, 0x7c, 0x92, 0x6d, 0x58, 0x9d, 0xe2, 0xdc,
	0xc9, 0xd4, 0x9f, 0xdd, 0xcf, 0x1e, 0x6c, 0xde, 0xa4, 0xf9, 0x9f, 0x14, 0x71, 0x08, 0xad, 0x19,
	0x4f, 0x30, 0x57, 0x22, 0x5d, 0x74, 0x6c, 0x09, 0x74, 0xbf, 0xad, 0xc1, 0xce, 0x6b, 0x4c, 0x51,
	0x52, 0xc5, 0x45, 0x1a, 0xe2, 0xfb, 0x02, 0x73, 0x45, 0xfe, 0x05, 0x7f, 0x5c, 0x24, 0xc9, 0xb0,
	0xc8, 0x22, 0xaa, 0xd0, 0x48, 0x6b, 0x0e, 0x6a, 0x21, 0x68, 0xf0, 0xc6, 0x60, 0xe4, 0x15, 0x6c,
	0xe7, 0x92, 0x0d, 0xad, 0x15, 0xd7, 0xf0, 0x15, 0x63, 0xe1, 0xef, 0xaa, 0x85, 0x52, 0xc7, 0x07,
	0xb5, 0xb0, 0x9d, 0x4b, 0x56, 0xfe, 0x07, 0x6f, 0x80, 0x68, 0x9a, 0x22, 0xad, 0x10, 0xad, 0x1a,
	0xa2, 0x83, 0x2a, 0x51, 0xa5, 0x6f, 0x83, 0x5a, 0xa8, 0xef, 0xaf, 0xf6, 0xf2, 0x05, 0x6c, 0x6a,
	0xb2, 0xe5, 0x04, 0x80, 0xe1, 0xd9, 0xab, 0xf2, 0x2c, 0xe6, 0x71, 0x50, 0x0b, 0xfd, 0x5c, 0xb2,
	0x73, 0x37, 0x1e, 0xda, 0x91, 0x8a, 0x55, 0xd5, 0xd1, 0xda, 0x63, 0x8e, 0xbc, 0xb0, 0xad, 0x62,
	0x75, 0xcf, 0x91, 0xa6, 0xb9, 0xe7, 0xa8, 0xfe, 0xb8, 0x23, 0x2f, 0xd4, 0xf7, 0x3f, 0x70, 0xa4,
	0xc9, 0x96, 0x8e, 0xfc, 0x5f, 0x3a, 0xf2, 0x42, 0x5f, 0xc5, 0xea, 0xce, 0xd1, 0xf2, 0xbd, 0x36,
	0x2a, 0xef, 0x75, 0x0f, 0x1a, 0xb7, 0x28, 0xf9, 0x78, 0x1e, 0xac, 0xeb, 0x3f, 0x1b, 0xba, 0x48,
	0xe3, 0x53, 0x9c, 0xe7, 0xa8, 0x82, 0xa6, 0xad, 0xb7, 0x91, 0xc6, 0x23, 0x39, 0x97, 0x45, 0x1a,
	0xb4, 0x6c, 0xbd, 0x8d, 0xce, 0x76, 0x60, 0x4b, 0xf7, 0xdb, 0x0e, 0xa5, 0x48, 0x51, 0x8c, 0x35,
	0xa4, 0x05, 0x97, 0xa0, 0x6e, 0x02, 0xa4, 0x3c, 0x61, 0x79, 0x26, 0xd2, 0x1c, 0xf5, 0xce, 0xc8,
	0x0b, 0xc6, 0x30, 0xcf, 0xed, 0x78, 0x85, 0x8b, 0x90, 0xfc, 0x03, 0x90, 0x08, 0x46, 0x93, 0x61,
	0x46, 0xd5, 0xc4, 0xbd, 0xff, 0x96, 0x41, 0x2e, 0xa9, 0x9a, 0xe8, 0xb4, 0xc4, 0x99, 0x50, 0x38,
	0x2c, 0x24, 0x5f, 0x0c, 0xb4, 0x45, 0x6e, 0x24, 0x3f, 0xfd, 0x00, 0xed, 0x4b, 0xbb, 0x59, 0xaf,
	0x50, 0xde, 0x72, 0x86, 0xe4, 0x1a, 0xb6, 0xdc, 0xfd, 0xe8, 0x32, 0xe4, 0xa8, 0xda, 0xbf, 0x07,
	0x0f, 0xa0, 0x73, 0xfc, 0xf3, 0x02, 0xab, 0xbf, 0xb3, 0xf5, 0xf5, 0x7b, 0xc7, 0x87, 0x75, 0xb7,
	0xc5, 0xb7, 0xbd, 0xb3, 0x67, 0xef, 0x9e, 0xc6, 0xe2, 0xee, 0x35, 0xf6, 0x84, 0x8c, 0xfb, 0xa5,
	0x3d, 0xcd, 0xd3, 0xb1, 0xa4, 0x7d, 0xb3, 0xa6, 0xfb, 0xb1, 0xe8, 0x97, 0xf7, 0xfb, 0xa8, 0x61,
	0xe0, 0xff, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x8b, 0x4b, 0x60, 0x20, 0x06, 0x00, 0x00,
}

// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4

// PayloadServiceClient is the client API for PayloadService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type PayloadServiceClient interface {
	GeneratePayload(ctx context.Context, in *GenerationRequest, opts ...grpc.CallOption) (*GenerationResponse, error)
}

type payloadServiceClient struct {
	cc *grpc.ClientConn
}

func NewPayloadServiceClient(cc *grpc.ClientConn) PayloadServiceClient {
	return &payloadServiceClient{cc}
}

func (c *payloadServiceClient) GeneratePayload(ctx context.Context, in *GenerationRequest, opts ...grpc.CallOption) (*GenerationResponse, error) {
	out := new(GenerationResponse)
	err := c.cc.Invoke(ctx, "/chromite.api.PayloadService/GeneratePayload", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// PayloadServiceServer is the server API for PayloadService service.
type PayloadServiceServer interface {
	GeneratePayload(context.Context, *GenerationRequest) (*GenerationResponse, error)
}

// UnimplementedPayloadServiceServer can be embedded to have forward compatible implementations.
type UnimplementedPayloadServiceServer struct {
}

func (*UnimplementedPayloadServiceServer) GeneratePayload(ctx context.Context, req *GenerationRequest) (*GenerationResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GeneratePayload not implemented")
}

func RegisterPayloadServiceServer(s *grpc.Server, srv PayloadServiceServer) {
	s.RegisterService(&_PayloadService_serviceDesc, srv)
}

func _PayloadService_GeneratePayload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GenerationRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PayloadServiceServer).GeneratePayload(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/chromite.api.PayloadService/GeneratePayload",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PayloadServiceServer).GeneratePayload(ctx, req.(*GenerationRequest))
	}
	return interceptor(ctx, in, info, handler)
}

var _PayloadService_serviceDesc = grpc.ServiceDesc{
	ServiceName: "chromite.api.PayloadService",
	HandlerType: (*PayloadServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GeneratePayload",
			Handler:    _PayloadService_GeneratePayload_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "chromite/api/payload.proto",
}
