// Code generated by protoc-gen-go. DO NOT EDIT.
// source: dmi/hw_management_service.proto

package dmi

import (
	context "context"
	fmt "fmt"
	proto "github.com/golang/protobuf/proto"
	empty "github.com/golang/protobuf/ptypes/empty"
	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

type PhysicalInventoryResponse_Reason int32

const (
	PhysicalInventoryResponse_UNDEFINED_REASON   PhysicalInventoryResponse_Reason = 0
	PhysicalInventoryResponse_UNKNOWN_DEVICE     PhysicalInventoryResponse_Reason = 1
	PhysicalInventoryResponse_INTERNAL_ERROR     PhysicalInventoryResponse_Reason = 2
	PhysicalInventoryResponse_DEVICE_UNREACHABLE PhysicalInventoryResponse_Reason = 3
)

var PhysicalInventoryResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "DEVICE_UNREACHABLE",
}

var PhysicalInventoryResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"INTERNAL_ERROR":     2,
	"DEVICE_UNREACHABLE": 3,
}

func (x PhysicalInventoryResponse_Reason) String() string {
	return proto.EnumName(PhysicalInventoryResponse_Reason_name, int32(x))
}

func (PhysicalInventoryResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{1, 0}
}

type HWComponentInfoGetResponse_Reason int32

const (
	HWComponentInfoGetResponse_UNDEFINED_REASON   HWComponentInfoGetResponse_Reason = 0
	HWComponentInfoGetResponse_UNKNOWN_DEVICE     HWComponentInfoGetResponse_Reason = 1
	HWComponentInfoGetResponse_UNKNOWN_COMPONENT  HWComponentInfoGetResponse_Reason = 2
	HWComponentInfoGetResponse_INTERNAL_ERROR     HWComponentInfoGetResponse_Reason = 3
	HWComponentInfoGetResponse_DEVICE_UNREACHABLE HWComponentInfoGetResponse_Reason = 4
)

var HWComponentInfoGetResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "UNKNOWN_COMPONENT",
	3: "INTERNAL_ERROR",
	4: "DEVICE_UNREACHABLE",
}

var HWComponentInfoGetResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"UNKNOWN_COMPONENT":  2,
	"INTERNAL_ERROR":     3,
	"DEVICE_UNREACHABLE": 4,
}

func (x HWComponentInfoGetResponse_Reason) String() string {
	return proto.EnumName(HWComponentInfoGetResponse_Reason_name, int32(x))
}

func (HWComponentInfoGetResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{3, 0}
}

type HWComponentInfoSetResponse_Reason int32

const (
	HWComponentInfoSetResponse_UNDEFINED_REASON   HWComponentInfoSetResponse_Reason = 0
	HWComponentInfoSetResponse_UNKNOWN_DEVICE     HWComponentInfoSetResponse_Reason = 1
	HWComponentInfoSetResponse_UNKNOWN_COMPONENT  HWComponentInfoSetResponse_Reason = 2
	HWComponentInfoSetResponse_INVALID_PARAMS     HWComponentInfoSetResponse_Reason = 3
	HWComponentInfoSetResponse_INTERNAL_ERROR     HWComponentInfoSetResponse_Reason = 4
	HWComponentInfoSetResponse_DEVICE_UNREACHABLE HWComponentInfoSetResponse_Reason = 5
)

var HWComponentInfoSetResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "UNKNOWN_COMPONENT",
	3: "INVALID_PARAMS",
	4: "INTERNAL_ERROR",
	5: "DEVICE_UNREACHABLE",
}

var HWComponentInfoSetResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"UNKNOWN_COMPONENT":  2,
	"INVALID_PARAMS":     3,
	"INTERNAL_ERROR":     4,
	"DEVICE_UNREACHABLE": 5,
}

func (x HWComponentInfoSetResponse_Reason) String() string {
	return proto.EnumName(HWComponentInfoSetResponse_Reason_name, int32(x))
}

func (HWComponentInfoSetResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{5, 0}
}

type StartManagingDeviceResponse_Reason int32

const (
	StartManagingDeviceResponse_UNDEFINED_REASON StartManagingDeviceResponse_Reason = 0
	// DEVICE_ALREADY_MANAGED is returned when StartManagingDevice is called again for the same name AFTER a previously
	// successful StartManagingDevice operation
	StartManagingDeviceResponse_DEVICE_ALREADY_MANAGED StartManagingDeviceResponse_Reason = 1
	// OPERATION_ALREADY_IN_PROGRESS is returned when StartManagingDevice is called again for the same name BEFORE
	// a previous StartManagingDevice operation has completed
	StartManagingDeviceResponse_OPERATION_ALREADY_IN_PROGRESS StartManagingDeviceResponse_Reason = 2
	StartManagingDeviceResponse_INVALID_PARAMS                StartManagingDeviceResponse_Reason = 3
	StartManagingDeviceResponse_INTERNAL_ERROR                StartManagingDeviceResponse_Reason = 4
)

var StartManagingDeviceResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "DEVICE_ALREADY_MANAGED",
	2: "OPERATION_ALREADY_IN_PROGRESS",
	3: "INVALID_PARAMS",
	4: "INTERNAL_ERROR",
}

var StartManagingDeviceResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":              0,
	"DEVICE_ALREADY_MANAGED":        1,
	"OPERATION_ALREADY_IN_PROGRESS": 2,
	"INVALID_PARAMS":                3,
	"INTERNAL_ERROR":                4,
}

func (x StartManagingDeviceResponse_Reason) String() string {
	return proto.EnumName(StartManagingDeviceResponse_Reason_name, int32(x))
}

func (StartManagingDeviceResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{6, 0}
}

// The only case in which an error is expected is if the name of the
// device to be stopped is not found
type StopManagingDeviceResponse_Reason int32

const (
	StopManagingDeviceResponse_UNDEFINED_REASON StopManagingDeviceResponse_Reason = 0
	StopManagingDeviceResponse_UNKNOWN_DEVICE   StopManagingDeviceResponse_Reason = 1
)

var StopManagingDeviceResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
}

var StopManagingDeviceResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON": 0,
	"UNKNOWN_DEVICE":   1,
}

func (x StopManagingDeviceResponse_Reason) String() string {
	return proto.EnumName(StopManagingDeviceResponse_Reason_name, int32(x))
}

func (StopManagingDeviceResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{8, 0}
}

type ManagedDevicesResponse_Reason int32

const (
	ManagedDevicesResponse_UNDEFINED_REASON ManagedDevicesResponse_Reason = 0
	ManagedDevicesResponse_INTERNAL_ERROR   ManagedDevicesResponse_Reason = 1
)

var ManagedDevicesResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "INTERNAL_ERROR",
}

var ManagedDevicesResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON": 0,
	"INTERNAL_ERROR":   1,
}

func (x ManagedDevicesResponse_Reason) String() string {
	return proto.EnumName(ManagedDevicesResponse_Reason_name, int32(x))
}

func (ManagedDevicesResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{10, 0}
}

type SetRemoteEndpointResponse_Reason int32

const (
	SetRemoteEndpointResponse_UNDEFINED_REASON                SetRemoteEndpointResponse_Reason = 0
	SetRemoteEndpointResponse_UNKNOWN_DEVICE                  SetRemoteEndpointResponse_Reason = 1
	SetRemoteEndpointResponse_INTERNAL_ERROR                  SetRemoteEndpointResponse_Reason = 2
	SetRemoteEndpointResponse_LOGGING_ENDPOINT_ERROR          SetRemoteEndpointResponse_Reason = 3
	SetRemoteEndpointResponse_LOGGING_ENDPOINT_PROTOCOL_ERROR SetRemoteEndpointResponse_Reason = 4
	SetRemoteEndpointResponse_MSGBUS_ENDPOINT_ERROR           SetRemoteEndpointResponse_Reason = 5
	SetRemoteEndpointResponse_DEVICE_UNREACHABLE              SetRemoteEndpointResponse_Reason = 6
)

var SetRemoteEndpointResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "LOGGING_ENDPOINT_ERROR",
	4: "LOGGING_ENDPOINT_PROTOCOL_ERROR",
	5: "MSGBUS_ENDPOINT_ERROR",
	6: "DEVICE_UNREACHABLE",
}

var SetRemoteEndpointResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":                0,
	"UNKNOWN_DEVICE":                  1,
	"INTERNAL_ERROR":                  2,
	"LOGGING_ENDPOINT_ERROR":          3,
	"LOGGING_ENDPOINT_PROTOCOL_ERROR": 4,
	"MSGBUS_ENDPOINT_ERROR":           5,
	"DEVICE_UNREACHABLE":              6,
}

func (x SetRemoteEndpointResponse_Reason) String() string {
	return proto.EnumName(SetRemoteEndpointResponse_Reason_name, int32(x))
}

func (SetRemoteEndpointResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{12, 0}
}

type GetLoggingEndpointResponse_Reason int32

const (
	GetLoggingEndpointResponse_UNDEFINED_REASON   GetLoggingEndpointResponse_Reason = 0
	GetLoggingEndpointResponse_UNKNOWN_DEVICE     GetLoggingEndpointResponse_Reason = 1
	GetLoggingEndpointResponse_INTERNAL_ERROR     GetLoggingEndpointResponse_Reason = 2
	GetLoggingEndpointResponse_DEVICE_UNREACHABLE GetLoggingEndpointResponse_Reason = 3
)

var GetLoggingEndpointResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "DEVICE_UNREACHABLE",
}

var GetLoggingEndpointResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"INTERNAL_ERROR":     2,
	"DEVICE_UNREACHABLE": 3,
}

func (x GetLoggingEndpointResponse_Reason) String() string {
	return proto.EnumName(GetLoggingEndpointResponse_Reason_name, int32(x))
}

func (GetLoggingEndpointResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{13, 0}
}

type GetMsgBusEndpointResponse_Reason int32

const (
	GetMsgBusEndpointResponse_UNDEFINED_REASON   GetMsgBusEndpointResponse_Reason = 0
	GetMsgBusEndpointResponse_INTERNAL_ERROR     GetMsgBusEndpointResponse_Reason = 1
	GetMsgBusEndpointResponse_DEVICE_UNREACHABLE GetMsgBusEndpointResponse_Reason = 2
)

var GetMsgBusEndpointResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "INTERNAL_ERROR",
	2: "DEVICE_UNREACHABLE",
}

var GetMsgBusEndpointResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"INTERNAL_ERROR":     1,
	"DEVICE_UNREACHABLE": 2,
}

func (x GetMsgBusEndpointResponse_Reason) String() string {
	return proto.EnumName(GetMsgBusEndpointResponse_Reason_name, int32(x))
}

func (GetMsgBusEndpointResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{15, 0}
}

type SetLogLevelResponse_Reason int32

const (
	SetLogLevelResponse_UNDEFINED_REASON   SetLogLevelResponse_Reason = 0
	SetLogLevelResponse_UNKNOWN_DEVICE     SetLogLevelResponse_Reason = 1
	SetLogLevelResponse_INTERNAL_ERROR     SetLogLevelResponse_Reason = 2
	SetLogLevelResponse_UNKNOWN_LOG_ENTITY SetLogLevelResponse_Reason = 3
	SetLogLevelResponse_DEVICE_UNREACHABLE SetLogLevelResponse_Reason = 4
)

var SetLogLevelResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "UNKNOWN_LOG_ENTITY",
	4: "DEVICE_UNREACHABLE",
}

var SetLogLevelResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"INTERNAL_ERROR":     2,
	"UNKNOWN_LOG_ENTITY": 3,
	"DEVICE_UNREACHABLE": 4,
}

func (x SetLogLevelResponse_Reason) String() string {
	return proto.EnumName(SetLogLevelResponse_Reason_name, int32(x))
}

func (SetLogLevelResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{18, 0}
}

type GetLogLevelResponse_Reason int32

const (
	GetLogLevelResponse_UNDEFINED_REASON   GetLogLevelResponse_Reason = 0
	GetLogLevelResponse_UNKNOWN_DEVICE     GetLogLevelResponse_Reason = 1
	GetLogLevelResponse_INTERNAL_ERROR     GetLogLevelResponse_Reason = 2
	GetLogLevelResponse_UNKNOWN_LOG_ENTITY GetLogLevelResponse_Reason = 3
	GetLogLevelResponse_DEVICE_UNREACHABLE GetLogLevelResponse_Reason = 4
)

var GetLogLevelResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "UNKNOWN_LOG_ENTITY",
	4: "DEVICE_UNREACHABLE",
}

var GetLogLevelResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"INTERNAL_ERROR":     2,
	"UNKNOWN_LOG_ENTITY": 3,
	"DEVICE_UNREACHABLE": 4,
}

func (x GetLogLevelResponse_Reason) String() string {
	return proto.EnumName(GetLogLevelResponse_Reason_name, int32(x))
}

func (GetLogLevelResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{20, 0}
}

type RebootDeviceResponse_Reason int32

const (
	RebootDeviceResponse_UNDEFINED_REASON   RebootDeviceResponse_Reason = 0
	RebootDeviceResponse_UNKNOWN_DEVICE     RebootDeviceResponse_Reason = 1
	RebootDeviceResponse_INTERNAL_ERROR     RebootDeviceResponse_Reason = 2
	RebootDeviceResponse_DEVICE_UNREACHABLE RebootDeviceResponse_Reason = 3
)

var RebootDeviceResponse_Reason_name = map[int32]string{
	0: "UNDEFINED_REASON",
	1: "UNKNOWN_DEVICE",
	2: "INTERNAL_ERROR",
	3: "DEVICE_UNREACHABLE",
}

var RebootDeviceResponse_Reason_value = map[string]int32{
	"UNDEFINED_REASON":   0,
	"UNKNOWN_DEVICE":     1,
	"INTERNAL_ERROR":     2,
	"DEVICE_UNREACHABLE": 3,
}

func (x RebootDeviceResponse_Reason) String() string {
	return proto.EnumName(RebootDeviceResponse_Reason_name, int32(x))
}

func (RebootDeviceResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{24, 0}
}

type PhysicalInventoryRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

var xxx_messageInfo_PhysicalInventoryRequest proto.InternalMessageInfo

