// 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
	HWComponentInfoSetResponse_SET_UNSUPPORTED    HWComponentInfoSetResponse_Reason = 6
)

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",
	6: "SET_UNSUPPORTED",
}

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,
	"SET_UNSUPPORTED":    6,
}

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
	// AUTHENTICATION_FAILURE is returned when the device management software/server is not able to connect to the underlying
	// hardware because of authentication failures
	StartManagingDeviceResponse_AUTHENTICATION_FAILURE StartManagingDeviceResponse_Reason = 5
	// INCOMPATIBLE_DEVICE is returned when there is a mismatch between the device management software/server and the underlying
	// hardware
	StartManagingDeviceResponse_INCOMPATIBLE_DEVICE StartManagingDeviceResponse_Reason = 6
)

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",
	5: "AUTHENTICATION_FAILURE",
	6: "INCOMPATIBLE_DEVICE",
}

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,
	"AUTHENTICATION_FAILURE":        5,
	"INCOMPATIBLE_DEVICE":           6,
}

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
	// DEVICE_UNREACHABLE is to be returned when the device manager cannot reach the device and stop managing it
	StopManagingDeviceResponse_DEVICE_UNREACHABLE StopManagingDeviceResponse_Reason = 2
)

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

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

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 SetDmLogLevelResponse_Reason int32

const (
	SetDmLogLevelResponse_UNDEFINED_REASON  SetDmLogLevelResponse_Reason = 0
	SetDmLogLevelResponse_INTERNAL_ERROR    SetDmLogLevelResponse_Reason = 1
	SetDmLogLevelResponse_UNKNOWN_LOG_LEVEL SetDmLogLevelResponse_Reason = 2
)

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

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

func (x SetDmLogLevelResponse_Reason) String() string {
	return proto.EnumName(SetDmLogLevelResponse_Reason_name, int32(x))
}

func (SetDmLogLevelResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{23, 0}
}

type GetDmLogLevelResponse_Reason int32

const (
	GetDmLogLevelResponse_UNDEFINED_REASON GetDmLogLevelResponse_Reason = 0
	GetDmLogLevelResponse_INTERNAL_ERROR   GetDmLogLevelResponse_Reason = 1
)

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

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

func (x GetDmLogLevelResponse_Reason) String() string {
	return proto.EnumName(GetDmLogLevelResponse_Reason_name, int32(x))
}

func (GetDmLogLevelResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{25, 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
	RebootDeviceResponse_DEVICE_IN_WRONG_STATE RebootDeviceResponse_Reason = 4
)

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

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

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

func (RebootDeviceResponse_Reason) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{28, 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 SetDmLogLevelRequest struct {
	Level                LogLevel `protobuf:"varint,1,opt,name=level,proto3,enum=dmi.LogLevel" json:"level,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

var xxx_messageInfo_SetDmLogLevelRequest proto.InternalMessageInfo

func (m *SetDmLogLevelRequest) GetLevel() LogLevel {
	if m != nil {
		return m.Level
	}
	return LogLevel_TRACE
}

type SetDmLogLevelResponse struct {
	Status               Status                       `protobuf:"varint,1,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               SetDmLogLevelResponse_Reason `protobuf:"varint,2,opt,name=reason,proto3,enum=dmi.SetDmLogLevelResponse_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 *SetDmLogLevelResponse) Reset()         { *m = SetDmLogLevelResponse{} }
func (m *SetDmLogLevelResponse) String() string { return proto.CompactTextString(m) }
func (*SetDmLogLevelResponse) ProtoMessage()    {}
func (*SetDmLogLevelResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{23}
}

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

var xxx_messageInfo_SetDmLogLevelResponse proto.InternalMessageInfo

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

func (m *SetDmLogLevelResponse) GetReason() SetDmLogLevelResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return SetDmLogLevelResponse_UNDEFINED_REASON
}

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

type GetDmLogLevelRequest struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

var xxx_messageInfo_GetDmLogLevelRequest proto.InternalMessageInfo

type GetDmLogLevelResponse struct {
	Level                LogLevel                     `protobuf:"varint,1,opt,name=level,proto3,enum=dmi.LogLevel" json:"level,omitempty"`
	Status               Status                       `protobuf:"varint,2,opt,name=status,proto3,enum=dmi.Status" json:"status,omitempty"`
	Reason               GetDmLogLevelResponse_Reason `protobuf:"varint,3,opt,name=reason,proto3,enum=dmi.GetDmLogLevelResponse_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 *GetDmLogLevelResponse) Reset()         { *m = GetDmLogLevelResponse{} }
func (m *GetDmLogLevelResponse) String() string { return proto.CompactTextString(m) }
func (*GetDmLogLevelResponse) ProtoMessage()    {}
func (*GetDmLogLevelResponse) Descriptor() ([]byte, []int) {
	return fileDescriptor_eae902e73066286d, []int{25}
}

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

var xxx_messageInfo_GetDmLogLevelResponse proto.InternalMessageInfo

func (m *GetDmLogLevelResponse) GetLevel() LogLevel {
	if m != nil {
		return m.Level
	}
	return LogLevel_TRACE
}

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

func (m *GetDmLogLevelResponse) GetReason() GetDmLogLevelResponse_Reason {
	if m != nil {
		return m.Reason
	}
	return GetDmLogLevelResponse_UNDEFINED_REASON
}

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

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{26}
}

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{27}
}

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{28}
}

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

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

func (c *nativeHWManagementServiceClient) GetDmLogLevel(ctx context.Context, in *GetDmLogLevelRequest, opts ...grpc.CallOption) (*GetDmLogLevelResponse, error) {
	out := new(GetDmLogLevelResponse)
	err := c.cc.Invoke(ctx, "/dmi.NativeHWManagementService/GetDmLogLevel", 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)
	// Sets the log level of the Device Manager itself
	SetDmLogLevel(context.Context, *SetDmLogLevelRequest) (*SetDmLogLevelResponse, error)
	// Gets the log level at which the Device Manager is running
	GetDmLogLevel(context.Context, *GetDmLogLevelRequest) (*GetDmLogLevelResponse, 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 (*UnimplementedNativeHWManagementServiceServer) SetDmLogLevel(ctx context.Context, req *SetDmLogLevelRequest) (*SetDmLogLevelResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetDmLogLevel not implemented")
}
func (*UnimplementedNativeHWManagementServiceServer) GetDmLogLevel(ctx context.Context, req *GetDmLogLevelRequest) (*GetDmLogLevelResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetDmLogLevel 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)
}

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

func _NativeHWManagementService_GetDmLogLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetDmLogLevelRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(NativeHWManagementServiceServer).GetDmLogLevel(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/dmi.NativeHWManagementService/GetDmLogLevel",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(NativeHWManagementServiceServer).GetDmLogLevel(ctx, req.(*GetDmLogLevelRequest))
	}
	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,
		},
		{
			MethodName: "SetDmLogLevel",
			Handler:    _NativeHWManagementService_SetDmLogLevel_Handler,
		},
		{
			MethodName: "GetDmLogLevel",
			Handler:    _NativeHWManagementService_GetDmLogLevel_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",
}
