github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-shared/v1/models/google_protobuf_field_mask.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  
    11  	"github.com/go-openapi/strfmt"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // GoogleProtobufFieldMask `FieldMask` represents a set of symbolic field paths, for example:
    16  //
    17  // paths: "f.a"
    18  //
    19  //	paths: "f.b.d"
    20  //
    21  // Here `f` represents a field in some root message, `a` and `b`
    22  // fields in the message found in `f`, and `d` a field found in the
    23  // message in `f.b`.
    24  //
    25  // Field masks are used to specify a subset of fields that should be
    26  // returned by a get operation or modified by an update operation.
    27  // Field masks also have a custom JSON encoding (see below).
    28  //
    29  // # Field Masks in Projections
    30  //
    31  // When used in the context of a projection, a response message or
    32  // sub-message is filtered by the API to only contain those fields as
    33  // specified in the mask. For example, if the mask in the previous
    34  // example is applied to a response message as follows:
    35  //
    36  //	f {
    37  //	  a : 22
    38  //	  b {
    39  //	    d : 1
    40  //	    x : 2
    41  //	  }
    42  //	  y : 13
    43  //	}
    44  //	z: 8
    45  //
    46  // The result will not contain specific values for fields x,y and z
    47  // (their value will be set to the default, and omitted in proto text
    48  // output):
    49  //
    50  //	f {
    51  //	  a : 22
    52  //	  b {
    53  //	    d : 1
    54  //	  }
    55  //	}
    56  //
    57  // A repeated field is not allowed except at the last position of a
    58  // paths string.
    59  //
    60  // If a FieldMask object is not present in a get operation, the
    61  // operation applies to all fields (as if a FieldMask of all fields
    62  // had been specified).
    63  //
    64  // Note that a field mask does not necessarily apply to the
    65  // top-level response message. In case of a REST get operation, the
    66  // field mask applies directly to the response, but in case of a REST
    67  // list operation, the mask instead applies to each individual message
    68  // in the returned resource list. In case of a REST custom method,
    69  // other definitions may be used. Where the mask applies will be
    70  // clearly documented together with its declaration in the API.  In
    71  // any case, the effect on the returned resource/resources is required
    72  // behavior for APIs.
    73  //
    74  // # Field Masks in Update Operations
    75  //
    76  // A field mask in update operations specifies which fields of the
    77  // targeted resource are going to be updated. The API is required
    78  // to only change the values of the fields as specified in the mask
    79  // and leave the others untouched. If a resource is passed in to
    80  // describe the updated values, the API ignores the values of all
    81  // fields not covered by the mask.
    82  //
    83  // If a repeated field is specified for an update operation, new values will
    84  // be appended to the existing repeated field in the target resource. Note that
    85  // a repeated field is only allowed in the last position of a `paths` string.
    86  //
    87  // If a sub-message is specified in the last position of the field mask for an
    88  // update operation, then new value will be merged into the existing sub-message
    89  // in the target resource.
    90  //
    91  // For example, given the target message:
    92  //
    93  //	f {
    94  //	  b {
    95  //	    d: 1
    96  //	    x: 2
    97  //	  }
    98  //	  c: [1]
    99  //	}
   100  //
   101  // And an update message:
   102  //
   103  //	f {
   104  //	  b {
   105  //	    d: 10
   106  //	  }
   107  //	  c: [2]
   108  //	}
   109  //
   110  // then if the field mask is:
   111  //
   112  //	paths: ["f.b", "f.c"]
   113  //
   114  // then the result will be:
   115  //
   116  //	f {
   117  //	  b {
   118  //	    d: 10
   119  //	    x: 2
   120  //	  }
   121  //	  c: [1, 2]
   122  //	}
   123  //
   124  // An implementation may provide options to override this default behavior for
   125  // repeated and message fields.
   126  //
   127  // In order to reset a field's value to the default, the field must
   128  // be in the mask and set to the default value in the provided resource.
   129  // Hence, in order to reset all fields of a resource, provide a default
   130  // instance of the resource and set all fields in the mask, or do
   131  // not provide a mask as described below.
   132  //
   133  // If a field mask is not present on update, the operation applies to
   134  // all fields (as if a field mask of all fields has been specified).
   135  // Note that in the presence of schema evolution, this may mean that
   136  // fields the client does not know and has therefore not filled into
   137  // the request will be reset to their default. If this is unwanted
   138  // behavior, a specific service may require a client to always specify
   139  // a field mask, producing an error if not.
   140  //
   141  // As with get operations, the location of the resource which
   142  // describes the updated values in the request message depends on the
   143  // operation kind. In any case, the effect of the field mask is
   144  // required to be honored by the API.
   145  //
   146  // ## Considerations for HTTP REST
   147  //
   148  // The HTTP kind of an update operation which uses a field mask must
   149  // be set to PATCH instead of PUT in order to satisfy HTTP semantics
   150  // (PUT must only be used for full updates).
   151  //
   152  // # JSON Encoding of Field Masks
   153  //
   154  // In JSON, a field mask is encoded as a single string where paths are
   155  // separated by a comma. Fields name in each path are converted
   156  // to/from lower-camel naming conventions.
   157  //
   158  // As an example, consider the following message declarations:
   159  //
   160  //	message Profile {
   161  //	  User user = 1;
   162  //	  Photo photo = 2;
   163  //	}
   164  //	message User {
   165  //	  string display_name = 1;
   166  //	  string address = 2;
   167  //	}
   168  //
   169  // In proto a field mask for `Profile` may look as such:
   170  //
   171  //	mask {
   172  //	  paths: "user.display_name"
   173  //	  paths: "photo"
   174  //	}
   175  //
   176  // In JSON, the same mask is represented as below:
   177  //
   178  //	{
   179  //	  mask: "user.displayName,photo"
   180  //	}
   181  //
   182  // # Field Masks and Oneof Fields
   183  //
   184  // Field masks treat fields in oneofs just as regular fields. Consider the
   185  // following message:
   186  //
   187  //	message SampleMessage {
   188  //	  oneof test_oneof {
   189  //	    string name = 4;
   190  //	    SubMessage sub_message = 9;
   191  //	  }
   192  //	}
   193  //
   194  // The field mask can be:
   195  //
   196  //	mask {
   197  //	  paths: "name"
   198  //	}
   199  //
   200  // Or:
   201  //
   202  //	mask {
   203  //	  paths: "sub_message"
   204  //	}
   205  //
   206  // Note that oneof type names ("test_oneof" in this case) cannot be used in
   207  // paths.
   208  //
   209  // ## Field Mask Verification
   210  //
   211  // The implementation of any API method which has a FieldMask type field in the
   212  // request should verify the included field paths, and return an
   213  // `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
   214  //
   215  // swagger:model google.protobuf.FieldMask
   216  type GoogleProtobufFieldMask struct {
   217  
   218  	// The set of field mask paths.
   219  	Paths []string `json:"paths"`
   220  }
   221  
   222  // Validate validates this google protobuf field mask
   223  func (m *GoogleProtobufFieldMask) Validate(formats strfmt.Registry) error {
   224  	return nil
   225  }
   226  
   227  // ContextValidate validates this google protobuf field mask based on context it is used
   228  func (m *GoogleProtobufFieldMask) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   229  	return nil
   230  }
   231  
   232  // MarshalBinary interface implementation
   233  func (m *GoogleProtobufFieldMask) MarshalBinary() ([]byte, error) {
   234  	if m == nil {
   235  		return nil, nil
   236  	}
   237  	return swag.WriteJSON(m)
   238  }
   239  
   240  // UnmarshalBinary interface implementation
   241  func (m *GoogleProtobufFieldMask) UnmarshalBinary(b []byte) error {
   242  	var res GoogleProtobufFieldMask
   243  	if err := swag.ReadJSON(b, &res); err != nil {
   244  		return err
   245  	}
   246  	*m = res
   247  	return nil
   248  }