func (m *PhysicalInventoryRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

type PhysicalInventoryResponse struct {
	Status    Status                           `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason    PhysicalInventoryResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.PhysicalInventoryResponse_Reason" json:"reason,omitempty"`
	Inventory *Hardware                        `protobuf:"bytes,3,opt,name=inventory,proto3" json:"inventory,omitempty"`
	// It is recommended that upstream components/users of the DMI interface
	// do not really interpret/parse the reson_detail, but rather use it for
	// display purposes to the end user or use it for logging the error
	ReasonDetail         string   `protobuf:"bytes,4,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

var xxx_messageInfo_PhysicalInventoryResponse proto.InternalMessageInfo

func (m *PhysicalInventoryResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *PhysicalInventoryResponse) GetReason() PhysicalInventoryResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return PhysicalInventoryResponse_UNDEFINED_REASON
}

func (m *PhysicalInventoryResponse) GetInventory() *Hardware {
	if m != nil {
		return m.Inventory
	}
	return nil
}

func (m *PhysicalInventoryResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type HWComponentInfoGetRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	ComponentUuid        *Uuid    `protobuf:"bytes,2,opt,name=component_uuid,json=componentUuid,proto3" json:"component_uuid,omitempty"`
	ComponentName        string   `protobuf:"bytes,3,opt,name=component_name,json=componentName,proto3" json:"component_name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

var xxx_messageInfo_HWComponentInfoGetRequest proto.InternalMessageInfo

func (m *HWComponentInfoGetRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *HWComponentInfoGetRequest) GetComponentUuid() *Uuid {
	if m != nil {
		return m.ComponentUuid
	}
	return nil
}

func (m *HWComponentInfoGetRequest) GetComponentName() string {
	if m != nil {
		return m.ComponentName
	}
	return ""
}

type HWComponentInfoGetResponse struct {
	Status               Status                            `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               HWComponentInfoGetResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.HWComponentInfoGetResponse_Reason" json:"reason,omitempty"`
	Component            *Component                        `protobuf:"bytes,3,opt,name=component,proto3" json:"component,omitempty"`
	ReasonDetail         string                            `protobuf:"bytes,4,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                          `json:"-"`
	XXX_unrecognized     []byte                            `json:"-"`
	XXX_sizecache        int32                             `json:"-"`
}

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

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

var xxx_messageInfo_HWComponentInfoGetResponse proto.InternalMessageInfo

func (m *HWComponentInfoGetResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *HWComponentInfoGetResponse) GetReason() HWComponentInfoGetResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return HWComponentInfoGetResponse_UNDEFINED_REASON
}

func (m *HWComponentInfoGetResponse) GetComponent() *Component {
	if m != nil {
		return m.Component
	}
	return nil
}

func (m *HWComponentInfoGetResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type HWComponentInfoSetRequest struct {
	DeviceUuid           *Uuid                `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	ComponentUuid        *Uuid                `protobuf:"bytes,2,opt,name=component_uuid,json=componentUuid,proto3" json:"component_uuid,omitempty"`
	ComponentName        string               `protobuf:"bytes,3,opt,name=component_name,json=componentName,proto3" json:"component_name,omitempty"`
	Changes              *ModifiableComponent `protobuf:"bytes,4,opt,name=changes,proto3" json:"changes,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

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

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

var xxx_messageInfo_HWComponentInfoSetRequest proto.InternalMessageInfo

func (m *HWComponentInfoSetRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *HWComponentInfoSetRequest) GetComponentUuid() *Uuid {
	if m != nil {
		return m.ComponentUuid
	}
	return nil
}

func (m *HWComponentInfoSetRequest) GetComponentName() string {
	if m != nil {
		return m.ComponentName
	}
	return ""
}

func (m *HWComponentInfoSetRequest) GetChanges() *ModifiableComponent {
	if m != nil {
		return m.Changes
	}
	return nil
}

type HWComponentInfoSetResponse struct {
	Status               Status                            `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               HWComponentInfoSetResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.HWComponentInfoSetResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                            `protobuf:"bytes,3,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                          `json:"-"`
	XXX_unrecognized     []byte                            `json:"-"`
	XXX_sizecache        int32                             `json:"-"`
}

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

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

var xxx_messageInfo_HWComponentInfoSetResponse proto.InternalMessageInfo

func (m *HWComponentInfoSetResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *HWComponentInfoSetResponse) GetReason() HWComponentInfoSetResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return HWComponentInfoSetResponse_UNDEFINED_REASON
}

func (m *HWComponentInfoSetResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type StartManagingDeviceResponse struct {
	Status               Status                             `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               StartManagingDeviceResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.StartManagingDeviceResponse_Reason" json:"reason,omitempty"`
	DeviceUuid           *Uuid                              `protobuf:"bytes,3,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	ReasonDetail         string                             `protobuf:"bytes,4,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                           `json:"-"`
	XXX_unrecognized     []byte                             `json:"-"`
	XXX_sizecache        int32                              `json:"-"`
}

func (m *StartManagingDeviceResponse) Reset()         { *m = StartManagingDeviceResponse{} }
func (m *StartManagingDeviceResponse) String() string { return proto.CompactTextString(m) }
func (*StartManagingDeviceResponse) ProtoMessage()    {}
func (*StartManagingDeviceResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{6}
}

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

var xxx_messageInfo_StartManagingDeviceResponse proto.InternalMessageInfo

func (m *StartManagingDeviceResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *StartManagingDeviceResponse) GetReason() StartManagingDeviceResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return StartManagingDeviceResponse_UNDEFINED_REASON
}

func (m *StartManagingDeviceResponse) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *StartManagingDeviceResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type StopManagingDeviceRequest struct {
	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *StopManagingDeviceRequest) Reset()         { *m = StopManagingDeviceRequest{} }
func (m *StopManagingDeviceRequest) String() string { return proto.CompactTextString(m) }
func (*StopManagingDeviceRequest) ProtoMessage()    {}
func (*StopManagingDeviceRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{7}
}

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

var xxx_messageInfo_StopManagingDeviceRequest proto.InternalMessageInfo

func (m *StopManagingDeviceRequest) GetName() string {
	if m != nil {
		return m.Name
	}
	return ""
}

type StopManagingDeviceResponse struct {
	Status               Status                            `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               StopManagingDeviceResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.StopManagingDeviceResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                            `protobuf:"bytes,3,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                          `json:"-"`
	XXX_unrecognized     []byte                            `json:"-"`
	XXX_sizecache        int32                             `json:"-"`
}

func (m *StopManagingDeviceResponse) Reset()         { *m = StopManagingDeviceResponse{} }
func (m *StopManagingDeviceResponse) String() string { return proto.CompactTextString(m) }
func (*StopManagingDeviceResponse) ProtoMessage()    {}
func (*StopManagingDeviceResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{8}
}

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

var xxx_messageInfo_StopManagingDeviceResponse proto.InternalMessageInfo

func (m *StopManagingDeviceResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *StopManagingDeviceResponse) GetReason() StopManagingDeviceResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return StopManagingDeviceResponse_UNDEFINED_REASON
}

