github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-shared/v1/models/google_protobuf_any.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 // GoogleProtobufAny `Any` contains an arbitrary serialized protocol buffer message along with a 16 // URL that describes the type of the serialized message. 17 // 18 // Protobuf library provides support to pack/unpack Any values in the form 19 // of utility functions or additional generated methods of the Any type. 20 // 21 // Example 1: Pack and unpack a message in C++. 22 // 23 // Foo foo = ...; 24 // Any any; 25 // any.PackFrom(foo); 26 // ... 27 // if (any.UnpackTo(&foo)) { 28 // ... 29 // } 30 // 31 // Example 2: Pack and unpack a message in Java. 32 // 33 // Foo foo = ...; 34 // Any any = Any.pack(foo); 35 // ... 36 // if (any.is(Foo.class)) { 37 // foo = any.unpack(Foo.class); 38 // } 39 // 40 // Example 3: Pack and unpack a message in Python. 41 // 42 // foo = Foo(...) 43 // any = Any() 44 // any.Pack(foo) 45 // ... 46 // if any.Is(Foo.DESCRIPTOR): 47 // any.Unpack(foo) 48 // ... 49 // 50 // Example 4: Pack and unpack a message in Go 51 // 52 // foo := &pb.Foo{...} 53 // any, err := anypb.New(foo) 54 // if err != nil { 55 // ... 56 // } 57 // ... 58 // foo := &pb.Foo{} 59 // if err := any.UnmarshalTo(foo); err != nil { 60 // ... 61 // } 62 // 63 // The pack methods provided by protobuf library will by default use 64 // 'type.googleapis.com/full.type.name' as the type URL and the unpack 65 // methods only use the fully qualified type name after the last '/' 66 // in the type URL, for example "foo.bar.com/x/y.z" will yield type 67 // name "y.z". 68 // 69 // JSON 70 // ==== 71 // The JSON representation of an `Any` value uses the regular 72 // representation of the deserialized, embedded message, with an 73 // additional field `@type` which contains the type URL. Example: 74 // 75 // package google.profile; 76 // message Person { 77 // string first_name = 1; 78 // string last_name = 2; 79 // } 80 // 81 // { 82 // "@type": "type.googleapis.com/google.profile.Person", 83 // "firstName": <string>, 84 // "lastName": <string> 85 // } 86 // 87 // If the embedded message type is well-known and has a custom JSON 88 // representation, that representation will be embedded adding a field 89 // `value` which holds the custom JSON in addition to the `@type` 90 // field. Example (for message [google.protobuf.Duration][]): 91 // 92 // { 93 // "@type": "type.googleapis.com/google.protobuf.Duration", 94 // "value": "1.212s" 95 // } 96 // 97 // swagger:model google.protobuf.Any 98 type GoogleProtobufAny struct { 99 100 // A URL/resource name that uniquely identifies the type of the serialized 101 // protocol buffer message. This string must contain at least 102 // one "/" character. The last segment of the URL's path must represent 103 // the fully qualified name of the type (as in 104 // `path/google.protobuf.Duration`). The name should be in a canonical form 105 // (e.g., leading "." is not accepted). 106 // 107 // In practice, teams usually precompile into the binary all types that they 108 // expect it to use in the context of Any. However, for URLs which use the 109 // scheme `http`, `https`, or no scheme, one can optionally set up a type 110 // server that maps type URLs to message definitions as follows: 111 // 112 // * If no scheme is provided, `https` is assumed. 113 // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 114 // value in binary format, or produce an error. 115 // * Applications are allowed to cache lookup results based on the 116 // URL, or have them precompiled into a binary to avoid any 117 // lookup. Therefore, binary compatibility needs to be preserved 118 // on changes to types. (Use versioned type names to manage 119 // breaking changes.) 120 // 121 // Note: this functionality is not currently available in the official 122 // protobuf release, and it is not used for type URLs beginning with 123 // type.googleapis.com. 124 // 125 // Schemes other than `http`, `https` (or the empty scheme) might be 126 // used with implementation specific semantics. 127 TypeURL string `json:"type_url,omitempty"` 128 129 // Must be a valid serialized protocol buffer of the above specified type. 130 // Format: byte 131 Value strfmt.Base64 `json:"value,omitempty"` 132 } 133 134 // Validate validates this google protobuf any 135 func (m *GoogleProtobufAny) Validate(formats strfmt.Registry) error { 136 return nil 137 } 138 139 // ContextValidate validates this google protobuf any based on context it is used 140 func (m *GoogleProtobufAny) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 141 return nil 142 } 143 144 // MarshalBinary interface implementation 145 func (m *GoogleProtobufAny) MarshalBinary() ([]byte, error) { 146 if m == nil { 147 return nil, nil 148 } 149 return swag.WriteJSON(m) 150 } 151 152 // UnmarshalBinary interface implementation 153 func (m *GoogleProtobufAny) UnmarshalBinary(b []byte) error { 154 var res GoogleProtobufAny 155 if err := swag.ReadJSON(b, &res); err != nil { 156 return err 157 } 158 *m = res 159 return nil 160 }