github.com/cloudwan/edgelq-sdk@v1.15.4/devices/resources/v1alpha2/device/device.pb.view.go (about)

     1  // Code generated by protoc-gen-goten-resource
     2  // Resource: Device
     3  // DO NOT EDIT!!!
     4  
     5  package device
     6  
     7  import (
     8  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
     9  
    10  	"github.com/cloudwan/goten-sdk/types/view"
    11  )
    12  
    13  // proto imports
    14  import (
    15  	project "github.com/cloudwan/edgelq-sdk/devices/resources/v1alpha2/project"
    16  	iam_attestation_domain "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/attestation_domain"
    17  	iam_iam_common "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/common"
    18  	iam_service_account "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/service_account"
    19  	meta "github.com/cloudwan/goten-sdk/types/meta"
    20  	latlng "google.golang.org/genproto/googleapis/type/latlng"
    21  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    22  	fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    23  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    24  )
    25  
    26  // ensure the imports are used
    27  var (
    28  	_ = googlefieldmaskpb.FieldMask{}
    29  
    30  	_ = view.View_UNSPECIFIED
    31  )
    32  
    33  // make sure we're using proto imports
    34  var (
    35  	_ = &project.Project{}
    36  	_ = &iam_attestation_domain.AttestationDomain{}
    37  	_ = &iam_iam_common.PCR{}
    38  	_ = &iam_service_account.ServiceAccount{}
    39  	_ = &durationpb.Duration{}
    40  	_ = &fieldmaskpb.FieldMask{}
    41  	_ = &timestamppb.Timestamp{}
    42  	_ = &latlng.LatLng{}
    43  	_ = &meta.Meta{}
    44  )
    45  
    46  func ResourceViewFieldMask(viewName view.View, extraMask *Device_FieldMask) *Device_FieldMask {
    47  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
    48  
    49  	switch viewName {
    50  	case view.View_UNSPECIFIED:
    51  		return extraMask
    52  	case view.View_FULL:
    53  		return nil
    54  	case view.View_BASIC:
    55  		protoFieldMask.Paths = append(protoFieldMask.Paths, "name", "display_name", "status.device_info.os_version", "status.device_info.hardware_information.system.product_name", "status.device_info.hardware_information.system.serial_number", "metadata.labels", "metadata.tags")
    56  		break
    57  	case view.View_NAME:
    58  		protoFieldMask.Paths = append(protoFieldMask.Paths, "name", "display_name")
    59  		break
    60  	default:
    61  		return extraMask
    62  	}
    63  	if extraMask != nil {
    64  		protoFieldMask.Paths = append(protoFieldMask.Paths, extraMask.ToProtoFieldMask().Paths...)
    65  	}
    66  	res := &Device_FieldMask{}
    67  	_ = res.FromProtoFieldMask(protoFieldMask)
    68  	return res
    69  }