func (m *StopManagingDeviceResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type ManagedDeviceInfo struct {
	Info                 *ModifiableComponent `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
	DeviceUuid           *Uuid                `protobuf:"bytes,2,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (m *ManagedDeviceInfo) Reset()         { *m = ManagedDeviceInfo{} }
func (m *ManagedDeviceInfo) String() string { return proto.CompactTextString(m) }
func (*ManagedDeviceInfo) ProtoMessage()    {}
func (*ManagedDeviceInfo) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{9}
}

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

var xxx_messageInfo_ManagedDeviceInfo proto.InternalMessageInfo

func (m *ManagedDeviceInfo) GetInfo() *ModifiableComponent {
	if m != nil {
		return m.Info
	}
	return nil
}

func (m *ManagedDeviceInfo) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

type ManagedDevicesResponse struct {
	Status               Status                        `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               ManagedDevicesResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.ManagedDevicesResponse_Reason" json:"reason,omitempty"`
	Devices              []*ManagedDeviceInfo          `protobuf:"bytes,3,rep,name=devices,proto3" json:"devices,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                      `json:"-"`
	XXX_unrecognized     []byte                        `json:"-"`
	XXX_sizecache        int32                         `json:"-"`
}

func (m *ManagedDevicesResponse) Reset()         { *m = ManagedDevicesResponse{} }
func (m *ManagedDevicesResponse) String() string { return proto.CompactTextString(m) }
func (*ManagedDevicesResponse) ProtoMessage()    {}
func (*ManagedDevicesResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{10}
}

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

var xxx_messageInfo_ManagedDevicesResponse proto.InternalMessageInfo

func (m *ManagedDevicesResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *ManagedDevicesResponse) GetReason() ManagedDevicesResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return ManagedDevicesResponse_UNDEFINED_REASON
}

func (m *ManagedDevicesResponse) GetDevices() []*ManagedDeviceInfo {
	if m != nil {
		return m.Devices
	}
	return nil
}

type SetLoggingEndpointRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	LoggingEndpoint      string   `protobuf:"bytes,2,opt,name=logging_endpoint,json=loggingEndpoint,proto3" json:"logging_endpoint,omitempty"`
	LoggingProtocol      string   `protobuf:"bytes,3,opt,name=logging_protocol,json=loggingProtocol,proto3" json:"logging_protocol,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *SetLoggingEndpointRequest) Reset()         { *m = SetLoggingEndpointRequest{} }
func (m *SetLoggingEndpointRequest) String() string { return proto.CompactTextString(m) }
func (*SetLoggingEndpointRequest) ProtoMessage()    {}
func (*SetLoggingEndpointRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{11}
}

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

var xxx_messageInfo_SetLoggingEndpointRequest proto.InternalMessageInfo

func (m *SetLoggingEndpointRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *SetLoggingEndpointRequest) GetLoggingEndpoint() string {
	if m != nil {
		return m.LoggingEndpoint
	}
	return ""
}

func (m *SetLoggingEndpointRequest) GetLoggingProtocol() string {
	if m != nil {
		return m.LoggingProtocol
	}
	return ""
}

type SetRemoteEndpointResponse struct {
	Status               Status                           `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               SetRemoteEndpointResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.SetRemoteEndpointResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                           `protobuf:"bytes,3,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                         `json:"-"`
	XXX_unrecognized     []byte                           `json:"-"`
	XXX_sizecache        int32                            `json:"-"`
}

func (m *SetRemoteEndpointResponse) Reset()         { *m = SetRemoteEndpointResponse{} }
func (m *SetRemoteEndpointResponse) String() string { return proto.CompactTextString(m) }
func (*SetRemoteEndpointResponse) ProtoMessage()    {}
func (*SetRemoteEndpointResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{12}
}

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

var xxx_messageInfo_SetRemoteEndpointResponse proto.InternalMessageInfo

func (m *SetRemoteEndpointResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *SetRemoteEndpointResponse) GetReason() SetRemoteEndpointResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return SetRemoteEndpointResponse_UNDEFINED_REASON
}

func (m *SetRemoteEndpointResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type GetLoggingEndpointResponse struct {
	Status               Status                            `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               GetLoggingEndpointResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.GetLoggingEndpointResponse_Reason" json:"reason,omitempty"`
	LoggingEndpoint      string                            `protobuf:"bytes,3,opt,name=logging_endpoint,json=loggingEndpoint,proto3" json:"logging_endpoint,omitempty"`
	LoggingProtocol      string                            `protobuf:"bytes,4,opt,name=logging_protocol,json=loggingProtocol,proto3" json:"logging_protocol,omitempty"`
	ReasonDetail         string                            `protobuf:"bytes,5,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                          `json:"-"`
	XXX_unrecognized     []byte                            `json:"-"`
	XXX_sizecache        int32                             `json:"-"`
}

func (m *GetLoggingEndpointResponse) Reset()         { *m = GetLoggingEndpointResponse{} }
func (m *GetLoggingEndpointResponse) String() string { return proto.CompactTextString(m) }
func (*GetLoggingEndpointResponse) ProtoMessage()    {}
func (*GetLoggingEndpointResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{13}
}

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

var xxx_messageInfo_GetLoggingEndpointResponse proto.InternalMessageInfo

func (m *GetLoggingEndpointResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *GetLoggingEndpointResponse) GetReason() GetLoggingEndpointResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return GetLoggingEndpointResponse_UNDEFINED_REASON
}

func (m *GetLoggingEndpointResponse) GetLoggingEndpoint() string {
	if m != nil {
		return m.LoggingEndpoint
	}
	return ""
}

func (m *GetLoggingEndpointResponse) GetLoggingProtocol() string {
	if m != nil {
		return m.LoggingProtocol
	}
	return ""
}

func (m *GetLoggingEndpointResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type SetMsgBusEndpointRequest struct {
	MsgbusEndpoint       string   `protobuf:"bytes,1,opt,name=msgbus_endpoint,json=msgbusEndpoint,proto3" json:"msgbus_endpoint,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *SetMsgBusEndpointRequest) Reset()         { *m = SetMsgBusEndpointRequest{} }
func (m *SetMsgBusEndpointRequest) String() string { return proto.CompactTextString(m) }
func (*SetMsgBusEndpointRequest) ProtoMessage()    {}
func (*SetMsgBusEndpointRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{14}
}

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

var xxx_messageInfo_SetMsgBusEndpointRequest proto.InternalMessageInfo

func (m *SetMsgBusEndpointRequest) GetMsgbusEndpoint() string {
	if m != nil {
		return m.MsgbusEndpoint
	}
	return ""
}

type GetMsgBusEndpointResponse struct {
	Status               Status                           `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               GetMsgBusEndpointResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.GetMsgBusEndpointResponse_Reason" json:"reason,omitempty"`
	MsgbusEndpoint       string                           `protobuf:"bytes,3,opt,name=msgbus_endpoint,json=msgbusEndpoint,proto3" json:"msgbus_endpoint,omitempty"`
	ReasonDetail         string                           `protobuf:"bytes,4,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                         `json:"-"`
	XXX_unrecognized     []byte                           `json:"-"`
	XXX_sizecache        int32                            `json:"-"`
}

func (m *GetMsgBusEndpointResponse) Reset()         { *m = GetMsgBusEndpointResponse{} }
func (m *GetMsgBusEndpointResponse) String() string { return proto.CompactTextString(m) }
func (*GetMsgBusEndpointResponse) ProtoMessage()    {}
func (*GetMsgBusEndpointResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{15}
}

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

var xxx_messageInfo_GetMsgBusEndpointResponse proto.InternalMessageInfo

func (m *GetMsgBusEndpointResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *GetMsgBusEndpointResponse) GetReason() GetMsgBusEndpointResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return GetMsgBusEndpointResponse_UNDEFINED_REASON
}

func (m *GetMsgBusEndpointResponse) GetMsgbusEndpoint() string {
	if m != nil {
		return m.MsgbusEndpoint
	}
	return ""
}

func (m *GetMsgBusEndpointResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type EntitiesLogLevel struct {
	LogLevel             LogLevel `protobuf:"varint,1,opt,name=logLevel,proto3,enum=dmi.LogLevel" json:"logLevel,omitempty"`
	Entities             []string `protobuf:"bytes,2,rep,name=entities,proto3" json:"entities,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *EntitiesLogLevel) Reset()         { *m = EntitiesLogLevel{} }
func (m *EntitiesLogLevel) String() string { return proto.CompactTextString(m) }
func (*EntitiesLogLevel) ProtoMessage()    {}
func (*EntitiesLogLevel) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{16}
}

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

var xxx_messageInfo_EntitiesLogLevel proto.InternalMessageInfo

func (m *EntitiesLogLevel) GetLogLevel() LogLevel {
	if m != nil {
		return m.LogLevel
	}
	return LogLevel_TRACE
}

func (m *EntitiesLogLevel) GetEntities() []string {
	if m != nil {
		return m.Entities
	}
	return nil
}

type SetLogLevelRequest struct {
	DeviceUuid           *Uuid               `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	Loglevels            []*EntitiesLogLevel `protobuf:"bytes,2,rep,name=loglevels,proto3" json:"loglevels,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

func (m *SetLogLevelRequest) Reset()         { *m = SetLogLevelRequest{} }
func (m *SetLogLevelRequest) String() string { return proto.CompactTextString(m) }
func (*SetLogLevelRequest) ProtoMessage()    {}
func (*SetLogLevelRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{17}
}

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

var xxx_messageInfo_SetLogLevelRequest proto.InternalMessageInfo

func (m *SetLogLevelRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *SetLogLevelRequest) GetLoglevels() []*EntitiesLogLevel {
	if m != nil {
		return m.Loglevels
	}
	return nil
}

type SetLogLevelResponse struct {
	DeviceUuid           *Uuid                      `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	Status               Status                     `protobuf:"varint,2,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               SetLogLevelResponse_Reason `protobuf:"varint,3,opt,name=reason,proto3,enum=dmi.SetLogLevelResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                     `protobuf:"bytes,4,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                   `json:"-"`
	XXX_unrecognized     []byte                     `json:"-"`
	XXX_sizecache        int32                      `json:"-"`
}

func (m *SetLogLevelResponse) Reset()         { *m = SetLogLevelResponse{} }
func (m *SetLogLevelResponse) String() string { return proto.CompactTextString(m) }
func (*SetLogLevelResponse) ProtoMessage()    {}
func (*SetLogLevelResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{18}
}

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

var xxx_messageInfo_SetLogLevelResponse proto.InternalMessageInfo

func (m *SetLogLevelResponse) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *SetLogLevelResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *SetLogLevelResponse) GetReason() SetLogLevelResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return SetLogLevelResponse_UNDEFINED_REASON
}

func (m *SetLogLevelResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type GetLogLevelRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	Entities             []string `protobuf:"bytes,2,rep,name=entities,proto3" json:"entities,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *GetLogLevelRequest) Reset()         { *m = GetLogLevelRequest{} }
func (m *GetLogLevelRequest) String() string { return proto.CompactTextString(m) }
func (*GetLogLevelRequest) ProtoMessage()    {}
func (*GetLogLevelRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{19}
}

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

var xxx_messageInfo_GetLogLevelRequest proto.InternalMessageInfo

func (m *GetLogLevelRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *GetLogLevelRequest) GetEntities() []string {
	if m != nil {
		return m.Entities
	}
	return nil
}

type GetLogLevelResponse struct {
	DeviceUuid           *Uuid                      `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	LogLevels            []*EntitiesLogLevel        `protobuf:"bytes,2,rep,name=logLevels,proto3" json:"logLevels,omitempty"`
	Status               Status                     `protobuf:"varint,3,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               GetLogLevelResponse_Reason `protobuf:"varint,4,opt,name=reason,proto3,enum=dmi.GetLogLevelResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                     `protobuf:"bytes,5,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                   `json:"-"`
	XXX_unrecognized     []byte                     `json:"-"`
	XXX_sizecache        int32                      `json:"-"`
}

func (m *GetLogLevelResponse) Reset()         { *m = GetLogLevelResponse{} }
func (m *GetLogLevelResponse) String() string { return proto.CompactTextString(m) }
func (*GetLogLevelResponse) ProtoMessage()    {}
func (*GetLogLevelResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{20}
}

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

var xxx_messageInfo_GetLogLevelResponse proto.InternalMessageInfo

func (m *GetLogLevelResponse) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

func (m *GetLogLevelResponse) GetLogLevels() []*EntitiesLogLevel {
	if m != nil {
		return m.LogLevels
	}
	return nil
}

func (m *GetLogLevelResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *GetLogLevelResponse) GetReason() GetLogLevelResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return GetLogLevelResponse_UNDEFINED_REASON
}

func (m *GetLogLevelResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

type GetLoggableEntitiesRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *GetLoggableEntitiesRequest) Reset()         { *m = GetLoggableEntitiesRequest{} }
func (m *GetLoggableEntitiesRequest) String() string { return proto.CompactTextString(m) }
func (*GetLoggableEntitiesRequest) ProtoMessage()    {}
func (*GetLoggableEntitiesRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{21}
}

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

var xxx_messageInfo_GetLoggableEntitiesRequest proto.InternalMessageInfo

func (m *GetLoggableEntitiesRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

type Heartbeat struct {
	HeartbeatSignature   uint32   `protobuf:"fixed32,1,opt,name=heartbeat_signature,json=heartbeatSignature,proto3" json:"heartbeat_signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *Heartbeat) Reset()         { *m = Heartbeat{} }
func (m *Heartbeat) String() string { return proto.CompactTextString(m) }
func (*Heartbeat) ProtoMessage()    {}
func (*Heartbeat) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{22}
}

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

var xxx_messageInfo_Heartbeat proto.InternalMessageInfo

func (m *Heartbeat) GetHeartbeatSignature() uint32 {
	if m != nil {
		return m.HeartbeatSignature
	}
	return 0
}

type RebootDeviceRequest struct {
	DeviceUuid           *Uuid    `protobuf:"bytes,1,opt,name=device_uuid,json=deviceUuid,proto3" json:"device_uuid,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *RebootDeviceRequest) Reset()         { *m = RebootDeviceRequest{} }
func (m *RebootDeviceRequest) String() string { return proto.CompactTextString(m) }
func (*RebootDeviceRequest) ProtoMessage()    {}
func (*RebootDeviceRequest) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{23}
}

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

var xxx_messageInfo_RebootDeviceRequest proto.InternalMessageInfo

func (m *RebootDeviceRequest) GetDeviceUuid() *Uuid {
	if m != nil {
		return m.DeviceUuid
	}
	return nil
}

type RebootDeviceResponse struct {
	Status               Status                      `protobuf:"varint,3,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               RebootDeviceResponse_Reason `protobuf:"varint,4,opt,name=reason,proto3,enum=dmi.RebootDeviceResponse_Reason" json:"reason,omitempty"`
	ReasonDetail         string                      `protobuf:"bytes,5,opt,name=reason_detail,json=reasonDetail,proto3" json:"reason_detail,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                    `json:"-"`
	XXX_unrecognized     []byte                      `json:"-"`
	XXX_sizecache        int32                       `json:"-"`
}

func (m *RebootDeviceResponse) Reset()         { *m = RebootDeviceResponse{} }
func (m *RebootDeviceResponse) String() string { return proto.CompactTextString(m) }
func (*RebootDeviceResponse) ProtoMessage()    {}
func (*RebootDeviceResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{24}
}

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

var xxx_messageInfo_RebootDeviceResponse proto.InternalMessageInfo

func (m *RebootDeviceResponse) GetStatus() Status {
	if m != nil {
		return m.Status
	}
	return Status_UNDEFINED_STATUS
}

func (m *RebootDeviceResponse) GetReason() RebootDeviceResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return RebootDeviceResponse_UNDEFINED_REASON
}

func (m *RebootDeviceResponse) GetReasonDetail() string {
	if m != nil {
		return m.ReasonDetail
	}
	return ""
}

func init() {
	proto.RegisterEnum("dmi.PhysicalInventoryResponse_Reason", PhysicalInventoryResponse_Reason_name, PhysicalInventoryResponse_Reason_value)
	proto.RegisterEnum("dmi.HWComponentInfoGetResponse_Reason", HWComponentInfoGetResponse_Reason_name, HWComponentInfoGetResponse_Reason_value)
	proto.RegisterEnum("dmi.HWComponentInfoSetResponse_Reason", HWComponentInfoSetResponse_Reason_name, HWComponentInfoSetResponse_Reason_value)
	proto.RegisterEnum("dmi.StartManagingDeviceResponse_Reason", StartManagingDeviceResponse_Reason_name, StartManagingDeviceResponse_Reason_value)
	proto.RegisterEnum("dmi.StopManagingDeviceResponse_Reason", StopManagingDeviceResponse_Reason_name, StopManagingDeviceResponse_Reason_value)
	proto.RegisterEnum("dmi.ManagedDevicesResponse_Reason", ManagedDevicesResponse_Reason_name, ManagedDevicesResponse_Reason_value)
	proto.RegisterEnum("dmi.SetRemoteEndpointResponse_Reason", SetRemoteEndpointResponse_Reason_name, SetRemoteEndpointResponse_Reason_value)
	proto.RegisterEnum("dmi.GetLoggingEndpointResponse_Reason", GetLoggingEndpointResponse_Reason_name, GetLoggingEndpointResponse_Reason_value)
	proto.RegisterEnum("dmi.GetMsgBusEndpointResponse_Reason", GetMsgBusEndpointResponse_Reason_name, GetMsgBusEndpointResponse_Reason_value)
	proto.RegisterEnum("dmi.SetLogLevelResponse_Reason", SetLogLevelResponse_Reason_name, SetLogLevelResponse_Reason_value)
	proto.RegisterEnum("dmi.GetLogLevelResponse_Reason", GetLogLevelResponse_Reason_name, GetLogLevelResponse_Reason_value)
	proto.RegisterEnum("dmi.RebootDeviceResponse_Reason", RebootDeviceResponse_Reason_name, RebootDeviceResponse_Reason_value)
	proto.RegisterType((*PhysicalInventoryRequest)(nil), "dmi.PhysicalInventoryRequest")
	proto.RegisterType((*PhysicalInventoryResponse)(nil), "dmi.PhysicalInventoryResponse")
	proto.RegisterType((*HWComponentInfoGetRequest)(nil), "dmi.HWComponentInfoGetRequest")
	proto.RegisterType((*HWComponentInfoGetResponse)(nil), "dmi.HWComponentInfoGetResponse")
	proto.RegisterType((*HWComponentInfoSetRequest)(nil), "dmi.HWComponentInfoSetRequest")
	proto.RegisterType((*HWComponentInfoSetResponse)(nil), "dmi.HWComponentInfoSetResponse")
	proto.RegisterType((*StartManagingDeviceResponse)(nil), "dmi.StartManagingDeviceResponse")
	proto.RegisterType((*StopManagingDeviceRequest)(nil), "dmi.StopManagingDeviceRequest")
	proto.RegisterType((*StopManagingDeviceResponse)(nil), "dmi.StopManagingDeviceResponse")
	proto.RegisterType((*ManagedDeviceInfo)(nil), "dmi.ManagedDeviceInfo")
	proto.RegisterType((*ManagedDevicesResponse)(nil), "dmi.ManagedDevicesResponse")
	proto.RegisterType((*SetLoggingEndpointRequest)(nil), "dmi.SetLoggingEndpointRequest")
	proto.RegisterType((*SetRemoteEndpointResponse)(nil), "dmi.SetRemoteEndpointResponse")
	proto.RegisterType((*GetLoggingEndpointResponse)(nil), "dmi.GetLoggingEndpointResponse")
	proto.RegisterType((*SetMsgBusEndpointRequest)(nil), "dmi.SetMsgBusEndpointRequest")
	proto.RegisterType((*GetMsgBusEndpointResponse)(nil), "dmi.GetMsgBusEndpointResponse")
	proto.RegisterType((*EntitiesLogLevel)(nil), "dmi.EntitiesLogLevel")
	proto.RegisterType((*SetLogLevelRequest)(nil), "dmi.SetLogLevelRequest")
	proto.RegisterType((*SetLogLevelResponse)(nil), "dmi.SetLogLevelResponse")
	proto.RegisterType((*GetLogLevelRequest)(nil), "dmi.GetLogLevelRequest")
	proto.RegisterType((*GetLogLevelResponse)(nil), "dmi.GetLogLevelResponse")
	proto.RegisterType((*GetLoggableEntitiesRequest)(nil), "dmi.GetLoggableEntitiesRequest")
	proto.RegisterType((*Heartbeat)(nil), "dmi.Heartbeat")
	proto.RegisterType((*RebootDeviceRequest)(nil), "dmi.RebootDeviceRequest")
	proto.RegisterType((*RebootDeviceResponse)(nil), "dmi.RebootDeviceResponse")
}

func init() { proto.RegisterFile("dmi/hw_management_service.proto", fileDescriptor_eae902e73066286d) }

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

// NativeHWManagementServiceClient is the client API for NativeHWManagementService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type NativeHWManagementServiceClient interface {
	// Initializes context for a device and sets up required states
	// In the call to StartManagingDevice, the fields of ModifiableComponent which are relevant
	// and their meanings in this context is mentioned below:
	// name = The unique name that needs to be assigned to this hardware;
	// class = COMPONENT_TYPE_UNDEFINED;
	// parent = nil;
	// alias = Optional;
	// asset_id = Optional;
	// uri = IP Address of the Hardware;
	StartManagingDevice(ctx context.Context, in *ModifiableComponent, opts ...grpc.CallOption) (NativeHWManagementService_StartManagingDeviceClient, error)
	// Stop management of a device and clean up any context and caches for that device
	// This rpc can be called at any time, even before the StartManagingDevice operation
	// has completed, and should be able to cleanup.
	StopManagingDevice(ctx context.Context, in *StopManagingDeviceRequest, opts ...grpc.CallOption) (*StopManagingDeviceResponse, error)
	// Returns an object containing a list of devices managed by this entity
	GetManagedDevices(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ManagedDevicesResponse, error)
	// Get the HW inventory details of the Device
	GetPhysicalInventory(ctx context.Context, in *PhysicalInventoryRequest, opts ...grpc.CallOption) (NativeHWManagementService_GetPhysicalInventoryClient, error)
	// Get the details of a particular HW component
	GetHWComponentInfo(ctx context.Context, in *HWComponentInfoGetRequest, opts ...grpc.CallOption) (NativeHWManagementService_GetHWComponentInfoClient, error)
	// Sets the permissible attributes of a HW component
	SetHWComponentInfo(ctx context.Context, in *HWComponentInfoSetRequest, opts ...grpc.CallOption) (*HWComponentInfoSetResponse, error)
	// Sets the location to which logs need to be shipped
	SetLoggingEndpoint(ctx context.Context, in *SetLoggingEndpointRequest, opts ...grpc.CallOption) (*SetRemoteEndpointResponse, error)
	// Gets the configured location to which the logs are being shipped
	GetLoggingEndpoint(ctx context.Context, in *HardwareID, opts ...grpc.CallOption) (*GetLoggingEndpointResponse, error)
	// Sets the location of the Message Bus to which events and metrics are shipped
	SetMsgBusEndpoint(ctx context.Context, in *SetMsgBusEndpointRequest, opts ...grpc.CallOption) (*SetRemoteEndpointResponse, error)
	// Gets the configured location to which the events and metrics are being shipped
	GetMsgBusEndpoint(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetMsgBusEndpointResponse, error)
	// Gets the entities of a device on which log can be configured. A few are expected, like OS, PON Management etc.
	// In general an entity is any item within an hardware system that can emit logs, e.g. service, process, subsystem,
	// interface, package etc.
	GetLoggableEntities(ctx context.Context, in *GetLoggableEntitiesRequest, opts ...grpc.CallOption) (*GetLogLevelResponse, error)
	// Sets the log level of the device, for each given entity to a certain level.
	// If only one EntitiesLogLevel is provided for the device and that request contains only a log level with
	// no entity in the list it's assumed that the caller wants to set that level for all the entities.
	SetLogLevel(ctx context.Context, in *SetLogLevelRequest, opts ...grpc.CallOption) (*SetLogLevelResponse, error)
	// Gets the configured log level for a certain entity on a certain device.
	// If no entity is specified in the request all the entities with their log level should be returned.
	GetLogLevel(ctx context.Context, in *GetLogLevelRequest, opts ...grpc.CallOption) (*GetLogLevelResponse, error)
	// Performs the heartbeat check
	HeartbeatCheck(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Heartbeat, error)
	// Performs the reboot of the device
	RebootDevice(ctx context.Context, in *RebootDeviceRequest, opts ...grpc.CallOption) (*RebootDeviceResponse, error)
}

type nativeHWManagementServiceClient struct {
	cc *grpc.ClientConn
}

func NewNativeHWManagementServiceClient(cc *grpc.ClientConn) NativeHWManagementServiceClient {
	return &nativeHWManagementServiceClient{cc}
}

func (c *nativeHWManagementServiceClient) StartManagingDevice(ctx context.Context, in *ModifiableComponent, opts ...grpc.CallOption) (NativeHWManagementService_StartManagingDeviceClient, error) {
	stream, err := c.cc.NewStream(ctx, &_NativeHWManagementService_serviceDesc.Streams[0], "/dmi.NativeHWManagementService/StartManagingDevice", opts...)
	if err != nil {
		return nil, err
	}
	x := &nativeHWManagementServiceStartManagingDeviceClient{stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

type NativeHWManagementService_StartManagingDeviceClient interface {
	Recv() (*StartManagingDeviceResponse, error)
	grpc.ClientStream
}

type nativeHWManagementServiceStartManagingDeviceClient struct {
	grpc.ClientStream
}

func (x *nativeHWManagementServiceStartManagingDeviceClient) Recv() (*StartManagingDeviceResponse, error) {
	m := new(StartManagingDeviceResponse)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *nativeHWManagementServiceClient) StopManagingDevice(ctx context.Context, in *StopManagingDeviceRequest, opts ...grpc.CallOption) (*StopManagingDeviceResponse, error) {
	out := new(StopManagingDeviceResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/StopManagingDevice", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetManagedDevices(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ManagedDevicesResponse, error) {
	out := new(ManagedDevicesResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetManagedDevices", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetPhysicalInventory(ctx context.Context, in *PhysicalInventoryRequest, opts ...grpc.CallOption) (NativeHWManagementService_GetPhysicalInventoryClient, error) {
	stream, err := c.cc.NewStream(ctx, &_NativeHWManagementService_serviceDesc.Streams[1], "/dmi.NativeHWManagementService/GetPhysicalInventory", opts...)
	if err != nil {
		return nil, err
	}
	x := &nativeHWManagementServiceGetPhysicalInventoryClient{stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

type NativeHWManagementService_GetPhysicalInventoryClient interface {
	Recv() (*PhysicalInventoryResponse, error)
	grpc.ClientStream
}

type nativeHWManagementServiceGetPhysicalInventoryClient struct {
	grpc.ClientStream
}

func (x *nativeHWManagementServiceGetPhysicalInventoryClient) Recv() (*PhysicalInventoryResponse, error) {
	m := new(PhysicalInventoryResponse)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *nativeHWManagementServiceClient) GetHWComponentInfo(ctx context.Context, in *HWComponentInfoGetRequest, opts ...grpc.CallOption) (NativeHWManagementService_GetHWComponentInfoClient, error) {
	stream, err := c.cc.NewStream(ctx, &_NativeHWManagementService_serviceDesc.Streams[2], "/dmi.NativeHWManagementService/GetHWComponentInfo", opts...)
	if err != nil {
		return nil, err
	}
	x := &nativeHWManagementServiceGetHWComponentInfoClient{stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

type NativeHWManagementService_GetHWComponentInfoClient interface {
	Recv() (*HWComponentInfoGetResponse, error)
	grpc.ClientStream
}

type nativeHWManagementServiceGetHWComponentInfoClient struct {
	grpc.ClientStream
}

func (x *nativeHWManagementServiceGetHWComponentInfoClient) Recv() (*HWComponentInfoGetResponse, error) {
	m := new(HWComponentInfoGetResponse)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *nativeHWManagementServiceClient) SetHWComponentInfo(ctx context.Context, in *HWComponentInfoSetRequest, opts ...grpc.CallOption) (*HWComponentInfoSetResponse, error) {
	out := new(HWComponentInfoSetResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/SetHWComponentInfo", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) SetLoggingEndpoint(ctx context.Context, in *SetLoggingEndpointRequest, opts ...grpc.CallOption) (*SetRemoteEndpointResponse, error) {
	out := new(SetRemoteEndpointResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/SetLoggingEndpoint", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetLoggingEndpoint(ctx context.Context, in *HardwareID, opts ...grpc.CallOption) (*GetLoggingEndpointResponse, error) {
	out := new(GetLoggingEndpointResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetLoggingEndpoint", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) SetMsgBusEndpoint(ctx context.Context, in *SetMsgBusEndpointRequest, opts ...grpc.CallOption) (*SetRemoteEndpointResponse, error) {
	out := new(SetRemoteEndpointResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/SetMsgBusEndpoint", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetMsgBusEndpoint(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetMsgBusEndpointResponse, error) {
	out := new(GetMsgBusEndpointResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetMsgBusEndpoint", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetLoggableEntities(ctx context.Context, in *GetLoggableEntitiesRequest, opts ...grpc.CallOption) (*GetLogLevelResponse, error) {
	out := new(GetLogLevelResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetLoggableEntities", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) SetLogLevel(ctx context.Context, in *SetLogLevelRequest, opts ...grpc.CallOption) (*SetLogLevelResponse, error) {
	out := new(SetLogLevelResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/SetLogLevel", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) GetLogLevel(ctx context.Context, in *GetLogLevelRequest, opts ...grpc.CallOption) (*GetLogLevelResponse, error) {
	out := new(GetLogLevelResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetLogLevel", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) HeartbeatCheck(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Heartbeat, error) {
	out := new(Heartbeat)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/HeartbeatCheck", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *nativeHWManagementServiceClient) RebootDevice(ctx context.Context, in *RebootDeviceRequest, opts ...grpc.CallOption) (*RebootDeviceResponse, error) {
	out := new(RebootDeviceResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/RebootDevice", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// NativeHWManagementServiceServer is the server API for NativeHWManagementService service.
type NativeHWManagementServiceServer interface {
	// Initializes context for a device and sets up required states
	// In the call to StartManagingDevice, the fields of ModifiableComponent which are relevant
	// and their meanings in this context is mentioned below:
	// name = The unique name that needs to be assigned to this hardware;
	// class = COMPONENT_TYPE_UNDEFINED;
	// parent = nil;
	// alias = Optional;
	// asset_id = Optional;
	// uri = IP Address of the Hardware;
	StartManagingDevice(*ModifiableComponent, NativeHWManagementService_StartManagingDeviceServer) error
	// Stop management of a device and clean up any context and caches for that device
	// This rpc can be called at any time, even before the StartManagingDevice operation
	// has completed, and should be able to cleanup.
	StopManagingDevice(context.Context, *StopManagingDeviceRequest) (*StopManagingDeviceResponse, error)
	// Returns an object containing a list of devices managed by this entity
	GetManagedDevices(context.Context, *empty.Empty) (*ManagedDevicesResponse, error)
	// Get the HW inventory details of the Device
	GetPhysicalInventory(*PhysicalInventoryRequest, NativeHWManagementService_GetPhysicalInventoryServer) error
	// Get the details of a particular HW component
	GetHWComponentInfo(*HWComponentInfoGetRequest, NativeHWManagementService_GetHWComponentInfoServer) error
	// Sets the permissible attributes of a HW component
	SetHWComponentInfo(context.Context, *HWComponentInfoSetRequest) (*HWComponentInfoSetResponse, error)
	// Sets the location to which logs need to be shipped
	SetLoggingEndpoint(context.Context, *SetLoggingEndpointRequest) (*SetRemoteEndpointResponse, error)
	// Gets the configured location to which the logs are being shipped
	GetLoggingEndpoint(context.Context, *HardwareID) (*GetLoggingEndpointResponse, error)
	// Sets the location of the Message Bus to which events and metrics are shipped
	SetMsgBusEndpoint(context.Context, *SetMsgBusEndpointRequest) (*SetRemoteEndpointResponse, error)
	// Gets the configured location to which the events and metrics are being shipped
	GetMsgBusEndpoint(context.Context, *empty.Empty) (*GetMsgBusEndpointResponse, error)
	// Gets the entities of a device on which log can be configured. A few are expected, like OS, PON Management etc.
	// In general an entity is any item within an hardware system that can emit logs, e.g. service, process, subsystem,
	// interface, package etc.
	GetLoggableEntities(context.Context, *GetLoggableEntitiesRequest) (*GetLogLevelResponse, error)
	// Sets the log level of the device, for each given entity to a certain level.
	// If only one EntitiesLogLevel is provided for the device and that request contains only a log level with
	// no entity in the list it's assumed that the caller wants to set that level for all the entities.
	SetLogLevel(context.Context, *SetLogLevelRequest) (*SetLogLevelResponse, error)
	// Gets the configured log level for a certain entity on a certain device.
	// If no entity is specified in the request all the entities with their log level should be returned.
	GetLogLevel(context.Context, *GetLogLevelRequest) (*GetLogLevelResponse, error)
	// Performs the heartbeat check
	HeartbeatCheck(context.Context, *empty.Empty) (*Heartbeat, error)
	// Performs the reboot of the device
	RebootDevice(context.Context, *RebootDeviceRequest) (*RebootDeviceResponse, error)
}

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

func (*UnimplementedNativeHWManagementServiceServer) StartManagingDevice(req *ModifiableComponent, srv NativeHWManagementService_StartManagingDeviceServer) error {
	return status.Errorf(codes.Unimplemented, "method StartManagingDevice not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) StopManagingDevice(ctx context.Context, req *StopManagingDeviceRequest) (*StopManagingDeviceResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method StopManagingDevice not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetManagedDevices(ctx context.Context, req *empty.Empty) (*ManagedDevicesResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetManagedDevices not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetPhysicalInventory(req *PhysicalInventoryRequest, srv NativeHWManagementService_GetPhysicalInventoryServer) error {
	return status.Errorf(codes.Unimplemented, "method GetPhysicalInventory not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetHWComponentInfo(req *HWComponentInfoGetRequest, srv NativeHWManagementService_GetHWComponentInfoServer) error {
	return status.Errorf(codes.Unimplemented, "method GetHWComponentInfo not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) SetHWComponentInfo(ctx context.Context, req *HWComponentInfoSetRequest) (*HWComponentInfoSetResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetHWComponentInfo not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) SetLoggingEndpoint(ctx context.Context, req *SetLoggingEndpointRequest) (*SetRemoteEndpointResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetLoggingEndpoint not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetLoggingEndpoint(ctx context.Context, req *HardwareID) (*GetLoggingEndpointResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetLoggingEndpoint not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) SetMsgBusEndpoint(ctx context.Context, req *SetMsgBusEndpointRequest) (*SetRemoteEndpointResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetMsgBusEndpoint not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetMsgBusEndpoint(ctx context.Context, req *empty.Empty) (*GetMsgBusEndpointResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetMsgBusEndpoint not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetLoggableEntities(ctx context.Context, req *GetLoggableEntitiesRequest) (*GetLogLevelResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetLoggableEntities not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) SetLogLevel(ctx context.Context, req *SetLogLevelRequest) (*SetLogLevelResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetLogLevel not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetLogLevel(ctx context.Context, req *GetLogLevelRequest) (*GetLogLevelResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetLogLevel not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) HeartbeatCheck(ctx context.Context, req *empty.Empty) (*Heartbeat, error) {
	return nil, status.Errorf(codes.Unimplemented, "method HeartbeatCheck not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) RebootDevice(ctx context.Context, req *RebootDeviceRequest) (*RebootDeviceResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method RebootDevice not implemented")
}

func RegisterNativeHWManagementServiceServer(s *grpc.Server, srv NativeHWManagementServiceServer) {
	s.RegisterService(&_NativeHWManagementService_serviceDesc, srv)
}

func _NativeHWManagementService_StartManagingDevice_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(ModifiableComponent)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(NativeHWManagementServiceServer).StartManagingDevice(m, &nativeHWManagementServiceStartManagingDeviceServer{stream})
}

type NativeHWManagementService_StartManagingDeviceServer interface {
	Send(*StartManagingDeviceResponse) error
	grpc.ServerStream
}

type nativeHWManagementServiceStartManagingDeviceServer struct {
	grpc.ServerStream
}

func (x *nativeHWManagementServiceStartManagingDeviceServer) Send(m *StartManagingDeviceResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _NativeHWManagementService_StopManagingDevice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(StopManagingDeviceRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).StopManagingDevice(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/StopManagingDevice",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).StopManagingDevice(ctx, req.(*StopManagingDeviceRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetManagedDevices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(empty.Empty)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetManagedDevices(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetManagedDevices",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetManagedDevices(ctx, req.(*empty.Empty))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetPhysicalInventory_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(PhysicalInventoryRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(NativeHWManagementServiceServer).GetPhysicalInventory(m, &nativeHWManagementServiceGetPhysicalInventoryServer{stream})
}

type NativeHWManagementService_GetPhysicalInventoryServer interface {
	Send(*PhysicalInventoryResponse) error
	grpc.ServerStream
}

type nativeHWManagementServiceGetPhysicalInventoryServer struct {
	grpc.ServerStream
}

func (x *nativeHWManagementServiceGetPhysicalInventoryServer) Send(m *PhysicalInventoryResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _NativeHWManagementService_GetHWComponentInfo_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(HWComponentInfoGetRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(NativeHWManagementServiceServer).GetHWComponentInfo(m, &nativeHWManagementServiceGetHWComponentInfoServer{stream})
}

type NativeHWManagementService_GetHWComponentInfoServer interface {
	Send(*HWComponentInfoGetResponse) error
	grpc.ServerStream
}

type nativeHWManagementServiceGetHWComponentInfoServer struct {
	grpc.ServerStream
}

func (x *nativeHWManagementServiceGetHWComponentInfoServer) Send(m *HWComponentInfoGetResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _NativeHWManagementService_SetHWComponentInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(HWComponentInfoSetRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).SetHWComponentInfo(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/SetHWComponentInfo",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).SetHWComponentInfo(ctx, req.(*HWComponentInfoSetRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_SetLoggingEndpoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SetLoggingEndpointRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).SetLoggingEndpoint(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/SetLoggingEndpoint",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).SetLoggingEndpoint(ctx, req.(*SetLoggingEndpointRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetLoggingEndpoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(HardwareID)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetLoggingEndpoint(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetLoggingEndpoint",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetLoggingEndpoint(ctx, req.(*HardwareID))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_SetMsgBusEndpoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SetMsgBusEndpointRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).SetMsgBusEndpoint(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/SetMsgBusEndpoint",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).SetMsgBusEndpoint(ctx, req.(*SetMsgBusEndpointRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetMsgBusEndpoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(empty.Empty)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetMsgBusEndpoint(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetMsgBusEndpoint",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetMsgBusEndpoint(ctx, req.(*empty.Empty))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetLoggableEntities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetLoggableEntitiesRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetLoggableEntities(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetLoggableEntities",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetLoggableEntities(ctx, req.(*GetLoggableEntitiesRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_SetLogLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SetLogLevelRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).SetLogLevel(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/SetLogLevel",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).SetLogLevel(ctx, req.(*SetLogLevelRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_GetLogLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetLogLevelRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetLogLevel(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetLogLevel",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetLogLevel(ctx, req.(*GetLogLevelRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_HeartbeatCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(empty.Empty)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).HeartbeatCheck(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/HeartbeatCheck",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).HeartbeatCheck(ctx, req.(*empty.Empty))
	}
	return interceptor(ctx, in, info, handler)
}

func _NativeHWManagementService_RebootDevice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(RebootDeviceRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).RebootDevice(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/RebootDevice",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).RebootDevice(ctx, req.(*RebootDeviceRequest))
	}
	return interceptor(ctx, in, info, handler)
}

var _NativeHWManagementService_serviceDesc = grpc.ServiceDesc{
	ServiceName: "dmi.NativeHWManagementService",
	HandlerType: (*NativeHWManagementServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "StopManagingDevice",
			Handler:    _NativeHWManagementService_StopManagingDevice_Handler,
		},
		{
			MethodName: "GetManagedDevices",
			Handler:    _NativeHWManagementService_GetManagedDevices_Handler,
		},
		{
			MethodName: "SetHWComponentInfo",
			Handler:    _NativeHWManagementService_SetHWComponentInfo_Handler,
		},
		{
			MethodName: "SetLoggingEndpoint",
			Handler:    _NativeHWManagementService_SetLoggingEndpoint_Handler,
		},
		{
			MethodName: "GetLoggingEndpoint",
			Handler:    _NativeHWManagementService_GetLoggingEndpoint_Handler,
		},
		{
			MethodName: "SetMsgBusEndpoint",
			Handler:    _NativeHWManagementService_SetMsgBusEndpoint_Handler,
		},
		{
			MethodName: "GetMsgBusEndpoint",
			Handler:    _NativeHWManagementService_GetMsgBusEndpoint_Handler,
		},
		{
			MethodName: "GetLoggableEntities",
			Handler:    _NativeHWManagementService_GetLoggableEntities_Handler,
		},
		{
			MethodName: "SetLogLevel",
			Handler:    _NativeHWManagementService_SetLogLevel_Handler,
		},
		{
			MethodName: "GetLogLevel",
			Handler:    _NativeHWManagementService_GetLogLevel_Handler,
		},
		{
			MethodName: "HeartbeatCheck",
			Handler:    _NativeHWManagementService_HeartbeatCheck_Handler,
		},
		{
			MethodName: "RebootDevice",
			Handler:    _NativeHWManagementService_RebootDevice_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "StartManagingDevice",
			Handler:       _NativeHWManagementService_StartManagingDevice_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "GetPhysicalInventory",
			Handler:       _NativeHWManagementService_GetPhysicalInventory_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "GetHWComponentInfo",
			Handler:       _NativeHWManagementService_GetHWComponentInfo_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "dmi/hw_management_service.proto",
}
