github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/service_account_key/service_account_key.pb.fieldmask.go (about)

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/iam/proto/v1alpha2/service_account_key.proto
     3  // DO NOT EDIT!!!
     4  
     5  package service_account_key
     6  
     7  import (
     8  	"encoding/json"
     9  	"strings"
    10  
    11  	"google.golang.org/grpc/codes"
    12  	"google.golang.org/grpc/status"
    13  	"google.golang.org/protobuf/proto"
    14  	preflect "google.golang.org/protobuf/reflect/protoreflect"
    15  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    16  
    17  	gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
    18  )
    19  
    20  // proto imports
    21  import (
    22  	service_account "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/service_account"
    23  	meta "github.com/cloudwan/goten-sdk/types/meta"
    24  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    25  )
    26  
    27  // ensure the imports are used
    28  var (
    29  	_ = new(json.Marshaler)
    30  	_ = strings.Builder{}
    31  
    32  	_ = codes.NotFound
    33  	_ = status.Status{}
    34  	_ = new(proto.Message)
    35  	_ = new(preflect.Message)
    36  	_ = googlefieldmaskpb.FieldMask{}
    37  
    38  	_ = new(gotenobject.FieldMask)
    39  )
    40  
    41  // make sure we're using proto imports
    42  var (
    43  	_ = &service_account.ServiceAccount{}
    44  	_ = &timestamppb.Timestamp{}
    45  	_ = &meta.Meta{}
    46  )
    47  
    48  type ServiceAccountKey_FieldMask struct {
    49  	Paths []ServiceAccountKey_FieldPath
    50  }
    51  
    52  func FullServiceAccountKey_FieldMask() *ServiceAccountKey_FieldMask {
    53  	res := &ServiceAccountKey_FieldMask{}
    54  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorName})
    55  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorDisplayName})
    56  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorPublicKeyData})
    57  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorPrivateKeyData})
    58  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorApiKey})
    59  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorAlgorithm})
    60  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorValidNotBefore})
    61  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorValidNotAfter})
    62  	res.Paths = append(res.Paths, &ServiceAccountKey_FieldTerminalPath{selector: ServiceAccountKey_FieldPathSelectorMetadata})
    63  	return res
    64  }
    65  
    66  func (fieldMask *ServiceAccountKey_FieldMask) String() string {
    67  	if fieldMask == nil {
    68  		return "<nil>"
    69  	}
    70  	pathsStr := make([]string, 0, len(fieldMask.Paths))
    71  	for _, path := range fieldMask.Paths {
    72  		pathsStr = append(pathsStr, path.String())
    73  	}
    74  	return strings.Join(pathsStr, ", ")
    75  }
    76  
    77  func (fieldMask *ServiceAccountKey_FieldMask) IsFull() bool {
    78  	if fieldMask == nil {
    79  		return false
    80  	}
    81  	presentSelectors := make([]bool, 9)
    82  	for _, path := range fieldMask.Paths {
    83  		if asFinal, ok := path.(*ServiceAccountKey_FieldTerminalPath); ok {
    84  			presentSelectors[int(asFinal.selector)] = true
    85  		}
    86  	}
    87  	for _, flag := range presentSelectors {
    88  		if !flag {
    89  			return false
    90  		}
    91  	}
    92  	return true
    93  }
    94  
    95  func (fieldMask *ServiceAccountKey_FieldMask) ProtoReflect() preflect.Message {
    96  	return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
    97  		return ParseServiceAccountKey_FieldPath(raw)
    98  	})
    99  }
   100  
   101  func (fieldMask *ServiceAccountKey_FieldMask) ProtoMessage() {}
   102  
   103  func (fieldMask *ServiceAccountKey_FieldMask) Reset() {
   104  	if fieldMask != nil {
   105  		fieldMask.Paths = nil
   106  	}
   107  }
   108  
   109  func (fieldMask *ServiceAccountKey_FieldMask) Subtract(other *ServiceAccountKey_FieldMask) *ServiceAccountKey_FieldMask {
   110  	result := &ServiceAccountKey_FieldMask{}
   111  	removedSelectors := make([]bool, 9)
   112  	otherSubMasks := map[ServiceAccountKey_FieldPathSelector]gotenobject.FieldMask{
   113  		ServiceAccountKey_FieldPathSelectorMetadata: &meta.Meta_FieldMask{},
   114  	}
   115  	mySubMasks := map[ServiceAccountKey_FieldPathSelector]gotenobject.FieldMask{
   116  		ServiceAccountKey_FieldPathSelectorMetadata: &meta.Meta_FieldMask{},
   117  	}
   118  
   119  	for _, path := range other.GetPaths() {
   120  		switch tp := path.(type) {
   121  		case *ServiceAccountKey_FieldTerminalPath:
   122  			removedSelectors[int(tp.selector)] = true
   123  		case *ServiceAccountKey_FieldSubPath:
   124  			otherSubMasks[tp.selector].AppendRawPath(tp.subPath)
   125  		}
   126  	}
   127  	for _, path := range fieldMask.GetPaths() {
   128  		if !removedSelectors[int(path.Selector())] {
   129  			if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 {
   130  				if tp, ok := path.(*ServiceAccountKey_FieldTerminalPath); ok {
   131  					switch tp.selector {
   132  					case ServiceAccountKey_FieldPathSelectorMetadata:
   133  						mySubMasks[ServiceAccountKey_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask()
   134  					}
   135  				} else if tp, ok := path.(*ServiceAccountKey_FieldSubPath); ok {
   136  					mySubMasks[tp.selector].AppendRawPath(tp.subPath)
   137  				}
   138  			} else {
   139  				result.Paths = append(result.Paths, path)
   140  			}
   141  		}
   142  	}
   143  	for selector, mySubMask := range mySubMasks {
   144  		if mySubMask.PathsCount() > 0 {
   145  			for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() {
   146  				result.Paths = append(result.Paths, &ServiceAccountKey_FieldSubPath{selector: selector, subPath: allowedPath})
   147  			}
   148  		}
   149  	}
   150  
   151  	if len(result.Paths) == 0 {
   152  		return nil
   153  	}
   154  	return result
   155  }
   156  
   157  func (fieldMask *ServiceAccountKey_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
   158  	return fieldMask.Subtract(other.(*ServiceAccountKey_FieldMask))
   159  }
   160  
   161  // FilterInputFields generates copy of field paths with output_only field paths removed
   162  func (fieldMask *ServiceAccountKey_FieldMask) FilterInputFields() *ServiceAccountKey_FieldMask {
   163  	result := &ServiceAccountKey_FieldMask{}
   164  	for _, path := range fieldMask.Paths {
   165  		switch path.Selector() {
   166  		case ServiceAccountKey_FieldPathSelectorPrivateKeyData:
   167  		case ServiceAccountKey_FieldPathSelectorApiKey:
   168  		case ServiceAccountKey_FieldPathSelectorValidNotBefore:
   169  		case ServiceAccountKey_FieldPathSelectorValidNotAfter:
   170  		case ServiceAccountKey_FieldPathSelectorMetadata:
   171  			if _, ok := path.(*ServiceAccountKey_FieldTerminalPath); ok {
   172  				for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths {
   173  					result.Paths = append(result.Paths, &ServiceAccountKey_FieldSubPath{selector: path.Selector(), subPath: subpath})
   174  				}
   175  			} else if sub, ok := path.(*ServiceAccountKey_FieldSubPath); ok {
   176  				selectedMask := &meta.Meta_FieldMask{
   177  					Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)},
   178  				}
   179  				for _, allowedPath := range selectedMask.FilterInputFields().Paths {
   180  					result.Paths = append(result.Paths, &ServiceAccountKey_FieldSubPath{selector: ServiceAccountKey_FieldPathSelectorMetadata, subPath: allowedPath})
   181  				}
   182  			}
   183  		default:
   184  			result.Paths = append(result.Paths, path)
   185  		}
   186  	}
   187  	return result
   188  }
   189  
   190  // ToFieldMask is used for proto conversions
   191  func (fieldMask *ServiceAccountKey_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask {
   192  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   193  	for _, path := range fieldMask.Paths {
   194  		protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
   195  	}
   196  	return protoFieldMask
   197  }
   198  
   199  func (fieldMask *ServiceAccountKey_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error {
   200  	if fieldMask == nil {
   201  		return status.Error(codes.Internal, "target field mask is nil")
   202  	}
   203  	fieldMask.Paths = make([]ServiceAccountKey_FieldPath, 0, len(protoFieldMask.Paths))
   204  	for _, strPath := range protoFieldMask.Paths {
   205  		path, err := ParseServiceAccountKey_FieldPath(strPath)
   206  		if err != nil {
   207  			return err
   208  		}
   209  		fieldMask.Paths = append(fieldMask.Paths, path)
   210  	}
   211  	return nil
   212  }
   213  
   214  // implement methods required by customType
   215  func (fieldMask ServiceAccountKey_FieldMask) Marshal() ([]byte, error) {
   216  	protoFieldMask := fieldMask.ToProtoFieldMask()
   217  	return proto.Marshal(protoFieldMask)
   218  }
   219  
   220  func (fieldMask *ServiceAccountKey_FieldMask) Unmarshal(data []byte) error {
   221  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   222  	if err := proto.Unmarshal(data, protoFieldMask); err != nil {
   223  		return err
   224  	}
   225  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   226  		return err
   227  	}
   228  	return nil
   229  }
   230  
   231  func (fieldMask *ServiceAccountKey_FieldMask) Size() int {
   232  	return proto.Size(fieldMask.ToProtoFieldMask())
   233  }
   234  
   235  func (fieldMask ServiceAccountKey_FieldMask) MarshalJSON() ([]byte, error) {
   236  	return json.Marshal(fieldMask.ToProtoFieldMask())
   237  }
   238  
   239  func (fieldMask *ServiceAccountKey_FieldMask) UnmarshalJSON(data []byte) error {
   240  	protoFieldMask := &googlefieldmaskpb.FieldMask{}
   241  	if err := json.Unmarshal(data, protoFieldMask); err != nil {
   242  		return err
   243  	}
   244  	if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
   245  		return err
   246  	}
   247  	return nil
   248  }
   249  
   250  func (fieldMask *ServiceAccountKey_FieldMask) AppendPath(path ServiceAccountKey_FieldPath) {
   251  	fieldMask.Paths = append(fieldMask.Paths, path)
   252  }
   253  
   254  func (fieldMask *ServiceAccountKey_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
   255  	fieldMask.Paths = append(fieldMask.Paths, path.(ServiceAccountKey_FieldPath))
   256  }
   257  
   258  func (fieldMask *ServiceAccountKey_FieldMask) GetPaths() []ServiceAccountKey_FieldPath {
   259  	if fieldMask == nil {
   260  		return nil
   261  	}
   262  	return fieldMask.Paths
   263  }
   264  
   265  func (fieldMask *ServiceAccountKey_FieldMask) GetRawPaths() []gotenobject.FieldPath {
   266  	if fieldMask == nil {
   267  		return nil
   268  	}
   269  	rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
   270  	for _, path := range fieldMask.Paths {
   271  		rawPaths = append(rawPaths, path)
   272  	}
   273  	return rawPaths
   274  }
   275  
   276  func (fieldMask *ServiceAccountKey_FieldMask) SetFromCliFlag(raw string) error {
   277  	path, err := ParseServiceAccountKey_FieldPath(raw)
   278  	if err != nil {
   279  		return err
   280  	}
   281  	fieldMask.Paths = append(fieldMask.Paths, path)
   282  	return nil
   283  }
   284  
   285  func (fieldMask *ServiceAccountKey_FieldMask) Set(target, source *ServiceAccountKey) {
   286  	for _, path := range fieldMask.Paths {
   287  		val, _ := path.GetSingle(source)
   288  		// if val is nil, then field does not exist in source, skip
   289  		// otherwise, process (can still reflect.ValueOf(val).IsNil!)
   290  		if val != nil {
   291  			path.WithIValue(val).SetTo(&target)
   292  		}
   293  	}
   294  }
   295  
   296  func (fieldMask *ServiceAccountKey_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
   297  	fieldMask.Set(target.(*ServiceAccountKey), source.(*ServiceAccountKey))
   298  }
   299  
   300  func (fieldMask *ServiceAccountKey_FieldMask) Project(source *ServiceAccountKey) *ServiceAccountKey {
   301  	if source == nil {
   302  		return nil
   303  	}
   304  	if fieldMask == nil {
   305  		return source
   306  	}
   307  	result := &ServiceAccountKey{}
   308  	metadataMask := &meta.Meta_FieldMask{}
   309  	wholeMetadataAccepted := false
   310  
   311  	for _, p := range fieldMask.Paths {
   312  		switch tp := p.(type) {
   313  		case *ServiceAccountKey_FieldTerminalPath:
   314  			switch tp.selector {
   315  			case ServiceAccountKey_FieldPathSelectorName:
   316  				result.Name = source.Name
   317  			case ServiceAccountKey_FieldPathSelectorDisplayName:
   318  				result.DisplayName = source.DisplayName
   319  			case ServiceAccountKey_FieldPathSelectorPublicKeyData:
   320  				result.PublicKeyData = source.PublicKeyData
   321  			case ServiceAccountKey_FieldPathSelectorPrivateKeyData:
   322  				result.PrivateKeyData = source.PrivateKeyData
   323  			case ServiceAccountKey_FieldPathSelectorApiKey:
   324  				result.ApiKey = source.ApiKey
   325  			case ServiceAccountKey_FieldPathSelectorAlgorithm:
   326  				result.Algorithm = source.Algorithm
   327  			case ServiceAccountKey_FieldPathSelectorValidNotBefore:
   328  				result.ValidNotBefore = source.ValidNotBefore
   329  			case ServiceAccountKey_FieldPathSelectorValidNotAfter:
   330  				result.ValidNotAfter = source.ValidNotAfter
   331  			case ServiceAccountKey_FieldPathSelectorMetadata:
   332  				result.Metadata = source.Metadata
   333  				wholeMetadataAccepted = true
   334  			}
   335  		case *ServiceAccountKey_FieldSubPath:
   336  			switch tp.selector {
   337  			case ServiceAccountKey_FieldPathSelectorMetadata:
   338  				metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath))
   339  			}
   340  		}
   341  	}
   342  	if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 {
   343  		result.Metadata = metadataMask.Project(source.GetMetadata())
   344  	}
   345  	return result
   346  }
   347  
   348  func (fieldMask *ServiceAccountKey_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
   349  	return fieldMask.Project(source.(*ServiceAccountKey))
   350  }
   351  
   352  func (fieldMask *ServiceAccountKey_FieldMask) PathsCount() int {
   353  	if fieldMask == nil {
   354  		return 0
   355  	}
   356  	return len(fieldMask.Paths)
   357  }