diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9623e9f..0000000 --- a/LICENSE +++ /dev/null @@ -1,189 +0,0 @@ -# Anduril Lattice Software Development Kit License Agreement - -## Terms and Conditions - -This is the Anduril Lattice Software Development Kit (SDK) License Agreement (the “License Agreement”). - -1. **Introduction** - - 1.1 "Anduril" means Anduril Industries, Inc., organized under the laws of the State of Delaware, USA, and operating under the laws of - the USA with principal place of business at 1400 Anduril, Costa Mesa, California 92626, USA. - - 1.2 "Lattice" means the Anduril Lattice™ software stack for devices, as made available by Anduril, as updated from time to time. - - 1.3 The Anduril Lattice Software Development Kit (referred to in the License Agreement as the "SDK" and specifically including the - Lattice system files, packaged APIs, and Anduril APIs add-ons) is licensed to you subject to the terms of the License Agreement. - The License Agreement forms a legally binding contract between you and Anduril in relation to your use of the SDK. SDK, as used - herein, also includes any software libraries and/or packages that reference this License. - - 1.4 A "compatible implementation" means any use that (i) is compatible with Lattice; or (ii) successfully is validated by Anduril to be - compatible with Lattice. The determination of a compatible implementation is solely at the discretion of Anduril. - -2. **Accepting this License Agreement** - - - 2.1 In order to use the SDK, you must first agree to the License Agreement. You may not use the SDK if you do not accept the License -Agreement. - - 2.2 By clicking to accept and/or using this SDK, you hereby agree to the terms of the License Agreement. - - 2.3 You may not use the SDK and may not accept the License Agreement if you are a person barred from receiving the SDK under the -laws of the United States or other countries, including the country in which you are resident or from which you use the SDK. - - 2.4 If you are agreeing to be bound by the License Agreement on behalf of your employer or other entity, you represent and warrant that -you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you -may not accept the License Agreement or use the SDK on behalf of your employer or other entity. Use of the SDK on hardware owned -by an entity such as your employer binds your employer to this License Agreement. - -3. **SDK License from Anduril** - - - 3.1 Subject to the terms of the License Agreement, Anduril grants you a limited, revocable, worldwide, royalty-free, non-assignable, - non- exclusive, and non-sublicensable license to use the SDK, or the software referencing this License Agreement, solely to develop - applications for compatible implementations of Anduril technology including without limitation systems, hardware and software such as Anduril Lattice. - - 3.2 You may not use this SDK to develop applications for other platforms (including non-compatible implementations of Lattice) or to -develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of -Lattice, provided that this SDK is not used for that purpose. - - 3.3 You agree that Anduril or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights -that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark -law, and any and all other proprietary rights. Anduril reserves all rights not expressly granted to you. - - 3.4 You may not use the SDK for any purpose not expressly permitted by the License Agreement. Except to the extent required by -applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, de compile, reverse engineer, -disassemble, or create derivative works of the SDK or any part of the SDK. - - 3.5 Use, reproduction and distribution of components of the SDK licensed under an open-source software license are governed solely by -the terms of that open-source software license and not the License Agreement. - - 3.6 You agree that the form and nature of the SDK that Anduril provides may change without prior notice to you and that future versions -of the SDK may be incompatible with applications developed on previous versions of the SDK. You agree that Anduril may stop -(permanently or temporarily) providing the SDK (or any features within the SDK) to you or to users generally at Anduril's sole discretion, -without prior notice to you. - - 3.7 Nothing in the License Agreement gives you a right to use any of Anduril's trade names, trademarks, service marks, logos, domain -names, or other distinctive brand features. - - 3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that -may be affixed to or contained within the SDK. - -4. **Use of the SDK by You** - - - 4.1 Anduril agrees that it obtains no right, title or interest from you (or your licensors) under the License Agreement in or to any software -applications that you develop using the SDK, including any intellectual property rights that subsist in those applications. - - 4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) the License Agreement and (b) any -applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the -export of data or software to and from the United States or other relevant countries). - - 4.3 You agree that if you use the SDK to develop applications for Anduril Lattice users, you will protect the privacy and legal rights of -those users. If your application stores personal or sensitive information, it must do so securely. You may not use a third-party’s Lattice -account information or credentials to access Lattice. - - 4.4 You agree that you will not engage in any activity with the SDK, including the development or distribution of an application, that -interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any -third party including, but not limited to, Anduril or any fixed or mobile communications carrier. - - 4.5 You agree that you are solely responsible for (and that Anduril has no responsibility to you or to any third party for) any data, content, -or resources that you create, transmit or display through Anduril Lattice and/or applications for Lattice, and for the consequences of your -actions (including any loss or damage which Anduril may suffer) by doing so. - - 4.6 You agree that you are solely responsible for (and that Anduril has no responsibility to you or to any third party for) any breach of your -obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and -for the consequences (including any loss or damage which Anduril or any third party may suffer) of any such breach. - -5. **Your Developer Credentials** - - - 5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by -Anduril or which you may choose yourself and that you will be solely responsible for all applications that are developed under your -developer credentials. - -6. **Privacy and Information** - - - 6.1 In order to continually innovate and improve the SDK, Anduril may collect certain usage statistics from the software including but not -limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in -the SDK are being used and how they are being used. - - 6.2 Anonymized and aggregated sets of the data may be used or shared by Anduril to improve the SDK. - -7. **Third Party Applications** - - - 7.1 If you use the SDK to run applications developed by a third party or that access data, content or resources provided by a third party, -you agree that Anduril is not responsible for those applications, data, content, or resources. You understand that all data, content or -resources which you may access through such third party applications are the sole responsibility of the person from which they originated -and that Anduril is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party -applications, data, content, or resources. - - 7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by -intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, -rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless -you have been specifically given permission to do so by the relevant owners. - - 7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between -you and the relevant third party. In that case, the License Agreement does not affect your legal relationship with these third parties. - -8. **Using Lattice APIs** - - - 8.1 Anduril Data APIs - - 8.1.1 If you use any API to retrieve data, you acknowledge that the data may be protected by intellectual property rights which are owned -by Anduril or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be -subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data -(either in whole or in part) unless allowed by the relevant owner and/or terms of service. - - 8.1.2 If you use any API to retrieve a user's data, you acknowledge and agree that you shall retrieve data only with the user's explicit -consent and only when, and for the limited purposes for which, the user has given you permission to do so. - -9. **Terminating this License Agreement** - - - 9.1 The License Agreement will continue to apply until terminated by either you or Anduril as set out below. - - 9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the SDK and any relevant developer -credentials. - - 9.3 Anduril may at any time, terminate the License Agreement with you if: (i) you have breached any provision of the License Agreement; -or (ii) Anduril is required to do so by law; or (iii) the partner with whom Anduril offered certain parts of SDK (such as APIs) to you has -terminated its relationship with Anduril or ceased to offer certain parts of the SDK to you; or (iv) Anduril decides to no longer provide the -SDK to you, or (v) in Anduril's sole discretion, it is no longer commercially viable to provide the SDK. - - 9.4 When the License Agreement comes to an end, you shall delete all copies in your possession of the SDK, and discontinue using the -SDK and related APIs.The provisions of paragraph 14.7 shall continue to apply indefinitely. - -10. **DISCLAIMER OF WARRANTIES** - - - 10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE SDK -IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM ANDURIL. - - 10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE -SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER -SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. - - 10.3 ANDURIL FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR -IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - -11. **LIMITATION OF LIABILITY** - - - 11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT ANDURIL, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS -SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER -OR NOT ANDURIL OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY -OF ANY SUCH LOSSES ARISING. - -12. **Indemnification** - - - 12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Anduril, its affiliates and their respective -directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, -liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the SDK, -(b) any application you develop on the SDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual -property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with -the License Agreement. - -13. **Changes to the License Agreement** - - - 13.1 Anduril may make changes to the License Agreement as it distributes new versions of the SDK. When these changes are made, -Anduril will make a new version of the License Agreement available on the website where the SDK is made available. - -14. **General Legal Terms** - - - 14.1 The License Agreement constitutes the whole legal agreement between you and Anduril and governs your use of the SDK (excluding -any services which Anduril may provide to you under a separate written agreement), and completely replaces any prior agreements -between you and Anduril in relation to the SDK. - - 14.2 You agree that if Anduril does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or -which Anduril has the benefit of under any applicable law), this will not be taken to be a formal waiver of Anduril's rights and that those -rights or remedies will still be available to Anduril. - - 14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then -that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions -of the License Agreement will continue to be valid and enforceable. - - 14.4 You acknowledge and agree that any subsidiaries or affiliates of Anduril is the parent shall be third party beneficiaries to the License -Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement -that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the -License Agreement. - - 14.5 EXPORT RESTRICTIONS. YOU MAY NOT EXPORT THIS LICENSE. THE SDK MAY BE SUBJECT TO UNITED STATES EXPORT -LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND -REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END -USE. - - 14.6 The rights granted in the License Agreement may not be assigned or transferred by either you or Anduril without the prior written -approval of the other party. Neither you nor Anduril shall be permitted to delegate their responsibilities or obligations under the License -Agreement without the prior written approval of the other party. - - 14.7 The License Agreement, and your relationship with Anduril under the License Agreement, shall be governed by the laws of the State -of Delaware without regard to its conflict of laws provisions. Except for claims for injunctive or equitable relief, and claims regarding -intellectual property rights to the extent not relating to indemnification under this Agreement (all of which may be brought in any competent -state or federal court), any dispute arising under this Agreement shall be finally settled in accordance with the Comprehensive Arbitration -Rules of the Judicial Arbitration and Mediation Service, Inc. (“JAMS”) by three arbitrators appointed in accordance with such Rules. The -arbitration shall take place in Irvine, California and the arbitral decision may be enforced in any competent U.S. federal court. In the event -of any court action, you agree to submit to the exclusive jurisdiction of the courts located in the city of Irvine located in Orange, California. -Notwithstanding this, you agree that Anduril shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal -relief) in any jurisdiction. - -**April 14, 2025** \ No newline at end of file diff --git a/README.md b/README.md index 206d7f4..4496092 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,17 @@ -# Lattice SDK Go library +# Lattice SDK Go Library ![](https://www.anduril.com/lattice-sdk/) -The Lattice SDK Go library provides convenient access to the Lattice API from Go. + +The Lattice SDK Go library provides convenient access to the Lattice SDK APIs from Go. ## Documentation API reference documentation is available [here](https://developer.anduril.com/). -## Requirements - -To use the SDK please ensure you have the following installed: - -* [Go](https://go.dev/doc/install) - -## Installation - -Install the Lattice SDK package with - -``` -go get github.com/anduril/lattice-sdk-go/v2 -``` - -## Support +## Reference -For support with this library please reach out to your Anduril representative. +A full reference for this library is available [here](./reference.md). ## Usage @@ -36,8 +23,8 @@ package example import ( client "github.com/anduril/lattice-sdk-go/v2/client" option "github.com/anduril/lattice-sdk-go/v2/option" - context "context" Lattice "github.com/anduril/lattice-sdk-go/v2" + context "context" ) func do() { @@ -46,11 +33,12 @@ func do() { "", ), ) + request := &Lattice.EntityEventRequest{ + SessionToken: "sessionToken", + } client.Entities.LongPollEntityEvents( context.TODO(), - &Lattice.EntityEventRequest{ - SessionToken: "sessionToken", - }, + request, ) } ``` @@ -139,6 +127,9 @@ A request is deemed retryable when any of the following HTTP status codes is ret - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) +If the `Retry-After` header is present in the response, the SDK will prioritize respecting its value exactly +over the default exponential backoff. + Use the `option.WithMaxAttempts` option to configure this behavior for the entire client or an individual request: ```go @@ -162,3 +153,25 @@ defer cancel() response, err := client.Entities.LongPollEntityEvents(ctx, ...) ``` + +### Explicit Null + +If you want to send the explicit `null` JSON value through an optional parameter, you can use the setters\ +that come with every object. Calling a setter method for a property will flip a bit in the `explicitFields` +bitfield for that setter's object; during serialization, any property with a flipped bit will have its +omittable status stripped, so zero or `nil` values will be sent explicitly rather than omitted altogether: + +```go +type ExampleRequest struct { + // An optional string parameter. + Name *string `json:"name,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +request := &ExampleRequest{} +request.SetName(nil) + +response, err := client.Entities.LongPollEntityEvents(ctx, request, ...) +``` diff --git a/client/client.go b/client/client.go index a799ecb..51fcc87 100644 --- a/client/client.go +++ b/client/client.go @@ -9,7 +9,6 @@ import ( objects "github.com/anduril/lattice-sdk-go/v2/objects" option "github.com/anduril/lattice-sdk-go/v2/option" tasks "github.com/anduril/lattice-sdk-go/v2/tasks" - http "net/http" ) type Client struct { @@ -17,17 +16,18 @@ type Client struct { Tasks *tasks.Client Objects *objects.Client + options *core.RequestOptions baseURL string caller *internal.Caller - header http.Header } func NewClient(opts ...option.RequestOption) *Client { options := core.NewRequestOptions(opts...) return &Client{ - Entities: entities.NewClient(opts...), - Tasks: tasks.NewClient(opts...), - Objects: objects.NewClient(opts...), + Entities: entities.NewClient(options), + Tasks: tasks.NewClient(options), + Objects: objects.NewClient(options), + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -35,6 +35,5 @@ func NewClient(opts ...option.RequestOption) *Client { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } diff --git a/client/client_test.go b/client/client_test.go index 458c288..51dc022 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -40,6 +40,6 @@ func TestNewClient(t *testing.T) { option.WithHTTPHeader(header), ) assert.Empty(t, c.baseURL) - assert.Equal(t, "test", c.header.Get("X-API-Tenancy")) + assert.Equal(t, "test", c.options.HTTPHeader.Get("X-API-Tenancy")) }) } diff --git a/core/request_option.go b/core/request_option.go index 09ceed2..e1dcc5b 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -56,8 +56,7 @@ func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/anduril/lattice-sdk-go/v2") - headers.Set("X-Fern-SDK-Version", "v2.2.0") - headers.Set("User-Agent", "github.com/anduril/lattice-sdk-go/2.2.0") + headers.Set("X-Fern-SDK-Version", "0.0.1") return headers } diff --git a/entities.go b/entities.go index 0f57198..aa0eb9c 100644 --- a/entities.go +++ b/entities.go @@ -6,24 +6,89 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" time "time" ) +var ( + entityEventRequestFieldSessionToken = big.NewInt(1 << 0) + entityEventRequestFieldBatchSize = big.NewInt(1 << 1) +) + type EntityEventRequest struct { // Long-poll session identifier. Leave empty to start a new polling session. SessionToken string `json:"sessionToken" url:"-"` // Maximum size of response batch. Defaults to 100. Must be between 1 and 2000 (inclusive). BatchSize *int `json:"batchSize,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (e *EntityEventRequest) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) } +// SetSessionToken sets the SessionToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEventRequest) SetSessionToken(sessionToken string) { + e.SessionToken = sessionToken + e.require(entityEventRequestFieldSessionToken) +} + +// SetBatchSize sets the BatchSize field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEventRequest) SetBatchSize(batchSize *int) { + e.BatchSize = batchSize + e.require(entityEventRequestFieldBatchSize) +} + +var ( + entityOverrideFieldEntity = big.NewInt(1 << 0) + entityOverrideFieldProvenance = big.NewInt(1 << 1) +) + type EntityOverride struct { // The entity containing the overridden fields. The service will extract the overridable fields from // the object and ignore all other fields. Entity *Entity `json:"entity,omitempty" url:"-"` // Additional information about the source of the override. Provenance *Provenance `json:"provenance,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (e *EntityOverride) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetEntity sets the Entity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityOverride) SetEntity(entity *Entity) { + e.Entity = entity + e.require(entityOverrideFieldEntity) } +// SetProvenance sets the Provenance field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityOverride) SetProvenance(provenance *Provenance) { + e.Provenance = provenance + e.require(entityOverrideFieldProvenance) +} + +var ( + entityStreamRequestFieldHeartbeatIntervalMs = big.NewInt(1 << 0) + entityStreamRequestFieldPreExistingOnly = big.NewInt(1 << 1) + entityStreamRequestFieldComponentsToInclude = big.NewInt(1 << 2) +) + type EntityStreamRequest struct { // at what interval to send heartbeat events, defaults to 30s. HeartbeatIntervalMs *int `json:"heartbeatIntervalMS,omitempty" url:"-"` @@ -31,14 +96,54 @@ type EntityStreamRequest struct { PreExistingOnly *bool `json:"preExistingOnly,omitempty" url:"-"` // list of components to include, leave empty to include all components. ComponentsToInclude []string `json:"componentsToInclude,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (e *EntityStreamRequest) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetHeartbeatIntervalMs sets the HeartbeatIntervalMs field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamRequest) SetHeartbeatIntervalMs(heartbeatIntervalMs *int) { + e.HeartbeatIntervalMs = heartbeatIntervalMs + e.require(entityStreamRequestFieldHeartbeatIntervalMs) +} + +// SetPreExistingOnly sets the PreExistingOnly field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamRequest) SetPreExistingOnly(preExistingOnly *bool) { + e.PreExistingOnly = preExistingOnly + e.require(entityStreamRequestFieldPreExistingOnly) +} + +// SetComponentsToInclude sets the ComponentsToInclude field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamRequest) SetComponentsToInclude(componentsToInclude []string) { + e.ComponentsToInclude = componentsToInclude + e.require(entityStreamRequestFieldComponentsToInclude) } // Event representing some type of entity change. +var ( + entityEventFieldEventType = big.NewInt(1 << 0) + entityEventFieldTime = big.NewInt(1 << 1) + entityEventFieldEntity = big.NewInt(1 << 2) +) + type EntityEvent struct { EventType *EntityEventEventType `json:"eventType,omitempty" url:"eventType,omitempty"` Time *time.Time `json:"time,omitempty" url:"time,omitempty"` Entity *Entity `json:"entity,omitempty" url:"entity,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -68,6 +173,34 @@ func (e *EntityEvent) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EntityEvent) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetEventType sets the EventType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEvent) SetEventType(eventType *EntityEventEventType) { + e.EventType = eventType + e.require(entityEventFieldEventType) +} + +// SetTime sets the Time field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEvent) SetTime(time *time.Time) { + e.Time = time + e.require(entityEventFieldTime) +} + +// SetEntity sets the Entity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEvent) SetEntity(entity *Entity) { + e.Entity = entity + e.require(entityEventFieldEntity) +} + func (e *EntityEvent) UnmarshalJSON(data []byte) error { type embed EntityEvent var unmarshaler = struct { @@ -99,7 +232,8 @@ func (e *EntityEvent) MarshalJSON() ([]byte, error) { embed: embed(*e), Time: internal.NewOptionalDateTime(e.Time), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) } func (e *EntityEvent) String() string { @@ -148,11 +282,19 @@ func (e EntityEventEventType) Ptr() *EntityEventEventType { return &e } +var ( + entityEventResponseFieldSessionToken = big.NewInt(1 << 0) + entityEventResponseFieldEntityEvents = big.NewInt(1 << 1) +) + type EntityEventResponse struct { // Long-poll session identifier. Use this token to resume polling on subsequent requests. SessionToken *string `json:"sessionToken,omitempty" url:"sessionToken,omitempty"` EntityEvents []*EntityEvent `json:"entityEvents,omitempty" url:"entityEvents,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -175,6 +317,27 @@ func (e *EntityEventResponse) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EntityEventResponse) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetSessionToken sets the SessionToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEventResponse) SetSessionToken(sessionToken *string) { + e.SessionToken = sessionToken + e.require(entityEventResponseFieldSessionToken) +} + +// SetEntityEvents sets the EntityEvents field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityEventResponse) SetEntityEvents(entityEvents []*EntityEvent) { + e.EntityEvents = entityEvents + e.require(entityEventResponseFieldEntityEvents) +} + func (e *EntityEventResponse) UnmarshalJSON(data []byte) error { type unmarshaler EntityEventResponse var value unmarshaler @@ -191,6 +354,17 @@ func (e *EntityEventResponse) UnmarshalJSON(data []byte) error { return nil } +func (e *EntityEventResponse) MarshalJSON() ([]byte, error) { + type embed EntityEventResponse + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *EntityEventResponse) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -203,11 +377,20 @@ func (e *EntityEventResponse) String() string { return fmt.Sprintf("%#v", e) } +var ( + entityStreamEventFieldEventType = big.NewInt(1 << 0) + entityStreamEventFieldTime = big.NewInt(1 << 1) + entityStreamEventFieldEntity = big.NewInt(1 << 2) +) + type EntityStreamEvent struct { EventType *EntityEventEventType `json:"eventType,omitempty" url:"eventType,omitempty"` Time *time.Time `json:"time,omitempty" url:"time,omitempty"` Entity *Entity `json:"entity,omitempty" url:"entity,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -237,6 +420,34 @@ func (e *EntityStreamEvent) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EntityStreamEvent) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetEventType sets the EventType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamEvent) SetEventType(eventType *EntityEventEventType) { + e.EventType = eventType + e.require(entityStreamEventFieldEventType) +} + +// SetTime sets the Time field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamEvent) SetTime(time *time.Time) { + e.Time = time + e.require(entityStreamEventFieldTime) +} + +// SetEntity sets the Entity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamEvent) SetEntity(entity *Entity) { + e.Entity = entity + e.require(entityStreamEventFieldEntity) +} + func (e *EntityStreamEvent) UnmarshalJSON(data []byte) error { type embed EntityStreamEvent var unmarshaler = struct { @@ -268,7 +479,8 @@ func (e *EntityStreamEvent) MarshalJSON() ([]byte, error) { embed: embed(*e), Time: internal.NewOptionalDateTime(e.Time), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) } func (e *EntityStreamEvent) String() string { @@ -283,10 +495,17 @@ func (e *EntityStreamEvent) String() string { return fmt.Sprintf("%#v", e) } +var ( + entityStreamHeartbeatFieldTimestamp = big.NewInt(1 << 0) +) + type EntityStreamHeartbeat struct { // timestamp of the heartbeat Timestamp *time.Time `json:"timestamp,omitempty" url:"timestamp,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -302,6 +521,20 @@ func (e *EntityStreamHeartbeat) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EntityStreamHeartbeat) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetTimestamp sets the Timestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityStreamHeartbeat) SetTimestamp(timestamp *time.Time) { + e.Timestamp = timestamp + e.require(entityStreamHeartbeatFieldTimestamp) +} + func (e *EntityStreamHeartbeat) UnmarshalJSON(data []byte) error { type embed EntityStreamHeartbeat var unmarshaler = struct { @@ -333,7 +566,8 @@ func (e *EntityStreamHeartbeat) MarshalJSON() ([]byte, error) { embed: embed(*e), Timestamp: internal.NewOptionalDateTime(e.Timestamp), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) } func (e *EntityStreamHeartbeat) String() string { @@ -348,10 +582,17 @@ func (e *EntityStreamHeartbeat) String() string { return fmt.Sprintf("%#v", e) } +var ( + heartbeatObjectFieldTimestamp = big.NewInt(1 << 0) +) + type HeartbeatObject struct { // timestamp of the heartbeat Timestamp *time.Time `json:"timestamp,omitempty" url:"timestamp,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -367,6 +608,20 @@ func (h *HeartbeatObject) GetExtraProperties() map[string]interface{} { return h.extraProperties } +func (h *HeartbeatObject) require(field *big.Int) { + if h.explicitFields == nil { + h.explicitFields = big.NewInt(0) + } + h.explicitFields.Or(h.explicitFields, field) +} + +// SetTimestamp sets the Timestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HeartbeatObject) SetTimestamp(timestamp *time.Time) { + h.Timestamp = timestamp + h.require(heartbeatObjectFieldTimestamp) +} + func (h *HeartbeatObject) UnmarshalJSON(data []byte) error { type embed HeartbeatObject var unmarshaler = struct { @@ -398,7 +653,8 @@ func (h *HeartbeatObject) MarshalJSON() ([]byte, error) { embed: embed(*h), Timestamp: internal.NewOptionalDateTime(h.Timestamp), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, h.explicitFields) + return json.Marshal(explicitMarshaler) } func (h *HeartbeatObject) String() string { diff --git a/entities/client.go b/entities/client.go index f19b9f7..330e864 100644 --- a/entities/client.go +++ b/entities/client.go @@ -4,7 +4,7 @@ package entities import ( context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" @@ -14,15 +14,15 @@ import ( type Client struct { WithRawResponse *RawClient + options *core.RequestOptions baseURL string caller *internal.Caller - header http.Header } -func NewClient(opts ...option.RequestOption) *Client { - options := core.NewRequestOptions(opts...) +func NewClient(options *core.RequestOptions) *Client { return &Client{ WithRawResponse: NewRawClient(options), + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -30,7 +30,6 @@ func NewClient(opts ...option.RequestOption) *Client { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } @@ -43,9 +42,9 @@ func NewClient(opts ...option.RequestOption) *Client { // provenance.sourceUpdateTime is greater than the provenance.sourceUpdateTime of the existing entity. func (c *Client) PublishEntity( ctx context.Context, - request *v2.Entity, + request *Lattice.Entity, opts ...option.RequestOption, -) (*v2.Entity, error) { +) (*Lattice.Entity, error) { response, err := c.WithRawResponse.PublishEntity( ctx, request, @@ -62,7 +61,7 @@ func (c *Client) GetEntity( // ID of the entity to return entityID string, opts ...option.RequestOption, -) (*v2.Entity, error) { +) (*Lattice.Entity, error) { response, err := c.WithRawResponse.GetEntity( ctx, entityID, @@ -87,9 +86,9 @@ func (c *Client) OverrideEntity( entityID string, // fieldPath to override fieldPath string, - request *v2.EntityOverride, + request *Lattice.EntityOverride, opts ...option.RequestOption, -) (*v2.Entity, error) { +) (*Lattice.Entity, error) { response, err := c.WithRawResponse.OverrideEntity( ctx, entityID, @@ -111,7 +110,7 @@ func (c *Client) RemoveEntityOverride( // The fieldPath to clear overrides from. fieldPath string, opts ...option.RequestOption, -) (*v2.Entity, error) { +) (*Lattice.Entity, error) { response, err := c.WithRawResponse.RemoveEntityOverride( ctx, entityID, @@ -135,9 +134,9 @@ func (c *Client) RemoveEntityOverride( // In this case you must start a new session by sending a request with an empty session token. func (c *Client) LongPollEntityEvents( ctx context.Context, - request *v2.EntityEventRequest, + request *Lattice.EntityEventRequest, opts ...option.RequestOption, -) (*v2.EntityEventResponse, error) { +) (*Lattice.EntityEventResponse, error) { response, err := c.WithRawResponse.LongPollEntityEvents( ctx, request, @@ -152,9 +151,9 @@ func (c *Client) LongPollEntityEvents( // Establishes a persistent connection to stream entity events as they occur. func (c *Client) StreamEntities( ctx context.Context, - request *v2.EntityStreamRequest, + request *Lattice.EntityStreamRequest, opts ...option.RequestOption, -) (*core.Stream[v2.StreamEntitiesResponse], error) { +) (*core.Stream[Lattice.StreamEntitiesResponse], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -163,24 +162,12 @@ func (c *Client) StreamEntities( ) endpointURL := baseURL + "/api/v1/entities/stream" headers := internal.MergeHeaders( - c.header.Clone(), + c.options.ToHeader(), options.ToHeader(), ) headers.Add("Accept", "text/event-stream") headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - } - streamer := internal.NewStreamer[v2.StreamEntitiesResponse](c.caller) + streamer := Lattice.NewStreamer[Lattice.StreamEntitiesResponse](c.caller) return streamer.Stream( ctx, &internal.StreamParams{ @@ -195,7 +182,7 @@ func (c *Client) StreamEntities( Terminator: internal.DefaultSSETerminator, Format: core.StreamFormatSSE, Request: request, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) } diff --git a/entities/entities_test/entities_test.go b/entities/entities_test/entities_test.go new file mode 100644 index 0000000..e8cfa1a --- /dev/null +++ b/entities/entities_test/entities_test.go @@ -0,0 +1,316 @@ +// Code generated by Fern. DO NOT EDIT. + +package entities_test + +import ( + context "context" + fmt "fmt" + v2 "github.com/anduril/lattice-sdk-go/v2" + client "github.com/anduril/lattice-sdk-go/v2/client" + option "github.com/anduril/lattice-sdk-go/v2/option" + require "github.com/stretchr/testify/require" + gowiremock "github.com/wiremock/go-wiremock" + wiremocktestcontainersgo "github.com/wiremock/wiremock-testcontainers-go" + http "net/http" + os "os" + testing "testing" +) + +// TestMain sets up shared test fixtures for all tests in this package// Global test fixtures +var ( + WireMockContainer *wiremocktestcontainersgo.WireMockContainer + WireMockBaseURL string + WireMockClient *gowiremock.Client +) + +// TestMain sets up shared test fixtures for all tests in this package +func TestMain(m *testing.M) { + // Setup shared WireMock container + ctx := context.Background() + container, err := wiremocktestcontainersgo.RunContainerAndStopOnCleanup( + ctx, + &testing.T{}, + wiremocktestcontainersgo.WithImage("docker.io/wiremock/wiremock:3.9.1"), + ) + if err != nil { + fmt.Printf("Failed to start WireMock container: %v\n", err) + os.Exit(1) + } + + // Store global references + WireMockContainer = container + + // Try to get the base URL using the standard method first + baseURL, err := container.Endpoint(ctx, "") + if err == nil { + // Standard method worked (running outside DinD) + // This uses the mapped port (e.g., localhost:59553) + WireMockBaseURL = "http://" + baseURL + WireMockClient = container.Client + } else { + // Standard method failed, use internal IP fallback (DinD environment) + fmt.Printf("Standard endpoint resolution failed, using internal IP fallback: %v\n", err) + + inspect, err := container.Inspect(ctx) + if err != nil { + fmt.Printf("Failed to inspect WireMock container: %v\n", err) + os.Exit(1) + } + + // Find the IP address from the container's networks + var containerIP string + for _, network := range inspect.NetworkSettings.Networks { + if network.IPAddress != "" { + containerIP = network.IPAddress + break + } + } + + if containerIP == "" { + fmt.Printf("Failed to get WireMock container IP address\n") + os.Exit(1) + } + + // In DinD, use the internal port directly (8080 for WireMock HTTP) + // Don't use the mapped port since it doesn't exist in this environment + WireMockBaseURL = fmt.Sprintf("http://%s:8080", containerIP) + + // The container.Client was created with a bad URL, so we need a new one + WireMockClient = gowiremock.NewClient(WireMockBaseURL) + } + + fmt.Printf("WireMock available at: %s\n", WireMockBaseURL) + + // Run all tests + code := m.Run() + + // Cleanup + if WireMockContainer != nil { + WireMockContainer.Terminate(ctx) + } + + // Exit with the same code as the tests + os.Exit(code) +} + +func TestEntitiesPublishEntityWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Put(gowiremock.URLPathTemplate("/api/v1/entities")).WithBodyPattern(gowiremock.MatchesJsonSchema("{}", "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"entityId": "entityId", "description": "description", "isLive": true, "createdTime": "2024-01-15T09:30:00Z", "expiryTime": "2024-01-15T09:30:00Z", "noExpiry": true, "status": map[string]interface{}{"code": 1, "message": "message", "details": []interface{}{map[string]interface{}{}}}, "location": map[string]interface{}{"position": map[string]interface{}{"latitudeDegrees": 1.1, "longitudeDegrees": 1.1, "altitudeHaeMeters": 1.1, "altitudeAglMeters": 1.1, "altitudeAsfMeters": 1.1, "pressureDepthMeters": 1.1}, "velocityEnu": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "speedMps": 1.1, "acceleration": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "attitudeEnu": map[string]interface{}{"x": 1.1, "y": 1.1, "z": 1.1, "w": 1.1}}, "locationUncertainty": map[string]interface{}{"positionEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "velocityEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "positionErrorEllipse": map[string]interface{}{"probability": 1.1, "semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1}}, "geoShape": map[string]interface{}{"line": map[string]interface{}{"positions": []interface{}{map[string]interface{}{}}}, "polygon": map[string]interface{}{"rings": []interface{}{map[string]interface{}{}}, "isRectangle": true}, "ellipse": map[string]interface{}{"semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1, "heightM": 1.1}, "ellipsoid": map[string]interface{}{"forwardAxisM": 1.1, "sideAxisM": 1.1, "upAxisM": 1.1}}, "geoDetails": map[string]interface{}{"type": "GEO_TYPE_INVALID", "controlArea": map[string]interface{}{"type": "CONTROL_AREA_TYPE_INVALID"}, "acm": map[string]interface{}{"acmType": "ACM_DETAIL_TYPE_INVALID", "acmDescription": "acmDescription"}}, "aliases": map[string]interface{}{"alternateIds": []interface{}{map[string]interface{}{}}, "name": "name"}, "tracked": map[string]interface{}{"trackQualityWrapper": 1, "sensorHits": 1, "numberOfObjects": map[string]interface{}{"lowerBound": 1, "upperBound": 1}, "radarCrossSection": 1.1, "lastMeasurementTime": "2024-01-15T09:30:00Z"}, "correlation": map[string]interface{}{"primary": map[string]interface{}{"secondaryEntityIds": []interface{}{"secondaryEntityIds"}}, "secondary": map[string]interface{}{"primaryEntityId": "primaryEntityId"}, "membership": map[string]interface{}{"correlationSetId": "correlationSetId"}, "decorrelation": map[string]interface{}{"decorrelatedEntities": []interface{}{map[string]interface{}{}}}}, "milView": map[string]interface{}{"disposition": "DISPOSITION_UNKNOWN", "environment": "ENVIRONMENT_UNKNOWN", "nationality": "NATIONALITY_INVALID"}, "ontology": map[string]interface{}{"platformType": "platformType", "specificType": "specificType", "template": "TEMPLATE_INVALID"}, "sensors": map[string]interface{}{"sensors": []interface{}{map[string]interface{}{}}}, "payloads": map[string]interface{}{"payloadConfigurations": []interface{}{map[string]interface{}{}}}, "powerState": map[string]interface{}{"sourceIdToState": map[string]interface{}{"key": map[string]interface{}{}}}, "provenance": map[string]interface{}{"integrationName": "integrationName", "dataType": "dataType", "sourceId": "sourceId", "sourceUpdateTime": "2024-01-15T09:30:00Z", "sourceDescription": "sourceDescription"}, "overrides": map[string]interface{}{"override": []interface{}{map[string]interface{}{}}}, "indicators": map[string]interface{}{"simulated": true, "exercise": true, "emergency": true, "c2": true, "egressable": true, "starred": true}, "targetPriority": map[string]interface{}{"highValueTarget": map[string]interface{}{"isHighValueTarget": true, "targetPriority": 1, "targetMatches": []interface{}{map[string]interface{}{}}, "isHighPayoffTarget": true}, "threat": map[string]interface{}{"isThreat": true}}, "signal": map[string]interface{}{"bandwidthHz": 1.1, "signalToNoiseRatio": 1.1, "emitterNotations": []interface{}{map[string]interface{}{}}, "pulseWidthS": 1.1, "scanCharacteristics": map[string]interface{}{"scanType": "SCAN_TYPE_INVALID", "scanPeriodS": 1.1}}, "transponderCodes": map[string]interface{}{"mode1": 1, "mode2": 1, "mode3": 1, "mode4InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": map[string]interface{}{"mode5InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": 1, "mode5PlatformId": 1}, "modeS": map[string]interface{}{"id": "id", "address": 1}}, "dataClassification": map[string]interface{}{"default": map[string]interface{}{"level": "CLASSIFICATION_LEVELS_INVALID", "caveats": []interface{}{"caveats"}}, "fields": []interface{}{map[string]interface{}{}}}, "taskCatalog": map[string]interface{}{"taskDefinitions": []interface{}{map[string]interface{}{}}}, "media": map[string]interface{}{"media": []interface{}{map[string]interface{}{}}}, "relationships": map[string]interface{}{"relationships": []interface{}{map[string]interface{}{}}}, "visualDetails": map[string]interface{}{"rangeRings": map[string]interface{}{"minDistanceM": 1.1, "maxDistanceM": 1.1, "ringCount": 1}}, "dimensions": map[string]interface{}{"lengthM": 1.1}, "routeDetails": map[string]interface{}{"destinationName": "destinationName", "estimatedArrivalTime": "2024-01-15T09:30:00Z"}, "schedules": map[string]interface{}{"schedules": []interface{}{map[string]interface{}{}}}, "health": map[string]interface{}{"connectionStatus": "CONNECTION_STATUS_INVALID", "healthStatus": "HEALTH_STATUS_INVALID", "components": []interface{}{map[string]interface{}{}}, "updateTime": "2024-01-15T09:30:00Z", "activeAlerts": []interface{}{map[string]interface{}{}}}, "groupDetails": map[string]interface{}{"echelon": map[string]interface{}{"armyEchelon": "ARMY_ECHELON_INVALID"}}, "supplies": map[string]interface{}{"fuel": []interface{}{map[string]interface{}{}}}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.Entity{} + _, invocationErr := client.Entities.PublishEntity( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestEntitiesGetEntityWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Get(gowiremock.URLPathTemplate("/api/v1/entities/{entityId}")).WithPathParam( + "entityId", + gowiremock.Matching("entityId"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"entityId": "entityId", "description": "description", "isLive": true, "createdTime": "2024-01-15T09:30:00Z", "expiryTime": "2024-01-15T09:30:00Z", "noExpiry": true, "status": map[string]interface{}{"code": 1, "message": "message", "details": []interface{}{map[string]interface{}{}}}, "location": map[string]interface{}{"position": map[string]interface{}{"latitudeDegrees": 1.1, "longitudeDegrees": 1.1, "altitudeHaeMeters": 1.1, "altitudeAglMeters": 1.1, "altitudeAsfMeters": 1.1, "pressureDepthMeters": 1.1}, "velocityEnu": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "speedMps": 1.1, "acceleration": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "attitudeEnu": map[string]interface{}{"x": 1.1, "y": 1.1, "z": 1.1, "w": 1.1}}, "locationUncertainty": map[string]interface{}{"positionEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "velocityEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "positionErrorEllipse": map[string]interface{}{"probability": 1.1, "semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1}}, "geoShape": map[string]interface{}{"line": map[string]interface{}{"positions": []interface{}{map[string]interface{}{}}}, "polygon": map[string]interface{}{"rings": []interface{}{map[string]interface{}{}}, "isRectangle": true}, "ellipse": map[string]interface{}{"semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1, "heightM": 1.1}, "ellipsoid": map[string]interface{}{"forwardAxisM": 1.1, "sideAxisM": 1.1, "upAxisM": 1.1}}, "geoDetails": map[string]interface{}{"type": "GEO_TYPE_INVALID", "controlArea": map[string]interface{}{"type": "CONTROL_AREA_TYPE_INVALID"}, "acm": map[string]interface{}{"acmType": "ACM_DETAIL_TYPE_INVALID", "acmDescription": "acmDescription"}}, "aliases": map[string]interface{}{"alternateIds": []interface{}{map[string]interface{}{}}, "name": "name"}, "tracked": map[string]interface{}{"trackQualityWrapper": 1, "sensorHits": 1, "numberOfObjects": map[string]interface{}{"lowerBound": 1, "upperBound": 1}, "radarCrossSection": 1.1, "lastMeasurementTime": "2024-01-15T09:30:00Z"}, "correlation": map[string]interface{}{"primary": map[string]interface{}{"secondaryEntityIds": []interface{}{"secondaryEntityIds"}}, "secondary": map[string]interface{}{"primaryEntityId": "primaryEntityId"}, "membership": map[string]interface{}{"correlationSetId": "correlationSetId"}, "decorrelation": map[string]interface{}{"decorrelatedEntities": []interface{}{map[string]interface{}{}}}}, "milView": map[string]interface{}{"disposition": "DISPOSITION_UNKNOWN", "environment": "ENVIRONMENT_UNKNOWN", "nationality": "NATIONALITY_INVALID"}, "ontology": map[string]interface{}{"platformType": "platformType", "specificType": "specificType", "template": "TEMPLATE_INVALID"}, "sensors": map[string]interface{}{"sensors": []interface{}{map[string]interface{}{}}}, "payloads": map[string]interface{}{"payloadConfigurations": []interface{}{map[string]interface{}{}}}, "powerState": map[string]interface{}{"sourceIdToState": map[string]interface{}{"key": map[string]interface{}{}}}, "provenance": map[string]interface{}{"integrationName": "integrationName", "dataType": "dataType", "sourceId": "sourceId", "sourceUpdateTime": "2024-01-15T09:30:00Z", "sourceDescription": "sourceDescription"}, "overrides": map[string]interface{}{"override": []interface{}{map[string]interface{}{}}}, "indicators": map[string]interface{}{"simulated": true, "exercise": true, "emergency": true, "c2": true, "egressable": true, "starred": true}, "targetPriority": map[string]interface{}{"highValueTarget": map[string]interface{}{"isHighValueTarget": true, "targetPriority": 1, "targetMatches": []interface{}{map[string]interface{}{}}, "isHighPayoffTarget": true}, "threat": map[string]interface{}{"isThreat": true}}, "signal": map[string]interface{}{"bandwidthHz": 1.1, "signalToNoiseRatio": 1.1, "emitterNotations": []interface{}{map[string]interface{}{}}, "pulseWidthS": 1.1, "scanCharacteristics": map[string]interface{}{"scanType": "SCAN_TYPE_INVALID", "scanPeriodS": 1.1}}, "transponderCodes": map[string]interface{}{"mode1": 1, "mode2": 1, "mode3": 1, "mode4InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": map[string]interface{}{"mode5InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": 1, "mode5PlatformId": 1}, "modeS": map[string]interface{}{"id": "id", "address": 1}}, "dataClassification": map[string]interface{}{"default": map[string]interface{}{"level": "CLASSIFICATION_LEVELS_INVALID", "caveats": []interface{}{"caveats"}}, "fields": []interface{}{map[string]interface{}{}}}, "taskCatalog": map[string]interface{}{"taskDefinitions": []interface{}{map[string]interface{}{}}}, "media": map[string]interface{}{"media": []interface{}{map[string]interface{}{}}}, "relationships": map[string]interface{}{"relationships": []interface{}{map[string]interface{}{}}}, "visualDetails": map[string]interface{}{"rangeRings": map[string]interface{}{"minDistanceM": 1.1, "maxDistanceM": 1.1, "ringCount": 1}}, "dimensions": map[string]interface{}{"lengthM": 1.1}, "routeDetails": map[string]interface{}{"destinationName": "destinationName", "estimatedArrivalTime": "2024-01-15T09:30:00Z"}, "schedules": map[string]interface{}{"schedules": []interface{}{map[string]interface{}{}}}, "health": map[string]interface{}{"connectionStatus": "CONNECTION_STATUS_INVALID", "healthStatus": "HEALTH_STATUS_INVALID", "components": []interface{}{map[string]interface{}{}}, "updateTime": "2024-01-15T09:30:00Z", "activeAlerts": []interface{}{map[string]interface{}{}}}, "groupDetails": map[string]interface{}{"echelon": map[string]interface{}{"armyEchelon": "ARMY_ECHELON_INVALID"}}, "supplies": map[string]interface{}{"fuel": []interface{}{map[string]interface{}{}}}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + _, invocationErr := client.Entities.GetEntity( + context.TODO(), + "entityId", + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestEntitiesOverrideEntityWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Put(gowiremock.URLPathTemplate("/api/v1/entities/{entityId}/override/{fieldPath}")).WithPathParam( + "entityId", + gowiremock.Matching("entityId"), + ).WithPathParam( + "fieldPath", + gowiremock.Matching("mil_view.disposition"), + ).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"entityId": "entityId", "description": "description", "isLive": true, "createdTime": "2024-01-15T09:30:00Z", "expiryTime": "2024-01-15T09:30:00Z", "noExpiry": true, "status": map[string]interface{}{"code": 1, "message": "message", "details": []interface{}{map[string]interface{}{}}}, "location": map[string]interface{}{"position": map[string]interface{}{"latitudeDegrees": 1.1, "longitudeDegrees": 1.1, "altitudeHaeMeters": 1.1, "altitudeAglMeters": 1.1, "altitudeAsfMeters": 1.1, "pressureDepthMeters": 1.1}, "velocityEnu": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "speedMps": 1.1, "acceleration": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "attitudeEnu": map[string]interface{}{"x": 1.1, "y": 1.1, "z": 1.1, "w": 1.1}}, "locationUncertainty": map[string]interface{}{"positionEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "velocityEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "positionErrorEllipse": map[string]interface{}{"probability": 1.1, "semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1}}, "geoShape": map[string]interface{}{"line": map[string]interface{}{"positions": []interface{}{map[string]interface{}{}}}, "polygon": map[string]interface{}{"rings": []interface{}{map[string]interface{}{}}, "isRectangle": true}, "ellipse": map[string]interface{}{"semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1, "heightM": 1.1}, "ellipsoid": map[string]interface{}{"forwardAxisM": 1.1, "sideAxisM": 1.1, "upAxisM": 1.1}}, "geoDetails": map[string]interface{}{"type": "GEO_TYPE_INVALID", "controlArea": map[string]interface{}{"type": "CONTROL_AREA_TYPE_INVALID"}, "acm": map[string]interface{}{"acmType": "ACM_DETAIL_TYPE_INVALID", "acmDescription": "acmDescription"}}, "aliases": map[string]interface{}{"alternateIds": []interface{}{map[string]interface{}{}}, "name": "name"}, "tracked": map[string]interface{}{"trackQualityWrapper": 1, "sensorHits": 1, "numberOfObjects": map[string]interface{}{"lowerBound": 1, "upperBound": 1}, "radarCrossSection": 1.1, "lastMeasurementTime": "2024-01-15T09:30:00Z"}, "correlation": map[string]interface{}{"primary": map[string]interface{}{"secondaryEntityIds": []interface{}{"secondaryEntityIds"}}, "secondary": map[string]interface{}{"primaryEntityId": "primaryEntityId"}, "membership": map[string]interface{}{"correlationSetId": "correlationSetId"}, "decorrelation": map[string]interface{}{"decorrelatedEntities": []interface{}{map[string]interface{}{}}}}, "milView": map[string]interface{}{"disposition": "DISPOSITION_UNKNOWN", "environment": "ENVIRONMENT_UNKNOWN", "nationality": "NATIONALITY_INVALID"}, "ontology": map[string]interface{}{"platformType": "platformType", "specificType": "specificType", "template": "TEMPLATE_INVALID"}, "sensors": map[string]interface{}{"sensors": []interface{}{map[string]interface{}{}}}, "payloads": map[string]interface{}{"payloadConfigurations": []interface{}{map[string]interface{}{}}}, "powerState": map[string]interface{}{"sourceIdToState": map[string]interface{}{"key": map[string]interface{}{}}}, "provenance": map[string]interface{}{"integrationName": "integrationName", "dataType": "dataType", "sourceId": "sourceId", "sourceUpdateTime": "2024-01-15T09:30:00Z", "sourceDescription": "sourceDescription"}, "overrides": map[string]interface{}{"override": []interface{}{map[string]interface{}{}}}, "indicators": map[string]interface{}{"simulated": true, "exercise": true, "emergency": true, "c2": true, "egressable": true, "starred": true}, "targetPriority": map[string]interface{}{"highValueTarget": map[string]interface{}{"isHighValueTarget": true, "targetPriority": 1, "targetMatches": []interface{}{map[string]interface{}{}}, "isHighPayoffTarget": true}, "threat": map[string]interface{}{"isThreat": true}}, "signal": map[string]interface{}{"bandwidthHz": 1.1, "signalToNoiseRatio": 1.1, "emitterNotations": []interface{}{map[string]interface{}{}}, "pulseWidthS": 1.1, "scanCharacteristics": map[string]interface{}{"scanType": "SCAN_TYPE_INVALID", "scanPeriodS": 1.1}}, "transponderCodes": map[string]interface{}{"mode1": 1, "mode2": 1, "mode3": 1, "mode4InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": map[string]interface{}{"mode5InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": 1, "mode5PlatformId": 1}, "modeS": map[string]interface{}{"id": "id", "address": 1}}, "dataClassification": map[string]interface{}{"default": map[string]interface{}{"level": "CLASSIFICATION_LEVELS_INVALID", "caveats": []interface{}{"caveats"}}, "fields": []interface{}{map[string]interface{}{}}}, "taskCatalog": map[string]interface{}{"taskDefinitions": []interface{}{map[string]interface{}{}}}, "media": map[string]interface{}{"media": []interface{}{map[string]interface{}{}}}, "relationships": map[string]interface{}{"relationships": []interface{}{map[string]interface{}{}}}, "visualDetails": map[string]interface{}{"rangeRings": map[string]interface{}{"minDistanceM": 1.1, "maxDistanceM": 1.1, "ringCount": 1}}, "dimensions": map[string]interface{}{"lengthM": 1.1}, "routeDetails": map[string]interface{}{"destinationName": "destinationName", "estimatedArrivalTime": "2024-01-15T09:30:00Z"}, "schedules": map[string]interface{}{"schedules": []interface{}{map[string]interface{}{}}}, "health": map[string]interface{}{"connectionStatus": "CONNECTION_STATUS_INVALID", "healthStatus": "HEALTH_STATUS_INVALID", "components": []interface{}{map[string]interface{}{}}, "updateTime": "2024-01-15T09:30:00Z", "activeAlerts": []interface{}{map[string]interface{}{}}}, "groupDetails": map[string]interface{}{"echelon": map[string]interface{}{"armyEchelon": "ARMY_ECHELON_INVALID"}}, "supplies": map[string]interface{}{"fuel": []interface{}{map[string]interface{}{}}}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.EntityOverride{} + _, invocationErr := client.Entities.OverrideEntity( + context.TODO(), + "entityId", + "mil_view.disposition", + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestEntitiesRemoveEntityOverrideWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Delete(gowiremock.URLPathTemplate("/api/v1/entities/{entityId}/override/{fieldPath}")).WithPathParam( + "entityId", + gowiremock.Matching("entityId"), + ).WithPathParam( + "fieldPath", + gowiremock.Matching("mil_view.disposition"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"entityId": "entityId", "description": "description", "isLive": true, "createdTime": "2024-01-15T09:30:00Z", "expiryTime": "2024-01-15T09:30:00Z", "noExpiry": true, "status": map[string]interface{}{"code": 1, "message": "message", "details": []interface{}{map[string]interface{}{}}}, "location": map[string]interface{}{"position": map[string]interface{}{"latitudeDegrees": 1.1, "longitudeDegrees": 1.1, "altitudeHaeMeters": 1.1, "altitudeAglMeters": 1.1, "altitudeAsfMeters": 1.1, "pressureDepthMeters": 1.1}, "velocityEnu": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "speedMps": 1.1, "acceleration": map[string]interface{}{"e": 1.1, "n": 1.1, "u": 1.1}, "attitudeEnu": map[string]interface{}{"x": 1.1, "y": 1.1, "z": 1.1, "w": 1.1}}, "locationUncertainty": map[string]interface{}{"positionEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "velocityEnuCov": map[string]interface{}{"mxx": 1.1, "mxy": 1.1, "mxz": 1.1, "myy": 1.1, "myz": 1.1, "mzz": 1.1}, "positionErrorEllipse": map[string]interface{}{"probability": 1.1, "semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1}}, "geoShape": map[string]interface{}{"line": map[string]interface{}{"positions": []interface{}{map[string]interface{}{}}}, "polygon": map[string]interface{}{"rings": []interface{}{map[string]interface{}{}}, "isRectangle": true}, "ellipse": map[string]interface{}{"semiMajorAxisM": 1.1, "semiMinorAxisM": 1.1, "orientationD": 1.1, "heightM": 1.1}, "ellipsoid": map[string]interface{}{"forwardAxisM": 1.1, "sideAxisM": 1.1, "upAxisM": 1.1}}, "geoDetails": map[string]interface{}{"type": "GEO_TYPE_INVALID", "controlArea": map[string]interface{}{"type": "CONTROL_AREA_TYPE_INVALID"}, "acm": map[string]interface{}{"acmType": "ACM_DETAIL_TYPE_INVALID", "acmDescription": "acmDescription"}}, "aliases": map[string]interface{}{"alternateIds": []interface{}{map[string]interface{}{}}, "name": "name"}, "tracked": map[string]interface{}{"trackQualityWrapper": 1, "sensorHits": 1, "numberOfObjects": map[string]interface{}{"lowerBound": 1, "upperBound": 1}, "radarCrossSection": 1.1, "lastMeasurementTime": "2024-01-15T09:30:00Z"}, "correlation": map[string]interface{}{"primary": map[string]interface{}{"secondaryEntityIds": []interface{}{"secondaryEntityIds"}}, "secondary": map[string]interface{}{"primaryEntityId": "primaryEntityId"}, "membership": map[string]interface{}{"correlationSetId": "correlationSetId"}, "decorrelation": map[string]interface{}{"decorrelatedEntities": []interface{}{map[string]interface{}{}}}}, "milView": map[string]interface{}{"disposition": "DISPOSITION_UNKNOWN", "environment": "ENVIRONMENT_UNKNOWN", "nationality": "NATIONALITY_INVALID"}, "ontology": map[string]interface{}{"platformType": "platformType", "specificType": "specificType", "template": "TEMPLATE_INVALID"}, "sensors": map[string]interface{}{"sensors": []interface{}{map[string]interface{}{}}}, "payloads": map[string]interface{}{"payloadConfigurations": []interface{}{map[string]interface{}{}}}, "powerState": map[string]interface{}{"sourceIdToState": map[string]interface{}{"key": map[string]interface{}{}}}, "provenance": map[string]interface{}{"integrationName": "integrationName", "dataType": "dataType", "sourceId": "sourceId", "sourceUpdateTime": "2024-01-15T09:30:00Z", "sourceDescription": "sourceDescription"}, "overrides": map[string]interface{}{"override": []interface{}{map[string]interface{}{}}}, "indicators": map[string]interface{}{"simulated": true, "exercise": true, "emergency": true, "c2": true, "egressable": true, "starred": true}, "targetPriority": map[string]interface{}{"highValueTarget": map[string]interface{}{"isHighValueTarget": true, "targetPriority": 1, "targetMatches": []interface{}{map[string]interface{}{}}, "isHighPayoffTarget": true}, "threat": map[string]interface{}{"isThreat": true}}, "signal": map[string]interface{}{"bandwidthHz": 1.1, "signalToNoiseRatio": 1.1, "emitterNotations": []interface{}{map[string]interface{}{}}, "pulseWidthS": 1.1, "scanCharacteristics": map[string]interface{}{"scanType": "SCAN_TYPE_INVALID", "scanPeriodS": 1.1}}, "transponderCodes": map[string]interface{}{"mode1": 1, "mode2": 1, "mode3": 1, "mode4InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": map[string]interface{}{"mode5InterrogationResponse": "INTERROGATION_RESPONSE_INVALID", "mode5": 1, "mode5PlatformId": 1}, "modeS": map[string]interface{}{"id": "id", "address": 1}}, "dataClassification": map[string]interface{}{"default": map[string]interface{}{"level": "CLASSIFICATION_LEVELS_INVALID", "caveats": []interface{}{"caveats"}}, "fields": []interface{}{map[string]interface{}{}}}, "taskCatalog": map[string]interface{}{"taskDefinitions": []interface{}{map[string]interface{}{}}}, "media": map[string]interface{}{"media": []interface{}{map[string]interface{}{}}}, "relationships": map[string]interface{}{"relationships": []interface{}{map[string]interface{}{}}}, "visualDetails": map[string]interface{}{"rangeRings": map[string]interface{}{"minDistanceM": 1.1, "maxDistanceM": 1.1, "ringCount": 1}}, "dimensions": map[string]interface{}{"lengthM": 1.1}, "routeDetails": map[string]interface{}{"destinationName": "destinationName", "estimatedArrivalTime": "2024-01-15T09:30:00Z"}, "schedules": map[string]interface{}{"schedules": []interface{}{map[string]interface{}{}}}, "health": map[string]interface{}{"connectionStatus": "CONNECTION_STATUS_INVALID", "healthStatus": "HEALTH_STATUS_INVALID", "components": []interface{}{map[string]interface{}{}}, "updateTime": "2024-01-15T09:30:00Z", "activeAlerts": []interface{}{map[string]interface{}{}}}, "groupDetails": map[string]interface{}{"echelon": map[string]interface{}{"armyEchelon": "ARMY_ECHELON_INVALID"}}, "supplies": map[string]interface{}{"fuel": []interface{}{map[string]interface{}{}}}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + _, invocationErr := client.Entities.RemoveEntityOverride( + context.TODO(), + "entityId", + "mil_view.disposition", + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestEntitiesLongPollEntityEventsWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Post(gowiremock.URLPathTemplate("/api/v1/entities/events")).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": ["sessionToken"], + "properties": { + "sessionToken": {"type": "string"} + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"sessionToken": "sessionToken", "entityEvents": []interface{}{map[string]interface{}{"eventType": "EVENT_TYPE_INVALID", "time": "2024-01-15T09:30:00Z"}}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.EntityEventRequest{ + SessionToken: "sessionToken", + } + _, invocationErr := client.Entities.LongPollEntityEvents( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestEntitiesStreamEntitiesWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Post(gowiremock.URLPathTemplate("/api/v1/entities/stream")).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.EntityStreamRequest{} + _, invocationErr := client.Entities.StreamEntities( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} diff --git a/entities/raw_client.go b/entities/raw_client.go index e409d2c..4f3219a 100644 --- a/entities/raw_client.go +++ b/entities/raw_client.go @@ -4,7 +4,7 @@ package entities import ( context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" @@ -14,11 +14,12 @@ import ( type RawClient struct { baseURL string caller *internal.Caller - header http.Header + options *core.RequestOptions } func NewRawClient(options *core.RequestOptions) *RawClient { return &RawClient{ + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -26,15 +27,14 @@ func NewRawClient(options *core.RequestOptions) *RawClient { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } func (r *RawClient) PublishEntity( ctx context.Context, - request *v2.Entity, + request *Lattice.Entity, opts ...option.RequestOption, -) (*core.Response[*v2.Entity], error) { +) (*core.Response[*Lattice.Entity], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -43,22 +43,10 @@ func (r *RawClient) PublishEntity( ) endpointURL := baseURL + "/api/v1/entities" headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - } - var response *v2.Entity + var response *Lattice.Entity raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -71,13 +59,13 @@ func (r *RawClient) PublishEntity( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Entity]{ + return &core.Response[*Lattice.Entity]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -89,7 +77,7 @@ func (r *RawClient) GetEntity( // ID of the entity to return entityID string, opts ...option.RequestOption, -) (*core.Response[*v2.Entity], error) { +) (*core.Response[*Lattice.Entity], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -101,27 +89,10 @@ func (r *RawClient) GetEntity( entityID, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.Entity + var response *Lattice.Entity raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -133,13 +104,13 @@ func (r *RawClient) GetEntity( QueryParameters: options.QueryParameters, Client: options.HTTPClient, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Entity]{ + return &core.Response[*Lattice.Entity]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -152,9 +123,9 @@ func (r *RawClient) OverrideEntity( entityID string, // fieldPath to override fieldPath string, - request *v2.EntityOverride, + request *Lattice.EntityOverride, opts ...option.RequestOption, -) (*core.Response[*v2.Entity], error) { +) (*core.Response[*Lattice.Entity], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -167,28 +138,11 @@ func (r *RawClient) OverrideEntity( fieldPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.Entity + var response *Lattice.Entity raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -201,13 +155,13 @@ func (r *RawClient) OverrideEntity( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Entity]{ + return &core.Response[*Lattice.Entity]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -221,7 +175,7 @@ func (r *RawClient) RemoveEntityOverride( // The fieldPath to clear overrides from. fieldPath string, opts ...option.RequestOption, -) (*core.Response[*v2.Entity], error) { +) (*core.Response[*Lattice.Entity], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -234,27 +188,10 @@ func (r *RawClient) RemoveEntityOverride( fieldPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.Entity + var response *Lattice.Entity raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -266,13 +203,13 @@ func (r *RawClient) RemoveEntityOverride( QueryParameters: options.QueryParameters, Client: options.HTTPClient, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Entity]{ + return &core.Response[*Lattice.Entity]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -281,9 +218,9 @@ func (r *RawClient) RemoveEntityOverride( func (r *RawClient) LongPollEntityEvents( ctx context.Context, - request *v2.EntityEventRequest, + request *Lattice.EntityEventRequest, opts ...option.RequestOption, -) (*core.Response[*v2.EntityEventResponse], error) { +) (*core.Response[*Lattice.EntityEventResponse], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -292,38 +229,11 @@ func (r *RawClient) LongPollEntityEvents( ) endpointURL := baseURL + "/api/v1/entities/events" headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - 408: func(apiError *core.APIError) error { - return &v2.RequestTimeoutError{ - APIError: apiError, - } - }, - 429: func(apiError *core.APIError) error { - return &v2.TooManyRequestsError{ - APIError: apiError, - } - }, - } - var response *v2.EntityEventResponse + var response *Lattice.EntityEventResponse raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -336,13 +246,13 @@ func (r *RawClient) LongPollEntityEvents( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.EntityEventResponse]{ + return &core.Response[*Lattice.EntityEventResponse]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, diff --git a/entity/types.go b/entity/types.go index b117632..df75721 100644 --- a/entity/types.go +++ b/entity/types.go @@ -6,12 +6,21 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" +) + +var ( + errorFieldErrorCode = big.NewInt(1 << 0) + errorFieldMessage = big.NewInt(1 << 1) ) type Error struct { ErrorCode string `json:"errorCode" url:"errorCode"` Message string `json:"message" url:"message"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -34,6 +43,27 @@ func (e *Error) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *Error) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetErrorCode sets the ErrorCode field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetErrorCode(errorCode string) { + e.ErrorCode = errorCode + e.require(errorFieldErrorCode) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetMessage(message string) { + e.Message = message + e.require(errorFieldMessage) +} + func (e *Error) UnmarshalJSON(data []byte) error { type unmarshaler Error var value unmarshaler @@ -50,6 +80,17 @@ func (e *Error) UnmarshalJSON(data []byte) error { return nil } +func (e *Error) MarshalJSON() ([]byte, error) { + type embed Error + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *Error) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { diff --git a/error_codes.go b/error_codes.go new file mode 100644 index 0000000..8f9822d --- /dev/null +++ b/error_codes.go @@ -0,0 +1,51 @@ +// Code generated by Fern. DO NOT EDIT. + +package Lattice + +import ( + core "github.com/anduril/lattice-sdk-go/v2/core" + internal "github.com/anduril/lattice-sdk-go/v2/internal" +) + +var ErrorCodes internal.ErrorCodes = internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &BadRequestError{ + APIError: apiError, + } + }, + 401: func(apiError *core.APIError) error { + return &UnauthorizedError{ + APIError: apiError, + } + }, + 404: func(apiError *core.APIError) error { + return &NotFoundError{ + APIError: apiError, + } + }, + 408: func(apiError *core.APIError) error { + return &RequestTimeoutError{ + APIError: apiError, + } + }, + 429: func(apiError *core.APIError) error { + return &TooManyRequestsError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &InternalServerError{ + APIError: apiError, + } + }, + 413: func(apiError *core.APIError) error { + return &ContentTooLargeError{ + APIError: apiError, + } + }, + 507: func(apiError *core.APIError) error { + return &InsufficientStorageError{ + APIError: apiError, + } + }, +} diff --git a/go.mod b/go.mod index d38bd9d..d7b429c 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,69 @@ module github.com/anduril/lattice-sdk-go/v2 -go 1.18 +go 1.21 -require ( - github.com/google/uuid v1.4.0 - github.com/stretchr/testify v1.7.0 -) +toolchain go1.23.8 + +require github.com/google/uuid v1.6.0 + +require github.com/stretchr/testify v1.9.0 + +require gopkg.in/yaml.v3 v3.0.1 // indirect + +require github.com/wiremock/wiremock-testcontainers-go v1.0.0-alpha-9 + +require github.com/wiremock/go-wiremock v1.14.0 require ( - github.com/davecgh/go-spew v1.1.0 // indirect + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/containerd/containerd v1.7.15 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/distribution/reference v0.5.0 // indirect + github.com/docker/docker v25.0.5+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/klauspost/compress v1.16.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/sys/user v0.1.0 // indirect + github.com/moby/term v0.5.0 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/shirou/gopsutil/v3 v3.23.12 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/testcontainers/testcontainers-go v0.31.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/tools v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.58.3 // indirect + google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/go.sum b/go.sum index b3766d4..8d98857 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,201 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= +github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/containerd/containerd v1.7.15 h1:afEHXdil9iAm03BmhjzKyXnnEBtjaLJefdU7DV0IFes= +github.com/containerd/containerd v1.7.15/go.mod h1:ISzRRTMF8EXNpJlTzyr2XMhN+j9K302C21/+cr3kUnY= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= +github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= +github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= +github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= +github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= +github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U= +github.com/testcontainers/testcontainers-go v0.31.0/go.mod h1:D2lAoA0zUFiSY+eAflqK5mcUx/A5hrrORaEQrd0SefI= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/wiremock/go-wiremock v1.14.0 h1:cVAV98Odg+hySEYKDRUasVo30q7JE/ysrdx5qOmF4f4= +github.com/wiremock/go-wiremock v1.14.0/go.mod h1:T5XkKnsKS2asycbUrk2cpxXTEXwa6klHfCWVN8BkhkU= +github.com/wiremock/wiremock-testcontainers-go v1.0.0-alpha-9 h1:LUa3up/6uLDRo6U++9VtLHfsJKQjwqHyHmdXuT3cqdU= +github.com/wiremock/wiremock-testcontainers-go v1.0.0-alpha-9/go.mod h1:nWMqyEkwfGVBm8gOpQ41RhUWUqSfsFhlIrxMtO9NziU= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= +go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= diff --git a/internal/caller_test.go b/internal/caller_test.go index f572411..c83cad2 100644 --- a/internal/caller_test.go +++ b/internal/caller_test.go @@ -18,8 +18,8 @@ import ( "github.com/stretchr/testify/require" ) -// TestCase represents a single test case. -type TestCase struct { +// InternalTestCase represents a single test case. +type InternalTestCase struct { description string // Server-side assertions. @@ -28,47 +28,47 @@ type TestCase struct { giveResponseIsOptional bool giveHeader http.Header giveErrorDecoder ErrorDecoder - giveRequest *Request + giveRequest *InternalTestRequest giveQueryParams url.Values giveBodyProperties map[string]interface{} // Client-side assertions. - wantResponse *Response + wantResponse *InternalTestResponse wantHeaders http.Header wantError error } -// Request a simple request body. -type Request struct { +// InternalTestRequest a simple request body. +type InternalTestRequest struct { Id string `json:"id"` } -// Response a simple response body. -type Response struct { +// InternalTestResponse a simple response body. +type InternalTestResponse struct { Id string `json:"id"` ExtraBodyProperties map[string]interface{} `json:"extraBodyProperties,omitempty"` QueryParameters url.Values `json:"queryParameters,omitempty"` } -// NotFoundError represents a 404. -type NotFoundError struct { +// InternalTestNotFoundError represents a 404. +type InternalTestNotFoundError struct { *core.APIError Message string `json:"message"` } func TestCall(t *testing.T) { - tests := []*TestCase{ + tests := []*InternalTestCase{ { description: "GET success", giveMethod: http.MethodGet, giveHeader: http.Header{ "X-API-Status": []string{"success"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: "123", }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ Id: "123", }, }, @@ -79,10 +79,10 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"success"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: "123", }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ Id: "123", QueryParameters: url.Values{ "limit": []string{"1"}, @@ -95,11 +95,11 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"fail"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: strconv.Itoa(http.StatusNotFound), }, giveErrorDecoder: newTestErrorDecoder(t), - wantError: &NotFoundError{ + wantError: &InternalTestNotFoundError{ APIError: core.NewAPIError( http.StatusNotFound, http.Header{}, @@ -126,7 +126,7 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"success"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: "123", }, giveResponseIsOptional: true, @@ -137,7 +137,7 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"fail"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: strconv.Itoa(http.StatusInternalServerError), }, wantError: core.NewAPIError( @@ -152,11 +152,11 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"success"}, }, - giveRequest: new(Request), + giveRequest: new(InternalTestRequest), giveBodyProperties: map[string]interface{}{ "key": "value", }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ ExtraBodyProperties: map[string]interface{}{ "key": "value", }, @@ -171,10 +171,10 @@ func TestCall(t *testing.T) { giveQueryParams: url.Values{ "extra": []string{"true"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: "123", }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ Id: "123", QueryParameters: url.Values{ "extra": []string{"true"}, @@ -188,13 +188,13 @@ func TestCall(t *testing.T) { giveHeader: http.Header{ "X-API-Status": []string{"success"}, }, - giveRequest: &Request{ + giveRequest: &InternalTestRequest{ Id: "123", }, giveQueryParams: url.Values{ "extra": []string{"true"}, }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ Id: "123", QueryParameters: url.Values{ "limit": []string{"1"}, @@ -214,7 +214,7 @@ func TestCall(t *testing.T) { Client: client, }, ) - var response *Response + var response *InternalTestResponse _, err := caller.Call( context.Background(), &CallParams{ @@ -303,7 +303,7 @@ func TestMergeHeaders(t *testing.T) { // newTestServer returns a new *httptest.Server configured with the // given test parameters. -func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { +func newTestServer(t *testing.T, tc *InternalTestCase) *httptest.Server { return httptest.NewServer( http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { @@ -313,7 +313,7 @@ func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { assert.Equal(t, value, r.Header.Values(header)) } - request := new(Request) + request := new(InternalTestRequest) bytes, err := io.ReadAll(r.Body) if tc.giveRequest == nil { @@ -328,7 +328,7 @@ func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { switch request.Id { case strconv.Itoa(http.StatusNotFound): - notFoundError := &NotFoundError{ + notFoundError := &InternalTestNotFoundError{ APIError: &core.APIError{ StatusCode: http.StatusNotFound, }, @@ -358,7 +358,7 @@ func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { require.NoError(t, json.Unmarshal(bytes, &extraBodyProperties)) delete(extraBodyProperties, "id") - response := &Response{ + response := &InternalTestResponse{ Id: request.Id, ExtraBodyProperties: extraBodyProperties, QueryParameters: r.URL.Query(), @@ -384,7 +384,7 @@ func newTestErrorDecoder(t *testing.T) func(int, http.Header, io.Reader) error { decoder = json.NewDecoder(bytes.NewReader(raw)) ) if statusCode == http.StatusNotFound { - value := new(NotFoundError) + value := new(InternalTestNotFoundError) value.APIError = apiError require.NoError(t, decoder.Decode(value)) diff --git a/internal/error_decoder.go b/internal/error_decoder.go index 85c735b..9457721 100644 --- a/internal/error_decoder.go +++ b/internal/error_decoder.go @@ -11,15 +11,32 @@ import ( "github.com/anduril/lattice-sdk-go/v2/core" ) +// ErrorCodes maps HTTP status codes to error constructors. +type ErrorCodes map[int]func(*core.APIError) error + // ErrorDecoder decodes *http.Response errors and returns a // typed API error (e.g. *core.APIError). type ErrorDecoder func(statusCode int, header http.Header, body io.Reader) error -// ErrorCodes maps HTTP status codes to error constructors. -type ErrorCodes map[int]func(*core.APIError) error - // NewErrorDecoder returns a new ErrorDecoder backed by the given error codes. -func NewErrorDecoder(errorCodes ErrorCodes) ErrorDecoder { +// errorCodesOverrides is optional and will be merged with the default error codes, +// with overrides taking precedence. +func NewErrorDecoder(errorCodes ErrorCodes, errorCodesOverrides ...ErrorCodes) ErrorDecoder { + // Merge default error codes with overrides + mergedErrorCodes := make(ErrorCodes) + + // Start with default error codes + for statusCode, errorFunc := range errorCodes { + mergedErrorCodes[statusCode] = errorFunc + } + + // Apply overrides if provided + if len(errorCodesOverrides) > 0 && errorCodesOverrides[0] != nil { + for statusCode, errorFunc := range errorCodesOverrides[0] { + mergedErrorCodes[statusCode] = errorFunc + } + } + return func(statusCode int, header http.Header, body io.Reader) error { raw, err := io.ReadAll(body) if err != nil { @@ -30,7 +47,7 @@ func NewErrorDecoder(errorCodes ErrorCodes) ErrorDecoder { header, errors.New(string(raw)), ) - newErrorFunc, ok := errorCodes[statusCode] + newErrorFunc, ok := mergedErrorCodes[statusCode] if !ok { // This status code isn't recognized, so we return // the API error as-is. diff --git a/internal/error_decoder_test.go b/internal/error_decoder_test.go index 1a5ce02..6e928da 100644 --- a/internal/error_decoder_test.go +++ b/internal/error_decoder_test.go @@ -14,7 +14,7 @@ func TestErrorDecoder(t *testing.T) { decoder := NewErrorDecoder( ErrorCodes{ http.StatusNotFound: func(apiError *core.APIError) error { - return &NotFoundError{APIError: apiError} + return &InternalTestNotFoundError{APIError: apiError} }, }) @@ -37,7 +37,7 @@ func TestErrorDecoder(t *testing.T) { giveStatusCode: http.StatusNotFound, giveHeader: http.Header{}, giveBody: `{"message": "Resource not found"}`, - wantError: &NotFoundError{ + wantError: &InternalTestNotFoundError{ APIError: core.NewAPIError(http.StatusNotFound, http.Header{}, errors.New(`{"message": "Resource not found"}`)), Message: "Resource not found", }, diff --git a/internal/explicit_fields.go b/internal/explicit_fields.go new file mode 100644 index 0000000..4bdf34f --- /dev/null +++ b/internal/explicit_fields.go @@ -0,0 +1,116 @@ +package internal + +import ( + "math/big" + "reflect" + "strings" +) + +// HandleExplicitFields processes a struct to remove `omitempty` from +// fields that have been explicitly set (as indicated by their corresponding bit in explicitFields). +// Note that `marshaler` should be an embedded struct to avoid infinite recursion. +// Returns an interface{} that can be passed to json.Marshal. +func HandleExplicitFields(marshaler interface{}, explicitFields *big.Int) interface{} { + val := reflect.ValueOf(marshaler) + typ := reflect.TypeOf(marshaler) + + // Handle pointer types + if val.Kind() == reflect.Ptr { + if val.IsNil() { + return nil + } + val = val.Elem() + typ = typ.Elem() + } + + // Only handle struct types + if val.Kind() != reflect.Struct { + return marshaler + } + + // Handle embedded struct pattern + var sourceVal reflect.Value + var sourceType reflect.Type + + // Check if this is an embedded struct pattern + if typ.NumField() == 1 && typ.Field(0).Anonymous { + // This is likely an embedded struct, get the embedded value + embeddedField := val.Field(0) + sourceVal = embeddedField + sourceType = embeddedField.Type() + } else { + // Regular struct + sourceVal = val + sourceType = typ + } + + // If no explicit fields set, use standard marshaling + if explicitFields == nil || explicitFields.Sign() == 0 { + return marshaler + } + + // Create a new struct type with modified tags + fields := make([]reflect.StructField, 0, sourceType.NumField()) + + for i := 0; i < sourceType.NumField(); i++ { + field := sourceType.Field(i) + + // Skip unexported fields and the explicitFields field itself + if !field.IsExported() || field.Name == "explicitFields" { + continue + } + + // Check if this field has been explicitly set + fieldBit := big.NewInt(1) + fieldBit.Lsh(fieldBit, uint(i)) + if big.NewInt(0).And(explicitFields, fieldBit).Sign() != 0 { + // Remove omitempty from the json tag + tag := field.Tag.Get("json") + if tag != "" && tag != "-" { + // Parse the json tag, remove omitempty from options + parts := strings.Split(tag, ",") + if len(parts) > 1 { + var newParts []string + newParts = append(newParts, parts[0]) // Keep the field name + for _, part := range parts[1:] { + if strings.TrimSpace(part) != "omitempty" { + newParts = append(newParts, part) + } + } + tag = strings.Join(newParts, ",") + } + + // Reconstruct the struct tag + newTag := `json:"` + tag + `"` + if urlTag := field.Tag.Get("url"); urlTag != "" { + newTag += ` url:"` + urlTag + `"` + } + + field.Tag = reflect.StructTag(newTag) + } + } + + fields = append(fields, field) + } + + // Create new struct type with modified tags + newType := reflect.StructOf(fields) + newVal := reflect.New(newType).Elem() + + // Copy field values from original struct to new struct + fieldIndex := 0 + for i := 0; i < sourceType.NumField(); i++ { + originalField := sourceType.Field(i) + + // Skip unexported fields and the explicitFields field itself + if !originalField.IsExported() || originalField.Name == "explicitFields" { + continue + } + + originalValue := sourceVal.Field(i) + newVal.Field(fieldIndex).Set(originalValue) + fieldIndex++ + } + + return newVal.Interface() +} diff --git a/internal/explicit_fields_test.go b/internal/explicit_fields_test.go new file mode 100644 index 0000000..9fccda7 --- /dev/null +++ b/internal/explicit_fields_test.go @@ -0,0 +1,496 @@ +package internal + +import ( + "encoding/json" + "math/big" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testExplicitFieldsStruct struct { + Name *string `json:"name,omitempty"` + Code *string `json:"code,omitempty"` + Count *int `json:"count,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Tags []string `json:"tags,omitempty"` + unexported string `json:"-"` + explicitFields *big.Int `json:"-"` +} + +var ( + testFieldName = big.NewInt(1 << 0) + testFieldCode = big.NewInt(1 << 1) + testFieldCount = big.NewInt(1 << 2) + testFieldEnabled = big.NewInt(1 << 3) + testFieldTags = big.NewInt(1 << 4) +) + +func (t *testExplicitFieldsStruct) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +func (t *testExplicitFieldsStruct) SetName(name *string) { + t.Name = name + t.require(testFieldName) +} + +func (t *testExplicitFieldsStruct) SetCode(code *string) { + t.Code = code + t.require(testFieldCode) +} + +func (t *testExplicitFieldsStruct) SetCount(count *int) { + t.Count = count + t.require(testFieldCount) +} + +func (t *testExplicitFieldsStruct) SetEnabled(enabled *bool) { + t.Enabled = enabled + t.require(testFieldEnabled) +} + +func (t *testExplicitFieldsStruct) SetTags(tags []string) { + t.Tags = tags + t.require(testFieldTags) +} + +func (t *testExplicitFieldsStruct) MarshalJSON() ([]byte, error) { + type embed testExplicitFieldsStruct + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + return json.Marshal(HandleExplicitFields(marshaler, t.explicitFields)) +} + +type testStructWithoutExplicitFields struct { + Name *string `json:"name,omitempty"` + Code *string `json:"code,omitempty"` +} + +func TestHandleExplicitFields(t *testing.T) { + tests := []struct { + desc string + giveInput interface{} + wantBytes []byte + wantError string + }{ + { + desc: "nil input", + giveInput: nil, + wantBytes: []byte(`null`), + }, + { + desc: "non-struct input", + giveInput: "string", + wantBytes: []byte(`"string"`), + }, + { + desc: "slice input", + giveInput: []string{"a", "b"}, + wantBytes: []byte(`["a","b"]`), + }, + { + desc: "map input", + giveInput: map[string]interface{}{"key": "value"}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "struct without explicitFields field", + giveInput: &testStructWithoutExplicitFields{ + Name: stringPtr("test"), + Code: nil, + }, + wantBytes: []byte(`{"name":"test"}`), + }, + { + desc: "struct with no explicit fields set", + giveInput: &testExplicitFieldsStruct{ + Name: stringPtr("test"), + Code: nil, + }, + wantBytes: []byte(`{"name":"test"}`), + }, + { + desc: "struct with explicit nil field", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{ + Name: stringPtr("test"), + } + s.SetCode(nil) + return s + }(), + wantBytes: []byte(`{"name":"test","code":null}`), + }, + { + desc: "struct with explicit non-nil field", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{} + s.SetName(stringPtr("explicit")) + s.SetCode(stringPtr("also-explicit")) + return s + }(), + wantBytes: []byte(`{"name":"explicit","code":"also-explicit"}`), + }, + { + desc: "struct with mixed explicit and implicit fields", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{ + Name: stringPtr("implicit"), + Count: intPtr(42), + } + s.SetCode(nil) // explicit nil + return s + }(), + wantBytes: []byte(`{"name":"implicit","code":null,"count":42}`), + }, + { + desc: "struct with multiple explicit nil fields", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{ + Name: stringPtr("test"), + } + s.SetCode(nil) + s.SetCount(nil) + return s + }(), + wantBytes: []byte(`{"name":"test","code":null,"count":null}`), + }, + { + desc: "struct with slice field", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{ + Tags: []string{"tag1", "tag2"}, + } + s.SetTags(nil) // explicit nil slice + return s + }(), + wantBytes: []byte(`{"tags":null}`), + }, + { + desc: "struct with boolean field", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{} + s.SetEnabled(boolPtr(false)) // explicit false + return s + }(), + wantBytes: []byte(`{"enabled":false}`), + }, + { + desc: "struct with all fields explicit", + giveInput: func() *testExplicitFieldsStruct { + s := &testExplicitFieldsStruct{} + s.SetName(stringPtr("test")) + s.SetCode(nil) + s.SetCount(intPtr(0)) + s.SetEnabled(boolPtr(false)) + s.SetTags([]string{}) + return s + }(), + wantBytes: []byte(`{"name":"test","code":null,"count":0,"enabled":false,"tags":[]}`), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + var explicitFields *big.Int + if s, ok := tt.giveInput.(*testExplicitFieldsStruct); ok { + explicitFields = s.explicitFields + } + bytes, err := json.Marshal(HandleExplicitFields(tt.giveInput, explicitFields)) + if tt.wantError != "" { + require.EqualError(t, err, tt.wantError) + assert.Nil(t, tt.wantBytes) + return + } + require.NoError(t, err) + assert.JSONEq(t, string(tt.wantBytes), string(bytes)) + + // Verify it's valid JSON + var value interface{} + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +func TestHandleExplicitFieldsCustomMarshaler(t *testing.T) { + t.Run("custom marshaler with explicit fields", func(t *testing.T) { + s := &testExplicitFieldsStruct{} + s.SetName(nil) + s.SetCode(stringPtr("test-code")) + + bytes, err := s.MarshalJSON() + require.NoError(t, err) + assert.JSONEq(t, `{"name":null,"code":"test-code"}`, string(bytes)) + }) + + t.Run("custom marshaler with no explicit fields", func(t *testing.T) { + s := &testExplicitFieldsStruct{ + Name: stringPtr("implicit"), + Code: stringPtr("also-implicit"), + } + + bytes, err := s.MarshalJSON() + require.NoError(t, err) + assert.JSONEq(t, `{"name":"implicit","code":"also-implicit"}`, string(bytes)) + }) +} + +func TestHandleExplicitFieldsPointerHandling(t *testing.T) { + t.Run("nil pointer", func(t *testing.T) { + var s *testExplicitFieldsStruct + bytes, err := json.Marshal(HandleExplicitFields(s, nil)) + require.NoError(t, err) + assert.Equal(t, []byte(`null`), bytes) + }) + + t.Run("pointer to struct", func(t *testing.T) { + s := &testExplicitFieldsStruct{} + s.SetName(nil) + + bytes, err := json.Marshal(HandleExplicitFields(s, s.explicitFields)) + require.NoError(t, err) + assert.JSONEq(t, `{"name":null}`, string(bytes)) + }) +} + +func TestHandleExplicitFieldsEmbeddedStruct(t *testing.T) { + t.Run("embedded struct with explicit fields", func(t *testing.T) { + // Create a struct similar to what MarshalJSON creates + s := &testExplicitFieldsStruct{} + s.SetName(nil) + s.SetCode(stringPtr("test-code")) + + type embed testExplicitFieldsStruct + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + + bytes, err := json.Marshal(HandleExplicitFields(marshaler, s.explicitFields)) + require.NoError(t, err) + // Should include both explicit fields (name as null, code as "test-code") + assert.JSONEq(t, `{"name":null,"code":"test-code"}`, string(bytes)) + }) + + t.Run("embedded struct with no explicit fields", func(t *testing.T) { + s := &testExplicitFieldsStruct{ + Name: stringPtr("implicit"), + Code: stringPtr("also-implicit"), + } + + type embed testExplicitFieldsStruct + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + + bytes, err := json.Marshal(HandleExplicitFields(marshaler, s.explicitFields)) + require.NoError(t, err) + // Should only include non-nil fields (omitempty behavior) + assert.JSONEq(t, `{"name":"implicit","code":"also-implicit"}`, string(bytes)) + }) + + t.Run("embedded struct with mixed fields", func(t *testing.T) { + s := &testExplicitFieldsStruct{ + Count: intPtr(42), // implicit field + } + s.SetName(nil) // explicit nil + s.SetCode(stringPtr("explicit")) // explicit value + + type embed testExplicitFieldsStruct + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + + bytes, err := json.Marshal(HandleExplicitFields(marshaler, s.explicitFields)) + require.NoError(t, err) + // Should include explicit null, explicit value, and implicit value + assert.JSONEq(t, `{"name":null,"code":"explicit","count":42}`, string(bytes)) + }) +} + +func TestHandleExplicitFieldsTagHandling(t *testing.T) { + type testStructWithComplexTags struct { + Field1 *string `json:"field1,omitempty" url:"field1,omitempty"` + Field2 *string `json:"field2,omitempty,string" url:"field2"` + Field3 *string `json:"-"` + Field4 *string `json:"field4"` + explicitFields *big.Int `json:"-"` + } + + s := &testStructWithComplexTags{ + Field1: stringPtr("test1"), + Field4: stringPtr("test4"), + explicitFields: big.NewInt(1), // Only first field is explicit + } + + bytes, err := json.Marshal(HandleExplicitFields(s, s.explicitFields)) + require.NoError(t, err) + + // Field1 should have omitempty removed, Field2 should keep omitempty, Field4 should be included + assert.JSONEq(t, `{"field1":"test1","field4":"test4"}`, string(bytes)) +} + +// Test types for nested struct explicit fields testing +type testNestedStruct struct { + NestedName *string `json:"nested_name,omitempty"` + NestedCode *string `json:"nested_code,omitempty"` + explicitFields *big.Int `json:"-"` +} + +type testParentStruct struct { + ParentName *string `json:"parent_name,omitempty"` + Nested *testNestedStruct `json:"nested,omitempty"` + explicitFields *big.Int `json:"-"` +} + +var ( + nestedFieldName = big.NewInt(1 << 0) + nestedFieldCode = big.NewInt(1 << 1) +) + +var ( + parentFieldName = big.NewInt(1 << 0) + parentFieldNested = big.NewInt(1 << 1) +) + +func (n *testNestedStruct) require(field *big.Int) { + if n.explicitFields == nil { + n.explicitFields = big.NewInt(0) + } + n.explicitFields.Or(n.explicitFields, field) +} + +func (n *testNestedStruct) SetNestedName(name *string) { + n.NestedName = name + n.require(nestedFieldName) +} + +func (n *testNestedStruct) SetNestedCode(code *string) { + n.NestedCode = code + n.require(nestedFieldCode) +} + +func (n *testNestedStruct) MarshalJSON() ([]byte, error) { + type embed testNestedStruct + var marshaler = struct { + embed + }{ + embed: embed(*n), + } + return json.Marshal(HandleExplicitFields(marshaler, n.explicitFields)) +} + +func (p *testParentStruct) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +func (p *testParentStruct) SetParentName(name *string) { + p.ParentName = name + p.require(parentFieldName) +} + +func (p *testParentStruct) SetNested(nested *testNestedStruct) { + p.Nested = nested + p.require(parentFieldNested) +} + +func (p *testParentStruct) MarshalJSON() ([]byte, error) { + type embed testParentStruct + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + return json.Marshal(HandleExplicitFields(marshaler, p.explicitFields)) +} + +func TestHandleExplicitFieldsNestedStruct(t *testing.T) { + tests := []struct { + desc string + setupFunc func() *testParentStruct + wantBytes []byte + }{ + { + desc: "nested struct with explicit nil in nested object", + setupFunc: func() *testParentStruct { + nested := &testNestedStruct{ + NestedName: stringPtr("implicit-nested"), + } + nested.SetNestedCode(nil) // explicit nil + + return &testParentStruct{ + ParentName: stringPtr("implicit-parent"), + Nested: nested, + } + }, + wantBytes: []byte(`{"parent_name":"implicit-parent","nested":{"nested_name":"implicit-nested","nested_code":null}}`), + }, + { + desc: "parent with explicit nil nested struct", + setupFunc: func() *testParentStruct { + parent := &testParentStruct{ + ParentName: stringPtr("implicit-parent"), + } + parent.SetNested(nil) // explicit nil nested struct + return parent + }, + wantBytes: []byte(`{"parent_name":"implicit-parent","nested":null}`), + }, + { + desc: "all explicit fields in nested structure", + setupFunc: func() *testParentStruct { + nested := &testNestedStruct{} + nested.SetNestedName(stringPtr("explicit-nested")) + nested.SetNestedCode(nil) // explicit nil + + parent := &testParentStruct{} + parent.SetParentName(nil) // explicit nil + parent.SetNested(nested) // explicit nested struct + + return parent + }, + wantBytes: []byte(`{"parent_name":null,"nested":{"nested_name":"explicit-nested","nested_code":null}}`), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + parent := tt.setupFunc() + bytes, err := parent.MarshalJSON() + require.NoError(t, err) + assert.JSONEq(t, string(tt.wantBytes), string(bytes)) + + // Verify it's valid JSON + var value interface{} + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +// Helper functions +func stringPtr(s string) *string { + return &s +} + +func intPtr(i int) *int { + return &i +} + +func boolPtr(b bool) *bool { + return &b +} diff --git a/internal/http.go b/internal/http.go index 768968b..7786375 100644 --- a/internal/http.go +++ b/internal/http.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "net/url" + "reflect" ) // HTTPClient is an interface for a subset of the *http.Client. @@ -23,15 +24,37 @@ func ResolveBaseURL(values ...string) string { } // EncodeURL encodes the given arguments into the URL, escaping -// values as needed. +// values as needed. Pointer arguments are dereferenced before processing. func EncodeURL(urlFormat string, args ...interface{}) string { escapedArgs := make([]interface{}, 0, len(args)) for _, arg := range args { - escapedArgs = append(escapedArgs, url.PathEscape(fmt.Sprintf("%v", arg))) + // Dereference the argument if it's a pointer + value := dereferenceArg(arg) + escapedArgs = append(escapedArgs, url.PathEscape(fmt.Sprintf("%v", value))) } return fmt.Sprintf(urlFormat, escapedArgs...) } +// dereferenceArg dereferences a pointer argument if necessary, returning the underlying value. +// If the argument is not a pointer or is nil, it returns the argument as-is. +func dereferenceArg(arg interface{}) interface{} { + if arg == nil { + return arg + } + + v := reflect.ValueOf(arg) + + // Keep dereferencing until we get to a non-pointer value or hit nil + for v.Kind() == reflect.Ptr { + if v.IsNil() { + return nil + } + v = v.Elem() + } + + return v.Interface() +} + // MergeHeaders merges the given headers together, where the right // takes precedence over the left. func MergeHeaders(left, right http.Header) http.Header { diff --git a/internal/query.go b/internal/query.go index 24ec496..786318b 100644 --- a/internal/query.go +++ b/internal/query.go @@ -24,31 +24,81 @@ type QueryEncoder interface { EncodeQueryValues(key string, v *url.Values) error } -// QueryValues encodes url.Values from request objects. -// -// Note: This type is inspired by Google's query encoding library, but -// supports far less customization and is tailored to fit this SDK's use case. -// -// Ref: https://github.com/google/go-querystring -func QueryValues(v interface{}) (url.Values, error) { +// prepareValue handles common validation and unwrapping logic for both functions +func prepareValue(v interface{}) (reflect.Value, url.Values, error) { values := make(url.Values) val := reflect.ValueOf(v) for val.Kind() == reflect.Ptr { if val.IsNil() { - return values, nil + return reflect.Value{}, values, nil } val = val.Elem() } if v == nil { - return values, nil + return reflect.Value{}, values, nil } if val.Kind() != reflect.Struct { - return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) + return reflect.Value{}, nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) } err := reflectValue(values, val, "") + if err != nil { + return reflect.Value{}, nil, err + } + + return val, values, nil +} + +// QueryValues encodes url.Values from request objects. +// +// Note: This type is inspired by Google's query encoding library, but +// supports far less customization and is tailored to fit this SDK's use case. +// +// Ref: https://github.com/google/go-querystring +func QueryValues(v interface{}) (url.Values, error) { + _, values, err := prepareValue(v) + return values, err +} + +// QueryValuesWithDefaults encodes url.Values from request objects +// and default values, merging the defaults into the request. +// It's expected that the values of defaults are wire names. +func QueryValuesWithDefaults(v interface{}, defaults map[string]interface{}) (url.Values, error) { + val, values, err := prepareValue(v) + if err != nil { + return values, err + } + + // apply defaults to zero-value fields directly on the original struct + valType := val.Type() + for i := 0; i < val.NumField(); i++ { + field := val.Field(i) + fieldType := valType.Field(i) + fieldName := fieldType.Name + + if fieldType.PkgPath != "" && !fieldType.Anonymous { + // Skip unexported fields. + continue + } + + // check if field is zero value and we have a default for it + if field.CanSet() && field.IsZero() { + tag := fieldType.Tag.Get("url") + if tag == "" || tag == "-" { + continue + } + wireName, _ := parseTag(tag) + if wireName == "" { + wireName = fieldName + } + if defaultVal, exists := defaults[wireName]; exists { + values.Set(wireName, valueString(reflect.ValueOf(defaultVal), tagOptions{}, reflect.StructField{})) + } + } + } + return values, err } diff --git a/internal/query_test.go b/internal/query_test.go index 75f66f8..1a4076d 100644 --- a/internal/query_test.go +++ b/internal/query_test.go @@ -237,3 +237,138 @@ func TestQueryValues(t *testing.T) { assert.Equal(t, "metadata%5Binner%5D=one&metadata%5Binner%5D=two&metadata%5Binner%5D=three", values.Encode()) }) } + +func TestQueryValuesWithDefaults(t *testing.T) { + t.Run("apply defaults to zero values", func(t *testing.T) { + type example struct { + Name string `json:"name" url:"name"` + Age int `json:"age" url:"age"` + Enabled bool `json:"enabled" url:"enabled"` + } + + defaults := map[string]interface{}{ + "name": "default-name", + "age": 25, + "enabled": true, + } + + values, err := QueryValuesWithDefaults(&example{}, defaults) + require.NoError(t, err) + assert.Equal(t, "age=25&enabled=true&name=default-name", values.Encode()) + }) + + t.Run("preserve non-zero values over defaults", func(t *testing.T) { + type example struct { + Name string `json:"name" url:"name"` + Age int `json:"age" url:"age"` + Enabled bool `json:"enabled" url:"enabled"` + } + + defaults := map[string]interface{}{ + "name": "default-name", + "age": 25, + "enabled": true, + } + + values, err := QueryValuesWithDefaults(&example{ + Name: "actual-name", + Age: 30, + // Enabled remains false (zero value), should get default + }, defaults) + require.NoError(t, err) + assert.Equal(t, "age=30&enabled=true&name=actual-name", values.Encode()) + }) + + t.Run("ignore defaults for fields not in struct", func(t *testing.T) { + type example struct { + Name string `json:"name" url:"name"` + Age int `json:"age" url:"age"` + } + + defaults := map[string]interface{}{ + "name": "default-name", + "age": 25, + "nonexistent": "should-be-ignored", + } + + values, err := QueryValuesWithDefaults(&example{}, defaults) + require.NoError(t, err) + assert.Equal(t, "age=25&name=default-name", values.Encode()) + }) + + t.Run("type conversion for compatible defaults", func(t *testing.T) { + type example struct { + Count int64 `json:"count" url:"count"` + Rate float64 `json:"rate" url:"rate"` + Message string `json:"message" url:"message"` + } + + defaults := map[string]interface{}{ + "count": int(100), // int -> int64 conversion + "rate": float32(2.5), // float32 -> float64 conversion + "message": "hello", // string -> string (no conversion needed) + } + + values, err := QueryValuesWithDefaults(&example{}, defaults) + require.NoError(t, err) + assert.Equal(t, "count=100&message=hello&rate=2.5", values.Encode()) + }) + + t.Run("mixed with pointer fields and omitempty", func(t *testing.T) { + type example struct { + Required string `json:"required" url:"required"` + Optional *string `json:"optional,omitempty" url:"optional,omitempty"` + Count int `json:"count,omitempty" url:"count,omitempty"` + } + + defaultOptional := "default-optional" + defaults := map[string]interface{}{ + "required": "default-required", + "optional": &defaultOptional, // pointer type + "count": 42, + } + + values, err := QueryValuesWithDefaults(&example{ + Required: "custom-required", // should override default + // Optional is nil, should get default + // Count is 0, should get default + }, defaults) + require.NoError(t, err) + assert.Equal(t, "count=42&optional=default-optional&required=custom-required", values.Encode()) + }) + + t.Run("override non-zero defaults with explicit zero values", func(t *testing.T) { + type example struct { + Name *string `json:"name" url:"name"` + Age *int `json:"age" url:"age"` + Enabled *bool `json:"enabled" url:"enabled"` + } + + defaults := map[string]interface{}{ + "name": "default-name", + "age": 25, + "enabled": true, + } + + // first, test that a properly empty request is overridden: + { + values, err := QueryValuesWithDefaults(&example{}, defaults) + require.NoError(t, err) + assert.Equal(t, "age=25&enabled=true&name=default-name", values.Encode()) + } + + // second, test that a request that contains zeros is not overridden: + var ( + name = "" + age = 0 + enabled = false + ) + values, err := QueryValuesWithDefaults(&example{ + Name: &name, // explicit empty string should override default + Age: &age, // explicit zero should override default + Enabled: &enabled, // explicit false should override default + }, defaults) + require.NoError(t, err) + assert.Equal(t, "age=0&enabled=false&name=", values.Encode()) + }) +} diff --git a/internal/retrier.go b/internal/retrier.go index 3418f00..4efae1b 100644 --- a/internal/retrier.go +++ b/internal/retrier.go @@ -4,13 +4,14 @@ import ( "crypto/rand" "math/big" "net/http" + "strconv" "time" ) const ( defaultRetryAttempts = 2 - minRetryDelay = 500 * time.Millisecond - maxRetryDelay = 5000 * time.Millisecond + minRetryDelay = 1000 * time.Millisecond + maxRetryDelay = 60000 * time.Millisecond ) // RetryOption adapts the behavior the *Retrier. @@ -105,7 +106,7 @@ func (r *Retrier) run( if r.shouldRetry(response) { defer response.Body.Close() - delay, err := r.retryDelay(retryAttempt) + delay, err := r.retryDelay(response, retryAttempt) if err != nil { return nil, err } @@ -133,31 +134,95 @@ func (r *Retrier) shouldRetry(response *http.Response) bool { response.StatusCode >= http.StatusInternalServerError } -// retryDelay calculates the delay time in milliseconds based on the retry attempt. -func (r *Retrier) retryDelay(retryAttempt uint) (time.Duration, error) { - // Apply exponential backoff. - delay := minRetryDelay + minRetryDelay*time.Duration(retryAttempt*retryAttempt) +// retryDelay calculates the delay time based on response headers, +// falling back to exponential backoff if no headers are present. +func (r *Retrier) retryDelay(response *http.Response, retryAttempt uint) (time.Duration, error) { + // Check for Retry-After header first (RFC 7231), applying no jitter + if retryAfter := response.Header.Get("Retry-After"); retryAfter != "" { + // Parse as number of seconds... + if seconds, err := strconv.Atoi(retryAfter); err == nil { + delay := time.Duration(seconds) * time.Second + if delay > 0 { + if delay > maxRetryDelay { + delay = maxRetryDelay + } + return delay, nil + } + } + + // ...or as an HTTP date; both are valid + if retryTime, err := time.Parse(time.RFC1123, retryAfter); err == nil { + delay := time.Until(retryTime) + if delay > 0 { + if delay > maxRetryDelay { + delay = maxRetryDelay + } + return delay, nil + } + } + } + + // Then check for industry-standard X-RateLimit-Reset header, applying positive jitter + if rateLimitReset := response.Header.Get("X-RateLimit-Reset"); rateLimitReset != "" { + if resetTimestamp, err := strconv.ParseInt(rateLimitReset, 10, 64); err == nil { + // Assume Unix timestamp in seconds + resetTime := time.Unix(resetTimestamp, 0) + delay := time.Until(resetTime) + if delay > 0 { + if delay > maxRetryDelay { + delay = maxRetryDelay + } + return r.addPositiveJitter(delay) + } + } + } + + // Fall back to exponential backoff + return r.exponentialBackoff(retryAttempt) +} - // Do not allow the number to exceed maxRetryDelay. +// exponentialBackoff calculates the delay time based on the retry attempt +// and applies symmetric jitter (±10% around the delay). +func (r *Retrier) exponentialBackoff(retryAttempt uint) (time.Duration, error) { + if retryAttempt > 63 { // 2^63+ would overflow uint64 + retryAttempt = 63 + } + + delay := minRetryDelay << retryAttempt if delay > maxRetryDelay { delay = maxRetryDelay } - // Apply some jitter by randomizing the value in the range of 75%-100%. - max := big.NewInt(int64(delay / 4)) - jitter, err := rand.Int(rand.Reader, max) + return r.addSymmetricJitter(delay) +} + +// addJitterWithRange applies jitter to the given delay. +// minPercent and maxPercent define the jitter range (e.g., 100, 120 for +0% to +20%). +func (r *Retrier) addJitterWithRange(delay time.Duration, minPercent, maxPercent int) (time.Duration, error) { + jitterRange := big.NewInt(int64(delay * time.Duration(maxPercent-minPercent) / 100)) + jitter, err := rand.Int(rand.Reader, jitterRange) if err != nil { return 0, err } - delay -= time.Duration(jitter.Int64()) - - // Never sleep less than the base sleep seconds. - if delay < minRetryDelay { - delay = minRetryDelay + jitteredDelay := delay + time.Duration(jitter.Int64()) + delay*time.Duration(minPercent-100)/100 + if jitteredDelay < minRetryDelay { + jitteredDelay = minRetryDelay } + if jitteredDelay > maxRetryDelay { + jitteredDelay = maxRetryDelay + } + return jitteredDelay, nil +} + +// addPositiveJitter applies positive jitter to the given delay (100%-120% range). +func (r *Retrier) addPositiveJitter(delay time.Duration) (time.Duration, error) { + return r.addJitterWithRange(delay, 100, 120) +} - return delay, nil +// addSymmetricJitter applies symmetric jitter to the given delay (90%-110% range). +func (r *Retrier) addSymmetricJitter(delay time.Duration) (time.Duration, error) { + return r.addJitterWithRange(delay, 90, 110) } type retryOptions struct { diff --git a/internal/retrier_test.go b/internal/retrier_test.go index 743d145..f962526 100644 --- a/internal/retrier_test.go +++ b/internal/retrier_test.go @@ -3,6 +3,7 @@ package internal import ( "context" "encoding/json" + "fmt" "io" "net/http" "net/http/httptest" @@ -19,9 +20,9 @@ type RetryTestCase struct { giveAttempts uint giveStatusCodes []int - giveResponse *Response + giveResponse *InternalTestResponse - wantResponse *Response + wantResponse *InternalTestResponse wantError *core.APIError } @@ -35,10 +36,10 @@ func TestRetrier(t *testing.T) { http.StatusServiceUnavailable, http.StatusOK, }, - giveResponse: &Response{ + giveResponse: &InternalTestResponse{ Id: "1", }, - wantResponse: &Response{ + wantResponse: &InternalTestResponse{ Id: "1", }, }, @@ -106,13 +107,13 @@ func TestRetrier(t *testing.T) { }, ) - var response *Response + var response *InternalTestResponse _, err := caller.Call( context.Background(), &CallParams{ URL: server.URL, Method: http.MethodGet, - Request: &Request{}, + Request: &InternalTestRequest{}, Response: &response, MaxAttempts: test.giveAttempts, ResponseIsOptional: true, @@ -147,8 +148,8 @@ func newTestRetryServer(t *testing.T, tc *RetryTestCase) *httptest.Server { // Ensure that the duration between retries increases exponentially, // and that it is within the minimum and maximum retry delay values. actualDuration := timestamps[index].Sub(timestamps[index-1]) - expectedDurationMin := expectedRetryDurations[index-1] * 75 / 100 - expectedDurationMax := expectedRetryDurations[index-1] * 125 / 100 + expectedDurationMin := expectedRetryDurations[index-1] * 50 / 100 + expectedDurationMax := expectedRetryDurations[index-1] * 150 / 100 assert.True( t, actualDuration >= expectedDurationMin && actualDuration <= expectedDurationMax, @@ -175,13 +176,14 @@ func newTestRetryServer(t *testing.T, tc *RetryTestCase) *httptest.Server { ) } - request := new(Request) + request := new(InternalTestRequest) bytes, err := io.ReadAll(r.Body) require.NoError(t, err) require.NoError(t, json.Unmarshal(bytes, request)) require.LessOrEqual(t, index, len(tc.giveStatusCodes)) statusCode := tc.giveStatusCodes[index] + w.WriteHeader(statusCode) if tc.giveResponse != nil && statusCode == http.StatusOK { @@ -200,12 +202,99 @@ func newTestRetryServer(t *testing.T, tc *RetryTestCase) *httptest.Server { // expectedRetryDurations holds an array of calculated retry durations, // where the index of the array should correspond to the retry attempt. // -// Values are calculated based off of `minRetryDelay + minRetryDelay*i*i`, with -// a max and min value of 5000ms and 500ms respectively. +// Values are calculated based off of `minRetryDelay * 2^i`. var expectedRetryDurations = []time.Duration{ - 500 * time.Millisecond, - 1000 * time.Millisecond, - 2500 * time.Millisecond, - 5000 * time.Millisecond, - 5000 * time.Millisecond, + 1000 * time.Millisecond, // 500ms * 2^1 = 1000ms + 2000 * time.Millisecond, // 500ms * 2^2 = 2000ms + 4000 * time.Millisecond, // 500ms * 2^3 = 4000ms + 8000 * time.Millisecond, // 500ms * 2^4 = 8000ms +} + +func TestRetryDelayTiming(t *testing.T) { + tests := []struct { + name string + headerName string + headerValueFunc func() string + expectedMinMs int64 + expectedMaxMs int64 + }{ + { + name: "retry-after with seconds value", + headerName: "retry-after", + headerValueFunc: func() string { + return "1" + }, + expectedMinMs: 500, + expectedMaxMs: 1500, + }, + { + name: "retry-after with HTTP date", + headerName: "retry-after", + headerValueFunc: func() string { + return time.Now().Add(3 * time.Second).Format(time.RFC1123) + }, + expectedMinMs: 1500, + expectedMaxMs: 4500, + }, + { + name: "x-ratelimit-reset with future timestamp", + headerName: "x-ratelimit-reset", + headerValueFunc: func() string { + return fmt.Sprintf("%d", time.Now().Add(3*time.Second).Unix()) + }, + expectedMinMs: 1500, + expectedMaxMs: 4500, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + var timestamps []time.Time + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timestamps = append(timestamps, time.Now()) + if len(timestamps) == 1 { + // First request - return retryable error with header + w.Header().Set(tt.headerName, tt.headerValueFunc()) + w.WriteHeader(http.StatusTooManyRequests) + } else { + // Second request - return success + w.WriteHeader(http.StatusOK) + response := &InternalTestResponse{Id: "success"} + bytes, _ := json.Marshal(response) + w.Write(bytes) + } + })) + defer server.Close() + + caller := NewCaller(&CallerParams{ + Client: server.Client(), + }) + + var response *InternalTestResponse + _, err := caller.Call( + context.Background(), + &CallParams{ + URL: server.URL, + Method: http.MethodGet, + Request: &InternalTestRequest{}, + Response: &response, + MaxAttempts: 2, + ResponseIsOptional: true, + }, + ) + + require.NoError(t, err) + require.Len(t, timestamps, 2, "Expected exactly 2 requests") + + actualDelayMs := timestamps[1].Sub(timestamps[0]).Milliseconds() + + assert.GreaterOrEqual(t, actualDelayMs, tt.expectedMinMs, + "Actual delay %dms should be >= expected min %dms", actualDelayMs, tt.expectedMinMs) + assert.LessOrEqual(t, actualDelayMs, tt.expectedMaxMs, + "Actual delay %dms should be <= expected max %dms", actualDelayMs, tt.expectedMaxMs) + }) + } } diff --git a/object/types.go b/object/types.go index 356c145..1121cc0 100644 --- a/object/types.go +++ b/object/types.go @@ -6,12 +6,21 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" +) + +var ( + errorFieldCode = big.NewInt(1 << 0) + errorFieldMessage = big.NewInt(1 << 1) ) type Error struct { Code string `json:"code" url:"code"` Message string `json:"message" url:"message"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -34,6 +43,27 @@ func (e *Error) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *Error) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetCode sets the Code field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetCode(code string) { + e.Code = code + e.require(errorFieldCode) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetMessage(message string) { + e.Message = message + e.require(errorFieldMessage) +} + func (e *Error) UnmarshalJSON(data []byte) error { type unmarshaler Error var value unmarshaler @@ -50,6 +80,17 @@ func (e *Error) UnmarshalJSON(data []byte) error { return nil } +func (e *Error) MarshalJSON() ([]byte, error) { + type embed Error + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *Error) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { diff --git a/objects.go b/objects.go index 97b39d2..30661e0 100644 --- a/objects.go +++ b/objects.go @@ -6,14 +6,53 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" time "time" ) +var ( + getObjectRequestFieldAcceptEncoding = big.NewInt(1 << 0) + getObjectRequestFieldPriority = big.NewInt(1 << 1) +) + type GetObjectRequest struct { // If set, Lattice will compress the response using the specified compression method. If the header is not defined, or the compression method is set to `identity`, no compression will be applied to the response. AcceptEncoding *GetObjectRequestAcceptEncoding `json:"-" url:"-"` + // Indicates a client's preference for the priority of the response. The value is a structured header as defined in RFC 9218. If you do not set the header, Lattice uses the default priority set for the environment. Incremental delivery directives are not supported and will be ignored. + Priority *string `json:"-" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (g *GetObjectRequest) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetAcceptEncoding sets the AcceptEncoding field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GetObjectRequest) SetAcceptEncoding(acceptEncoding *GetObjectRequestAcceptEncoding) { + g.AcceptEncoding = acceptEncoding + g.require(getObjectRequestFieldAcceptEncoding) +} + +// SetPriority sets the Priority field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GetObjectRequest) SetPriority(priority *string) { + g.Priority = priority + g.require(getObjectRequestFieldPriority) } +var ( + listObjectsRequestFieldPrefix = big.NewInt(1 << 0) + listObjectsRequestFieldSinceTimestamp = big.NewInt(1 << 1) + listObjectsRequestFieldPageToken = big.NewInt(1 << 2) + listObjectsRequestFieldAllObjectsInMesh = big.NewInt(1 << 3) +) + type ListObjectsRequest struct { // Filters the objects based on the specified prefix path. If no path is specified, all objects are returned. Prefix *string `json:"-" url:"prefix,omitempty"` @@ -23,8 +62,51 @@ type ListObjectsRequest struct { PageToken *string `json:"-" url:"pageToken,omitempty"` // Lists objects across all environment nodes in a Lattice Mesh. AllObjectsInMesh *bool `json:"-" url:"allObjectsInMesh,omitempty"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (l *ListObjectsRequest) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetPrefix sets the Prefix field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListObjectsRequest) SetPrefix(prefix *string) { + l.Prefix = prefix + l.require(listObjectsRequestFieldPrefix) } +// SetSinceTimestamp sets the SinceTimestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListObjectsRequest) SetSinceTimestamp(sinceTimestamp *time.Time) { + l.SinceTimestamp = sinceTimestamp + l.require(listObjectsRequestFieldSinceTimestamp) +} + +// SetPageToken sets the PageToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListObjectsRequest) SetPageToken(pageToken *string) { + l.PageToken = pageToken + l.require(listObjectsRequestFieldPageToken) +} + +// SetAllObjectsInMesh sets the AllObjectsInMesh field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListObjectsRequest) SetAllObjectsInMesh(allObjectsInMesh *bool) { + l.AllObjectsInMesh = allObjectsInMesh + l.require(listObjectsRequestFieldAllObjectsInMesh) +} + +var ( + contentIdentifierFieldPath = big.NewInt(1 << 0) + contentIdentifierFieldChecksum = big.NewInt(1 << 1) +) + type ContentIdentifier struct { // A valid path must not contain the following: // - Spaces or Tabs @@ -35,6 +117,9 @@ type ContentIdentifier struct { // The SHA-256 checksum of this object. Checksum string `json:"checksum" url:"checksum"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -57,6 +142,27 @@ func (c *ContentIdentifier) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *ContentIdentifier) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetPath sets the Path field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ContentIdentifier) SetPath(path string) { + c.Path = path + c.require(contentIdentifierFieldPath) +} + +// SetChecksum sets the Checksum field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ContentIdentifier) SetChecksum(checksum string) { + c.Checksum = checksum + c.require(contentIdentifierFieldChecksum) +} + func (c *ContentIdentifier) UnmarshalJSON(data []byte) error { type unmarshaler ContentIdentifier var value unmarshaler @@ -73,6 +179,17 @@ func (c *ContentIdentifier) UnmarshalJSON(data []byte) error { return nil } +func (c *ContentIdentifier) MarshalJSON() ([]byte, error) { + type embed ContentIdentifier + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *ContentIdentifier) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -85,10 +202,18 @@ func (c *ContentIdentifier) String() string { return fmt.Sprintf("%#v", c) } +var ( + listResponseFieldPathMetadatas = big.NewInt(1 << 0) + listResponseFieldNextPageToken = big.NewInt(1 << 1) +) + type ListResponse struct { PathMetadatas []*PathMetadata `json:"path_metadatas" url:"path_metadatas"` NextPageToken *string `json:"next_page_token,omitempty" url:"next_page_token,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -111,6 +236,27 @@ func (l *ListResponse) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *ListResponse) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetPathMetadatas sets the PathMetadatas field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListResponse) SetPathMetadatas(pathMetadatas []*PathMetadata) { + l.PathMetadatas = pathMetadatas + l.require(listResponseFieldPathMetadatas) +} + +// SetNextPageToken sets the NextPageToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *ListResponse) SetNextPageToken(nextPageToken *string) { + l.NextPageToken = nextPageToken + l.require(listResponseFieldNextPageToken) +} + func (l *ListResponse) UnmarshalJSON(data []byte) error { type unmarshaler ListResponse var value unmarshaler @@ -127,6 +273,17 @@ func (l *ListResponse) UnmarshalJSON(data []byte) error { return nil } +func (l *ListResponse) MarshalJSON() ([]byte, error) { + type embed ListResponse + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *ListResponse) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -139,12 +296,22 @@ func (l *ListResponse) String() string { return fmt.Sprintf("%#v", l) } +var ( + pathMetadataFieldContentIdentifier = big.NewInt(1 << 0) + pathMetadataFieldSizeBytes = big.NewInt(1 << 1) + pathMetadataFieldLastUpdatedAt = big.NewInt(1 << 2) + pathMetadataFieldExpiryTime = big.NewInt(1 << 3) +) + type PathMetadata struct { ContentIdentifier *ContentIdentifier `json:"content_identifier" url:"content_identifier"` SizeBytes int64 `json:"size_bytes" url:"size_bytes"` LastUpdatedAt time.Time `json:"last_updated_at" url:"last_updated_at"` ExpiryTime *time.Time `json:"expiry_time,omitempty" url:"expiry_time,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -181,6 +348,41 @@ func (p *PathMetadata) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PathMetadata) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetContentIdentifier sets the ContentIdentifier field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PathMetadata) SetContentIdentifier(contentIdentifier *ContentIdentifier) { + p.ContentIdentifier = contentIdentifier + p.require(pathMetadataFieldContentIdentifier) +} + +// SetSizeBytes sets the SizeBytes field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PathMetadata) SetSizeBytes(sizeBytes int64) { + p.SizeBytes = sizeBytes + p.require(pathMetadataFieldSizeBytes) +} + +// SetLastUpdatedAt sets the LastUpdatedAt field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PathMetadata) SetLastUpdatedAt(lastUpdatedAt time.Time) { + p.LastUpdatedAt = lastUpdatedAt + p.require(pathMetadataFieldLastUpdatedAt) +} + +// SetExpiryTime sets the ExpiryTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PathMetadata) SetExpiryTime(expiryTime *time.Time) { + p.ExpiryTime = expiryTime + p.require(pathMetadataFieldExpiryTime) +} + func (p *PathMetadata) UnmarshalJSON(data []byte) error { type embed PathMetadata var unmarshaler = struct { @@ -216,7 +418,8 @@ func (p *PathMetadata) MarshalJSON() ([]byte, error) { LastUpdatedAt: internal.NewDateTime(p.LastUpdatedAt), ExpiryTime: internal.NewOptionalDateTime(p.ExpiryTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) } func (p *PathMetadata) String() string { diff --git a/objects/client.go b/objects/client.go index 6f491ea..8c042ef 100644 --- a/objects/client.go +++ b/objects/client.go @@ -4,7 +4,7 @@ package objects import ( context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" @@ -15,15 +15,15 @@ import ( type Client struct { WithRawResponse *RawClient + options *core.RequestOptions baseURL string caller *internal.Caller - header http.Header } -func NewClient(opts ...option.RequestOption) *Client { - options := core.NewRequestOptions(opts...) +func NewClient(options *core.RequestOptions) *Client { return &Client{ WithRawResponse: NewRawClient(options), + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -31,16 +31,15 @@ func NewClient(opts ...option.RequestOption) *Client { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } // Lists objects in your environment. You can define a prefix to list a subset of your objects. If you do not set a prefix, Lattice returns all available objects. By default this endpoint will list local objects only. func (c *Client) ListObjects( ctx context.Context, - request *v2.ListObjectsRequest, + request *Lattice.ListObjectsRequest, opts ...option.RequestOption, -) (*core.Page[*v2.PathMetadata], error) { +) (*core.Page[*Lattice.PathMetadata], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -53,26 +52,9 @@ func (c *Client) ListObjects( return nil, err } headers := internal.MergeHeaders( - c.header.Clone(), + c.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &v2.InternalServerError{ - APIError: apiError, - } - }, - } prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { if pageRequest.Cursor != nil { queryParams.Set("pageToken", *pageRequest.Cursor) @@ -90,14 +72,14 @@ func (c *Client) ListObjects( QueryParameters: options.QueryParameters, Client: options.HTTPClient, Response: pageRequest.Response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), } } - readPageResponse := func(response *v2.ListResponse) *internal.PageResponse[*string, *v2.PathMetadata] { + readPageResponse := func(response *Lattice.ListResponse) *internal.PageResponse[*string, *Lattice.PathMetadata] { var zeroValue *string next := response.GetNextPageToken() results := response.GetPathMetadatas() - return &internal.PageResponse[*string, *v2.PathMetadata]{ + return &internal.PageResponse[*string, *Lattice.PathMetadata]{ Next: next, Results: results, Done: next == zeroValue, @@ -116,7 +98,7 @@ func (c *Client) GetObject( ctx context.Context, // The path of the object to fetch. objectPath string, - request *v2.GetObjectRequest, + request *Lattice.GetObjectRequest, opts ...option.RequestOption, ) (io.Reader, error) { response, err := c.WithRawResponse.GetObject( @@ -138,7 +120,7 @@ func (c *Client) UploadObject( objectPath string, request io.Reader, opts ...option.RequestOption, -) (*v2.PathMetadata, error) { +) (*Lattice.PathMetadata, error) { response, err := c.WithRawResponse.UploadObject( ctx, objectPath, diff --git a/objects/objects_test/objects_test.go b/objects/objects_test/objects_test.go new file mode 100644 index 0000000..4b36444 --- /dev/null +++ b/objects/objects_test/objects_test.go @@ -0,0 +1,237 @@ +// Code generated by Fern. DO NOT EDIT. + +package objects_test + +import ( + context "context" + fmt "fmt" + v2 "github.com/anduril/lattice-sdk-go/v2" + client "github.com/anduril/lattice-sdk-go/v2/client" + option "github.com/anduril/lattice-sdk-go/v2/option" + require "github.com/stretchr/testify/require" + gowiremock "github.com/wiremock/go-wiremock" + wiremocktestcontainersgo "github.com/wiremock/wiremock-testcontainers-go" + http "net/http" + os "os" + testing "testing" +) + +// TestMain sets up shared test fixtures for all tests in this package// Global test fixtures +var ( + WireMockContainer *wiremocktestcontainersgo.WireMockContainer + WireMockBaseURL string + WireMockClient *gowiremock.Client +) + +// TestMain sets up shared test fixtures for all tests in this package +func TestMain(m *testing.M) { + // Setup shared WireMock container + ctx := context.Background() + container, err := wiremocktestcontainersgo.RunContainerAndStopOnCleanup( + ctx, + &testing.T{}, + wiremocktestcontainersgo.WithImage("docker.io/wiremock/wiremock:3.9.1"), + ) + if err != nil { + fmt.Printf("Failed to start WireMock container: %v\n", err) + os.Exit(1) + } + + // Store global references + WireMockContainer = container + + // Try to get the base URL using the standard method first + baseURL, err := container.Endpoint(ctx, "") + if err == nil { + // Standard method worked (running outside DinD) + // This uses the mapped port (e.g., localhost:59553) + WireMockBaseURL = "http://" + baseURL + WireMockClient = container.Client + } else { + // Standard method failed, use internal IP fallback (DinD environment) + fmt.Printf("Standard endpoint resolution failed, using internal IP fallback: %v\n", err) + + inspect, err := container.Inspect(ctx) + if err != nil { + fmt.Printf("Failed to inspect WireMock container: %v\n", err) + os.Exit(1) + } + + // Find the IP address from the container's networks + var containerIP string + for _, network := range inspect.NetworkSettings.Networks { + if network.IPAddress != "" { + containerIP = network.IPAddress + break + } + } + + if containerIP == "" { + fmt.Printf("Failed to get WireMock container IP address\n") + os.Exit(1) + } + + // In DinD, use the internal port directly (8080 for WireMock HTTP) + // Don't use the mapped port since it doesn't exist in this environment + WireMockBaseURL = fmt.Sprintf("http://%s:8080", containerIP) + + // The container.Client was created with a bad URL, so we need a new one + WireMockClient = gowiremock.NewClient(WireMockBaseURL) + } + + fmt.Printf("WireMock available at: %s\n", WireMockBaseURL) + + // Run all tests + code := m.Run() + + // Cleanup + if WireMockContainer != nil { + WireMockContainer.Terminate(ctx) + } + + // Exit with the same code as the tests + os.Exit(code) +} + +func TestObjectsListObjectsWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Get(gowiremock.URLPathTemplate("/api/v1/objects")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"path_metadatas": []interface{}{map[string]interface{}{"content_identifier": map[string]interface{}{"path": "path", "checksum": "checksum"}, "size_bytes": 1000000, "last_updated_at": "2024-01-15T09:30:00Z", "expiry_time": "2024-01-15T09:30:00Z"}}, "next_page_token": "next_page_token"}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.ListObjectsRequest{ + Prefix: Lattice.String( + "prefix", + ), + SinceTimestamp: Lattice.Time( + Lattice.MustParseDateTime( + "2024-01-15T09:30:00Z", + ), + ), + PageToken: Lattice.String( + "pageToken", + ), + AllObjectsInMesh: Lattice.Bool( + true, + ), + } + _, invocationErr := client.Objects.ListObjects( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestObjectsGetObjectWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Get(gowiremock.URLPathTemplate("/api/v1/objects/{objectPath}")).WithPathParam( + "objectPath", + gowiremock.Matching("objectPath"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.GetObjectRequest{} + _, invocationErr := client.Objects.GetObject( + context.TODO(), + "objectPath", + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestObjectsDeleteObjectWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Delete(gowiremock.URLPathTemplate("/api/v1/objects/{objectPath}")).WithPathParam( + "objectPath", + gowiremock.Matching("objectPath"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + invocationErr := client.Objects.DeleteObject( + context.TODO(), + "objectPath", + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestObjectsGetObjectMetadataWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Head(gowiremock.URLPathTemplate("/api/v1/objects/{objectPath}")).WithPathParam( + "objectPath", + gowiremock.Matching("objectPath"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + invocationErr := client.Objects.GetObjectMetadata( + context.TODO(), + "objectPath", + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} diff --git a/objects/raw_client.go b/objects/raw_client.go index 0ef7cb4..abf42c2 100644 --- a/objects/raw_client.go +++ b/objects/raw_client.go @@ -5,7 +5,7 @@ package objects import ( bytes "bytes" context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" @@ -16,11 +16,12 @@ import ( type RawClient struct { baseURL string caller *internal.Caller - header http.Header + options *core.RequestOptions } func NewRawClient(options *core.RequestOptions) *RawClient { return &RawClient{ + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -28,7 +29,6 @@ func NewRawClient(options *core.RequestOptions) *RawClient { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } @@ -36,7 +36,7 @@ func (r *RawClient) GetObject( ctx context.Context, // The path of the object to fetch. objectPath string, - request *v2.GetObjectRequest, + request *Lattice.GetObjectRequest, opts ...option.RequestOption, ) (*core.Response[io.Reader], error) { options := core.NewRequestOptions(opts...) @@ -50,35 +50,16 @@ func (r *RawClient) GetObject( objectPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) if request.AcceptEncoding != nil { headers.Add("Accept-Encoding", string(*request.AcceptEncoding)) } - - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &v2.InternalServerError{ - APIError: apiError, - } - }, + if request.Priority != nil { + headers.Add("Priority", *request.Priority) } + response := bytes.NewBuffer(nil) raw, err := r.caller.Call( ctx, @@ -91,7 +72,7 @@ func (r *RawClient) GetObject( QueryParameters: options.QueryParameters, Client: options.HTTPClient, Response: response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { @@ -110,7 +91,7 @@ func (r *RawClient) UploadObject( objectPath string, request io.Reader, opts ...option.RequestOption, -) (*core.Response[*v2.PathMetadata], error) { +) (*core.Response[*Lattice.PathMetadata], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -122,37 +103,10 @@ func (r *RawClient) UploadObject( objectPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 413: func(apiError *core.APIError) error { - return &v2.ContentTooLargeError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &v2.InternalServerError{ - APIError: apiError, - } - }, - 507: func(apiError *core.APIError) error { - return &v2.InsufficientStorageError{ - APIError: apiError, - } - }, - } - var response *v2.PathMetadata + var response *Lattice.PathMetadata raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -165,13 +119,13 @@ func (r *RawClient) UploadObject( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.PathMetadata]{ + return &core.Response[*Lattice.PathMetadata]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -195,31 +149,9 @@ func (r *RawClient) DeleteObject( objectPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &v2.InternalServerError{ - APIError: apiError, - } - }, - } raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -230,7 +162,7 @@ func (r *RawClient) DeleteObject( BodyProperties: options.BodyProperties, QueryParameters: options.QueryParameters, Client: options.HTTPClient, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { @@ -260,26 +192,9 @@ func (r *RawClient) GetObjectMetadata( objectPath, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &v2.InternalServerError{ - APIError: apiError, - } - }, - } raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -290,7 +205,7 @@ func (r *RawClient) GetObjectMetadata( BodyProperties: options.BodyProperties, QueryParameters: options.QueryParameters, Client: options.HTTPClient, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..52671f7 --- /dev/null +++ b/reference.md @@ -0,0 +1,1125 @@ +# Reference +## Entities +
client.Entities.PublishEntity(request) -> *Lattice.Entity +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Publish an entity for ingest into the Entities API. Entities created with this method are "owned" by the originator: other sources, +such as the UI, may not edit or delete these entities. The server validates entities at API call time and +returns an error if the entity is invalid. + +An entity ID must be provided when calling this endpoint. If the entity referenced by the entity ID does not exist +then it will be created. Otherwise the entity will be updated. An entity will only be updated if its +provenance.sourceUpdateTime is greater than the provenance.sourceUpdateTime of the existing entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.Entity{} +client.Entities.PublishEntity( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `*Lattice.Entity` + +
+
+
+
+ + +
+
+
+ +
client.Entities.GetEntity(EntityID) -> *Lattice.Entity +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +client.Entities.GetEntity( + context.TODO(), + "entityId", + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityID:** `string` — ID of the entity to return + +
+
+
+
+ + +
+
+
+ +
client.Entities.OverrideEntity(EntityID, FieldPath, request) -> *Lattice.Entity +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Only fields marked with overridable can be overridden. Please refer to our documentation to see the comprehensive +list of fields that can be overridden. The entity in the request body should only have a value set on the field +specified in the field path parameter. Field paths are rooted in the base entity object and must be represented +using lower_snake_case. Do not include "entity" in the field path. + +Note that overrides are applied in an eventually consistent manner. If multiple overrides are created +concurrently for the same field path, the last writer wins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.EntityOverride{} +client.Entities.OverrideEntity( + context.TODO(), + "entityId", + "mil_view.disposition", + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityID:** `string` — The unique ID of the entity to override + +
+
+ +
+
+ +**fieldPath:** `string` — fieldPath to override + +
+
+ +
+
+ +**entity:** `*Lattice.Entity` + +The entity containing the overridden fields. The service will extract the overridable fields from +the object and ignore all other fields. + +
+
+ +
+
+ +**provenance:** `*Lattice.Provenance` — Additional information about the source of the override. + +
+
+
+
+ + +
+
+
+ +
client.Entities.RemoveEntityOverride(EntityID, FieldPath) -> *Lattice.Entity +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This operation clears the override value from the specified field path on the entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +client.Entities.RemoveEntityOverride( + context.TODO(), + "entityId", + "mil_view.disposition", + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityID:** `string` — The unique ID of the entity to undo an override from. + +
+
+ +
+
+ +**fieldPath:** `string` — The fieldPath to clear overrides from. + +
+
+
+
+ + +
+
+
+ +
client.Entities.LongPollEntityEvents(request) -> *Lattice.EntityEventResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This is a long polling API that will first return all pre-existing data and then return all new data as +it becomes available. If you want to start a new polling session then open a request with an empty +'sessionToken' in the request body. The server will return a new session token in the response. +If you want to retrieve the next batch of results from an existing polling session then send the session +token you received from the server in the request body. If no new data is available then the server will +hold the connection open for up to 5 minutes. After the 5 minute timeout period, the server will close the +connection with no results and you may resume polling with the same session token. If your session falls behind +more than 3x the total number of entities in the environment, the server will terminate your session. +In this case you must start a new session by sending a request with an empty session token. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.EntityEventRequest{ + SessionToken: "sessionToken", + } +client.Entities.LongPollEntityEvents( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**sessionToken:** `string` — Long-poll session identifier. Leave empty to start a new polling session. + +
+
+ +
+
+ +**batchSize:** `*int` — Maximum size of response batch. Defaults to 100. Must be between 1 and 2000 (inclusive). + +
+
+
+
+ + +
+
+
+ +
client.Entities.StreamEntities(request) -> Lattice.StreamEntitiesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Establishes a persistent connection to stream entity events as they occur. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.EntityStreamRequest{} +client.Entities.StreamEntities( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**heartbeatIntervalMs:** `*int` — at what interval to send heartbeat events, defaults to 30s. + +
+
+ +
+
+ +**preExistingOnly:** `*bool` — only stream pre-existing entities in the environment and then close the connection, defaults to false. + +
+
+ +
+
+ +**componentsToInclude:** `[]string` — list of components to include, leave empty to include all components. + +
+
+
+
+ + +
+
+
+ +## Tasks +
client.Tasks.CreateTask(request) -> *Lattice.Task +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Submit a request to create a task and schedule it for delivery. Tasks, once delivered, will +be asynchronously updated by their destined agent. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.TaskCreation{} +client.Tasks.CreateTask( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**taskID:** `*string` + +If non-empty, will set the requested Task ID, otherwise will generate a new random +GUID. Will reject if supplied Task ID does not match [A-Za-z0-9_-.]{5,36}. + +
+
+ +
+
+ +**displayName:** `*string` — Human readable display name for this Task, should be short (<100 chars). + +
+
+ +
+
+ +**description:** `*string` — Longer, free form human readable description of this Task. + +
+
+ +
+
+ +**specification:** `*Lattice.GoogleProtobufAny` — Full set of task parameters. + +
+
+ +
+
+ +**author:** `*Lattice.Principal` + +
+
+ +
+
+ +**relations:** `*Lattice.Relations` + +Any relationships associated with this Task, such as a parent Task or an assignee +this Task is designated to for execution. + +
+
+ +
+
+ +**isExecutedElsewhere:** `*bool` + +If set, then the service will not trigger execution of this task on an agent. Useful +for when ingesting tasks from an external system that is triggering execution of tasks +on agents. + +
+
+ +
+
+ +**initialEntities:** `[]*Lattice.TaskEntity` + +Indicates an initial set of entities that can be used to execute an entity aware +task. For example, an entity Objective, an entity Keep In Zone, etc. + +
+
+
+
+ + +
+
+
+ +
client.Tasks.GetTask(TaskID) -> *Lattice.Task +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +client.Tasks.GetTask( + context.TODO(), + "taskId", + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**taskID:** `string` — ID of task to return + +
+
+
+
+ + +
+
+
+ +
client.Tasks.UpdateTaskStatus(TaskID, request) -> *Lattice.Task +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update the status of a task. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.TaskStatusUpdate{} +client.Tasks.UpdateTaskStatus( + context.TODO(), + "taskId", + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**taskID:** `string` — ID of task to update status of + +
+
+ +
+
+ +**statusVersion:** `*int` + +The status version of the task to update. This version number increments to indicate the task's +current stage in its status lifecycle. Specifically, whenever a task's status updates, the status +version increments by one. Any status updates received with a lower status version number than what +is known are considered stale and ignored. + +
+
+ +
+
+ +**newStatus:** `*Lattice.TaskStatus` — The new status of the task. + +
+
+ +
+
+ +**author:** `*Lattice.Principal` + +
+
+
+
+ + +
+
+
+ +
client.Tasks.QueryTasks(request) -> *Lattice.TaskQueryResults +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Query for tasks by a specified search criteria. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.TaskQuery{} +client.Tasks.QueryTasks( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**pageToken:** `*string` — If set, returns results starting from the given pageToken. + +
+
+ +
+
+ +**parentTaskID:** `*string` + +If present matches Tasks with this parent Task ID. +Note: this is mutually exclusive with all other query parameters, i.e., either provide parent Task ID, or +any of the remaining parameters, but not both. + +
+
+ +
+
+ +**statusFilter:** `*Lattice.TaskQueryStatusFilter` + +
+
+ +
+
+ +**updateTimeRange:** `*Lattice.TaskQueryUpdateTimeRange` — If provided, only provides Tasks updated within the time range. + +
+
+
+
+ + +
+
+
+ +
client.Tasks.ListenAsAgent(request) -> *Lattice.AgentRequest +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This is a long polling API that will block until a new task is ready for delivery. If no new task is +available then the server will hold on to your request for up to 5 minutes, after that 5 minute timeout +period you will be expected to reinitiate a new request. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.AgentListener{} +client.Tasks.ListenAsAgent( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**agentSelector:** `*Lattice.EntityIDsSelector` — Selector criteria to determine which Agent Tasks the agent receives + +
+
+
+
+ + +
+
+
+ +## Objects +
client.Objects.ListObjects() -> *Lattice.ListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists objects in your environment. You can define a prefix to list a subset of your objects. If you do not set a prefix, Lattice returns all available objects. By default this endpoint will list local objects only. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.ListObjectsRequest{ + Prefix: Lattice.String( + "prefix", + ), + SinceTimestamp: Lattice.Time( + Lattice.MustParseDateTime( + "2024-01-15T09:30:00Z", + ), + ), + PageToken: Lattice.String( + "pageToken", + ), + AllObjectsInMesh: Lattice.Bool( + true, + ), + } +client.Objects.ListObjects( + context.TODO(), + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prefix:** `*string` — Filters the objects based on the specified prefix path. If no path is specified, all objects are returned. + +
+
+ +
+
+ +**sinceTimestamp:** `*time.Time` — Sets the age for the oldest objects to query across the environment. + +
+
+ +
+
+ +**pageToken:** `*string` — Base64 and URL-encoded cursor returned by the service to continue paging. + +
+
+ +
+
+ +**allObjectsInMesh:** `*bool` — Lists objects across all environment nodes in a Lattice Mesh. + +
+
+
+
+ + +
+
+
+ +
client.Objects.GetObject(ObjectPath) -> string +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetches an object from your environment using the objectPath path parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +request := &Lattice.GetObjectRequest{} +client.Objects.GetObject( + context.TODO(), + "objectPath", + request, + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**objectPath:** `string` — The path of the object to fetch. + +
+
+ +
+
+ +**acceptEncoding:** `*Lattice.GetObjectRequestAcceptEncoding` — If set, Lattice will compress the response using the specified compression method. If the header is not defined, or the compression method is set to `identity`, no compression will be applied to the response. + +
+
+ +
+
+ +**priority:** `*string` — Indicates a client's preference for the priority of the response. The value is a structured header as defined in RFC 9218. If you do not set the header, Lattice uses the default priority set for the environment. Incremental delivery directives are not supported and will be ignored. + +
+
+
+
+ + +
+
+
+ +
client.Objects.DeleteObject(ObjectPath) -> error +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deletes an object from your environment given the objectPath path parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +client.Objects.DeleteObject( + context.TODO(), + "objectPath", + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**objectPath:** `string` — The path of the object to delete. + +
+
+
+
+ + +
+
+
+ +
client.Objects.GetObjectMetadata(ObjectPath) -> error +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns metadata for a specified object path. Use this to fetch metadata such as object size (size_bytes), its expiry time (expiry_time), or its latest update timestamp (last_updated_at). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```go +client.Objects.GetObjectMetadata( + context.TODO(), + "objectPath", + ) +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**objectPath:** `string` — The path of the object to query. + +
+
+
+
+ + +
+
+
diff --git a/task/types.go b/task/types.go index 2c97e96..a24a636 100644 --- a/task/types.go +++ b/task/types.go @@ -6,12 +6,21 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" +) + +var ( + errorFieldCode = big.NewInt(1 << 0) + errorFieldMessage = big.NewInt(1 << 1) ) type Error struct { Code string `json:"code" url:"code"` Message string `json:"message" url:"message"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -34,6 +43,27 @@ func (e *Error) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *Error) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetCode sets the Code field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetCode(code string) { + e.Code = code + e.require(errorFieldCode) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Error) SetMessage(message string) { + e.Message = message + e.require(errorFieldMessage) +} + func (e *Error) UnmarshalJSON(data []byte) error { type unmarshaler Error var value unmarshaler @@ -50,6 +80,17 @@ func (e *Error) UnmarshalJSON(data []byte) error { return nil } +func (e *Error) MarshalJSON() ([]byte, error) { + type embed Error + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *Error) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { diff --git a/tasks.go b/tasks.go index 6fccd00..1585840 100644 --- a/tasks.go +++ b/tasks.go @@ -6,9 +6,21 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" time "time" ) +var ( + taskCreationFieldTaskID = big.NewInt(1 << 0) + taskCreationFieldDisplayName = big.NewInt(1 << 1) + taskCreationFieldDescription = big.NewInt(1 << 2) + taskCreationFieldSpecification = big.NewInt(1 << 3) + taskCreationFieldAuthor = big.NewInt(1 << 4) + taskCreationFieldRelations = big.NewInt(1 << 5) + taskCreationFieldIsExecutedElsewhere = big.NewInt(1 << 6) + taskCreationFieldInitialEntities = big.NewInt(1 << 7) +) + type TaskCreation struct { // If non-empty, will set the requested Task ID, otherwise will generate a new random // GUID. Will reject if supplied Task ID does not match [A-Za-z0-9_-.]{5,36}. @@ -30,13 +42,107 @@ type TaskCreation struct { // Indicates an initial set of entities that can be used to execute an entity aware // task. For example, an entity Objective, an entity Keep In Zone, etc. InitialEntities []*TaskEntity `json:"initialEntities,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` } +func (t *TaskCreation) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTaskID sets the TaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetTaskID(taskID *string) { + t.TaskID = taskID + t.require(taskCreationFieldTaskID) +} + +// SetDisplayName sets the DisplayName field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetDisplayName(displayName *string) { + t.DisplayName = displayName + t.require(taskCreationFieldDisplayName) +} + +// SetDescription sets the Description field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetDescription(description *string) { + t.Description = description + t.require(taskCreationFieldDescription) +} + +// SetSpecification sets the Specification field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetSpecification(specification *GoogleProtobufAny) { + t.Specification = specification + t.require(taskCreationFieldSpecification) +} + +// SetAuthor sets the Author field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetAuthor(author *Principal) { + t.Author = author + t.require(taskCreationFieldAuthor) +} + +// SetRelations sets the Relations field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetRelations(relations *Relations) { + t.Relations = relations + t.require(taskCreationFieldRelations) +} + +// SetIsExecutedElsewhere sets the IsExecutedElsewhere field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetIsExecutedElsewhere(isExecutedElsewhere *bool) { + t.IsExecutedElsewhere = isExecutedElsewhere + t.require(taskCreationFieldIsExecutedElsewhere) +} + +// SetInitialEntities sets the InitialEntities field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCreation) SetInitialEntities(initialEntities []*TaskEntity) { + t.InitialEntities = initialEntities + t.require(taskCreationFieldInitialEntities) +} + +var ( + agentListenerFieldAgentSelector = big.NewInt(1 << 0) +) + type AgentListener struct { // Selector criteria to determine which Agent Tasks the agent receives AgentSelector *EntityIDsSelector `json:"agentSelector,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` } +func (a *AgentListener) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetAgentSelector sets the AgentSelector field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AgentListener) SetAgentSelector(agentSelector *EntityIDsSelector) { + a.AgentSelector = agentSelector + a.require(agentListenerFieldAgentSelector) +} + +var ( + taskQueryFieldPageToken = big.NewInt(1 << 0) + taskQueryFieldParentTaskID = big.NewInt(1 << 1) + taskQueryFieldStatusFilter = big.NewInt(1 << 2) + taskQueryFieldUpdateTimeRange = big.NewInt(1 << 3) +) + type TaskQuery struct { // If set, returns results starting from the given pageToken. PageToken *string `json:"pageToken,omitempty" url:"-"` @@ -47,13 +153,60 @@ type TaskQuery struct { StatusFilter *TaskQueryStatusFilter `json:"statusFilter,omitempty" url:"-"` // If provided, only provides Tasks updated within the time range. UpdateTimeRange *TaskQueryUpdateTimeRange `json:"updateTimeRange,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (t *TaskQuery) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetPageToken sets the PageToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQuery) SetPageToken(pageToken *string) { + t.PageToken = pageToken + t.require(taskQueryFieldPageToken) } +// SetParentTaskID sets the ParentTaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQuery) SetParentTaskID(parentTaskID *string) { + t.ParentTaskID = parentTaskID + t.require(taskQueryFieldParentTaskID) +} + +// SetStatusFilter sets the StatusFilter field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQuery) SetStatusFilter(statusFilter *TaskQueryStatusFilter) { + t.StatusFilter = statusFilter + t.require(taskQueryFieldStatusFilter) +} + +// SetUpdateTimeRange sets the UpdateTimeRange field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQuery) SetUpdateTimeRange(updateTimeRange *TaskQueryUpdateTimeRange) { + t.UpdateTimeRange = updateTimeRange + t.require(taskQueryFieldUpdateTimeRange) +} + +var ( + agentRequestFieldExecuteRequest = big.NewInt(1 << 0) + agentRequestFieldCancelRequest = big.NewInt(1 << 1) + agentRequestFieldCompleteRequest = big.NewInt(1 << 2) +) + type AgentRequest struct { ExecuteRequest *ExecuteRequest `json:"executeRequest,omitempty" url:"executeRequest,omitempty"` CancelRequest *CancelRequest `json:"cancelRequest,omitempty" url:"cancelRequest,omitempty"` CompleteRequest *CompleteRequest `json:"completeRequest,omitempty" url:"completeRequest,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -83,6 +236,34 @@ func (a *AgentRequest) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *AgentRequest) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetExecuteRequest sets the ExecuteRequest field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AgentRequest) SetExecuteRequest(executeRequest *ExecuteRequest) { + a.ExecuteRequest = executeRequest + a.require(agentRequestFieldExecuteRequest) +} + +// SetCancelRequest sets the CancelRequest field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AgentRequest) SetCancelRequest(cancelRequest *CancelRequest) { + a.CancelRequest = cancelRequest + a.require(agentRequestFieldCancelRequest) +} + +// SetCompleteRequest sets the CompleteRequest field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AgentRequest) SetCompleteRequest(completeRequest *CompleteRequest) { + a.CompleteRequest = completeRequest + a.require(agentRequestFieldCompleteRequest) +} + func (a *AgentRequest) UnmarshalJSON(data []byte) error { type unmarshaler AgentRequest var value unmarshaler @@ -99,6 +280,17 @@ func (a *AgentRequest) UnmarshalJSON(data []byte) error { return nil } +func (a *AgentRequest) MarshalJSON() ([]byte, error) { + type embed AgentRequest + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *AgentRequest) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -112,10 +304,17 @@ func (a *AgentRequest) String() string { } // Allocation contains a list of agents allocated to a Task. +var ( + allocationFieldActiveAgents = big.NewInt(1 << 0) +) + type Allocation struct { // Agents actively being utilized in a Task. ActiveAgents []*Agent `json:"activeAgents,omitempty" url:"activeAgents,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -131,6 +330,20 @@ func (a *Allocation) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *Allocation) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetActiveAgents sets the ActiveAgents field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Allocation) SetActiveAgents(activeAgents []*Agent) { + a.ActiveAgents = activeAgents + a.require(allocationFieldActiveAgents) +} + func (a *Allocation) UnmarshalJSON(data []byte) error { type unmarshaler Allocation var value unmarshaler @@ -147,6 +360,17 @@ func (a *Allocation) UnmarshalJSON(data []byte) error { return nil } +func (a *Allocation) MarshalJSON() ([]byte, error) { + type embed Allocation + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *Allocation) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -160,6 +384,11 @@ func (a *Allocation) String() string { } // Request to Cancel a Task. +var ( + cancelRequestFieldTaskID = big.NewInt(1 << 0) + cancelRequestFieldAssignee = big.NewInt(1 << 1) +) + type CancelRequest struct { // ID of the Task to cancel. TaskID *string `json:"taskId,omitempty" url:"taskId,omitempty"` @@ -168,6 +397,9 @@ type CancelRequest struct { // especially onBehalfOf assignees. Assignee *Principal `json:"assignee,omitempty" url:"assignee,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -190,6 +422,27 @@ func (c *CancelRequest) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *CancelRequest) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetTaskID sets the TaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CancelRequest) SetTaskID(taskID *string) { + c.TaskID = taskID + c.require(cancelRequestFieldTaskID) +} + +// SetAssignee sets the Assignee field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CancelRequest) SetAssignee(assignee *Principal) { + c.Assignee = assignee + c.require(cancelRequestFieldAssignee) +} + func (c *CancelRequest) UnmarshalJSON(data []byte) error { type unmarshaler CancelRequest var value unmarshaler @@ -206,6 +459,17 @@ func (c *CancelRequest) UnmarshalJSON(data []byte) error { return nil } +func (c *CancelRequest) MarshalJSON() ([]byte, error) { + type embed CancelRequest + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *CancelRequest) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -219,10 +483,17 @@ func (c *CancelRequest) String() string { } // Request to Complete a Task. +var ( + completeRequestFieldTaskID = big.NewInt(1 << 0) +) + type CompleteRequest struct { // ID of the task to complete. TaskID *string `json:"taskId,omitempty" url:"taskId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -238,6 +509,20 @@ func (c *CompleteRequest) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *CompleteRequest) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetTaskID sets the TaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CompleteRequest) SetTaskID(taskID *string) { + c.TaskID = taskID + c.require(completeRequestFieldTaskID) +} + func (c *CompleteRequest) UnmarshalJSON(data []byte) error { type unmarshaler CompleteRequest var value unmarshaler @@ -254,6 +539,17 @@ func (c *CompleteRequest) UnmarshalJSON(data []byte) error { return nil } +func (c *CompleteRequest) MarshalJSON() ([]byte, error) { + type embed CompleteRequest + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *CompleteRequest) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -266,10 +562,17 @@ func (c *CompleteRequest) String() string { return fmt.Sprintf("%#v", c) } +var ( + entityIDsSelectorFieldEntityIDs = big.NewInt(1 << 0) +) + type EntityIDsSelector struct { // Receive tasks as an assignee for one or more of the supplied entity ids. EntityIDs []string `json:"entityIds,omitempty" url:"entityIds,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -285,6 +588,20 @@ func (e *EntityIDsSelector) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EntityIDsSelector) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetEntityIDs sets the EntityIDs field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EntityIDsSelector) SetEntityIDs(entityIDs []string) { + e.EntityIDs = entityIDs + e.require(entityIDsSelectorFieldEntityIDs) +} + func (e *EntityIDsSelector) UnmarshalJSON(data []byte) error { type unmarshaler EntityIDsSelector var value unmarshaler @@ -301,6 +618,17 @@ func (e *EntityIDsSelector) UnmarshalJSON(data []byte) error { return nil } +func (e *EntityIDsSelector) MarshalJSON() ([]byte, error) { + type embed EntityIDsSelector + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *EntityIDsSelector) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -314,10 +642,17 @@ func (e *EntityIDsSelector) String() string { } // Request to execute a Task. +var ( + executeRequestFieldTask = big.NewInt(1 << 0) +) + type ExecuteRequest struct { // Task to execute. Task *Task `json:"task,omitempty" url:"task,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -333,6 +668,20 @@ func (e *ExecuteRequest) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *ExecuteRequest) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetTask sets the Task field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *ExecuteRequest) SetTask(task *Task) { + e.Task = task + e.require(executeRequestFieldTask) +} + func (e *ExecuteRequest) UnmarshalJSON(data []byte) error { type unmarshaler ExecuteRequest var value unmarshaler @@ -349,6 +698,17 @@ func (e *ExecuteRequest) UnmarshalJSON(data []byte) error { return nil } +func (e *ExecuteRequest) MarshalJSON() ([]byte, error) { + type embed ExecuteRequest + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *ExecuteRequest) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -362,10 +722,17 @@ func (e *ExecuteRequest) String() string { } // Owner designates the entity responsible for writes of Task data. +var ( + ownerFieldEntityID = big.NewInt(1 << 0) +) + type Owner struct { // Entity ID of the owner. EntityID *string `json:"entityId,omitempty" url:"entityId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -381,6 +748,20 @@ func (o *Owner) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *Owner) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Owner) SetEntityID(entityID *string) { + o.EntityID = entityID + o.require(ownerFieldEntityID) +} + func (o *Owner) UnmarshalJSON(data []byte) error { type unmarshaler Owner var value unmarshaler @@ -397,6 +778,17 @@ func (o *Owner) UnmarshalJSON(data []byte) error { return nil } +func (o *Owner) MarshalJSON() ([]byte, error) { + type embed Owner + var marshaler = struct { + embed + }{ + embed: embed(*o), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (o *Owner) String() string { if len(o.rawJSON) > 0 { if value, err := internal.StringifyJSON(o.rawJSON); err == nil { @@ -410,6 +802,13 @@ func (o *Owner) String() string { } // A Principal is an entity that has authority over this Task. +var ( + principalFieldSystem = big.NewInt(1 << 0) + principalFieldUser = big.NewInt(1 << 1) + principalFieldTeam = big.NewInt(1 << 2) + principalFieldOnBehalfOf = big.NewInt(1 << 3) +) + type Principal struct { System *System `json:"system,omitempty" url:"system,omitempty"` User *User `json:"user,omitempty" url:"user,omitempty"` @@ -419,6 +818,9 @@ type Principal struct { // Likely only populated once in the nesting (i.e. the "on_behalf_of" Principal would not have another "on_behalf_of" in most cases). OnBehalfOf *Principal `json:"onBehalfOf,omitempty" url:"onBehalfOf,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -455,6 +857,41 @@ func (p *Principal) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *Principal) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetSystem sets the System field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Principal) SetSystem(system *System) { + p.System = system + p.require(principalFieldSystem) +} + +// SetUser sets the User field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Principal) SetUser(user *User) { + p.User = user + p.require(principalFieldUser) +} + +// SetTeam sets the Team field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Principal) SetTeam(team *Team) { + p.Team = team + p.require(principalFieldTeam) +} + +// SetOnBehalfOf sets the OnBehalfOf field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Principal) SetOnBehalfOf(onBehalfOf *Principal) { + p.OnBehalfOf = onBehalfOf + p.require(principalFieldOnBehalfOf) +} + func (p *Principal) UnmarshalJSON(data []byte) error { type unmarshaler Principal var value unmarshaler @@ -471,6 +908,17 @@ func (p *Principal) UnmarshalJSON(data []byte) error { return nil } +func (p *Principal) MarshalJSON() ([]byte, error) { + type embed Principal + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *Principal) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -484,12 +932,20 @@ func (p *Principal) String() string { } // Relations describes the relationships of this Task, such as assignment, or if the Task has any parents. +var ( + relationsFieldAssignee = big.NewInt(1 << 0) + relationsFieldParentTaskID = big.NewInt(1 << 1) +) + type Relations struct { // Who or what, if anyone, this Task is currently assigned to. Assignee *Principal `json:"assignee,omitempty" url:"assignee,omitempty"` // If this Task is a "sub-Task", what is its parent, none if empty. ParentTaskID *string `json:"parentTaskId,omitempty" url:"parentTaskId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -512,6 +968,27 @@ func (r *Relations) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *Relations) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetAssignee sets the Assignee field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relations) SetAssignee(assignee *Principal) { + r.Assignee = assignee + r.require(relationsFieldAssignee) +} + +// SetParentTaskID sets the ParentTaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relations) SetParentTaskID(parentTaskID *string) { + r.ParentTaskID = parentTaskID + r.require(relationsFieldParentTaskID) +} + func (r *Relations) UnmarshalJSON(data []byte) error { type unmarshaler Relations var value unmarshaler @@ -528,6 +1005,17 @@ func (r *Relations) UnmarshalJSON(data []byte) error { return nil } +func (r *Relations) MarshalJSON() ([]byte, error) { + type embed Relations + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *Relations) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -541,10 +1029,17 @@ func (r *Relations) String() string { } // Any metadata associated with the replication of a Task. +var ( + replicationFieldStaleTime = big.NewInt(1 << 0) +) + type Replication struct { // Time by which this Task should be assumed to be stale. StaleTime *time.Time `json:"staleTime,omitempty" url:"staleTime,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -560,6 +1055,20 @@ func (r *Replication) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *Replication) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetStaleTime sets the StaleTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Replication) SetStaleTime(staleTime *time.Time) { + r.StaleTime = staleTime + r.require(replicationFieldStaleTime) +} + func (r *Replication) UnmarshalJSON(data []byte) error { type embed Replication var unmarshaler = struct { @@ -591,7 +1100,8 @@ func (r *Replication) MarshalJSON() ([]byte, error) { embed: embed(*r), StaleTime: internal.NewOptionalDateTime(r.StaleTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) } func (r *Replication) String() string { @@ -607,6 +1117,12 @@ func (r *Replication) String() string { } // System Principal representing some autonomous system. +var ( + systemFieldServiceName = big.NewInt(1 << 0) + systemFieldEntityID = big.NewInt(1 << 1) + systemFieldManagesOwnScheduling = big.NewInt(1 << 2) +) + type System struct { // Name of the service associated with this System. ServiceName *string `json:"serviceName,omitempty" url:"serviceName,omitempty"` @@ -620,6 +1136,9 @@ type System struct { // determine and set this value appropriately. ManagesOwnScheduling *bool `json:"managesOwnScheduling,omitempty" url:"managesOwnScheduling,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -649,6 +1168,34 @@ func (s *System) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *System) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetServiceName sets the ServiceName field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *System) SetServiceName(serviceName *string) { + s.ServiceName = serviceName + s.require(systemFieldServiceName) +} + +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *System) SetEntityID(entityID *string) { + s.EntityID = entityID + s.require(systemFieldEntityID) +} + +// SetManagesOwnScheduling sets the ManagesOwnScheduling field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *System) SetManagesOwnScheduling(managesOwnScheduling *bool) { + s.ManagesOwnScheduling = managesOwnScheduling + s.require(systemFieldManagesOwnScheduling) +} + func (s *System) UnmarshalJSON(data []byte) error { type unmarshaler System var value unmarshaler @@ -665,6 +1212,17 @@ func (s *System) UnmarshalJSON(data []byte) error { return nil } +func (s *System) MarshalJSON() ([]byte, error) { + type embed System + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *System) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -678,6 +1236,24 @@ func (s *System) String() string { } // A Task is something an agent can be asked to do. +var ( + taskFieldVersion = big.NewInt(1 << 0) + taskFieldDisplayName = big.NewInt(1 << 1) + taskFieldSpecification = big.NewInt(1 << 2) + taskFieldCreatedBy = big.NewInt(1 << 3) + taskFieldLastUpdatedBy = big.NewInt(1 << 4) + taskFieldLastUpdateTime = big.NewInt(1 << 5) + taskFieldStatus = big.NewInt(1 << 6) + taskFieldScheduledTime = big.NewInt(1 << 7) + taskFieldRelations = big.NewInt(1 << 8) + taskFieldDescription = big.NewInt(1 << 9) + taskFieldIsExecutedElsewhere = big.NewInt(1 << 10) + taskFieldCreateTime = big.NewInt(1 << 11) + taskFieldReplication = big.NewInt(1 << 12) + taskFieldInitialEntities = big.NewInt(1 << 13) + taskFieldOwner = big.NewInt(1 << 14) +) + type Task struct { // Version of this Task. Version *TaskVersion `json:"version,omitempty" url:"version,omitempty"` @@ -718,6 +1294,9 @@ type Task struct { // for replication of task data to other nodes running Task Manager. Owner *Owner `json:"owner,omitempty" url:"owner,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -831,6 +1410,118 @@ func (t *Task) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *Task) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetVersion sets the Version field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetVersion(version *TaskVersion) { + t.Version = version + t.require(taskFieldVersion) +} + +// SetDisplayName sets the DisplayName field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetDisplayName(displayName *string) { + t.DisplayName = displayName + t.require(taskFieldDisplayName) +} + +// SetSpecification sets the Specification field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetSpecification(specification *GoogleProtobufAny) { + t.Specification = specification + t.require(taskFieldSpecification) +} + +// SetCreatedBy sets the CreatedBy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetCreatedBy(createdBy *Principal) { + t.CreatedBy = createdBy + t.require(taskFieldCreatedBy) +} + +// SetLastUpdatedBy sets the LastUpdatedBy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetLastUpdatedBy(lastUpdatedBy *Principal) { + t.LastUpdatedBy = lastUpdatedBy + t.require(taskFieldLastUpdatedBy) +} + +// SetLastUpdateTime sets the LastUpdateTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetLastUpdateTime(lastUpdateTime *time.Time) { + t.LastUpdateTime = lastUpdateTime + t.require(taskFieldLastUpdateTime) +} + +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetStatus(status *TaskStatus) { + t.Status = status + t.require(taskFieldStatus) +} + +// SetScheduledTime sets the ScheduledTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetScheduledTime(scheduledTime *time.Time) { + t.ScheduledTime = scheduledTime + t.require(taskFieldScheduledTime) +} + +// SetRelations sets the Relations field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetRelations(relations *Relations) { + t.Relations = relations + t.require(taskFieldRelations) +} + +// SetDescription sets the Description field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetDescription(description *string) { + t.Description = description + t.require(taskFieldDescription) +} + +// SetIsExecutedElsewhere sets the IsExecutedElsewhere field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetIsExecutedElsewhere(isExecutedElsewhere *bool) { + t.IsExecutedElsewhere = isExecutedElsewhere + t.require(taskFieldIsExecutedElsewhere) +} + +// SetCreateTime sets the CreateTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetCreateTime(createTime *time.Time) { + t.CreateTime = createTime + t.require(taskFieldCreateTime) +} + +// SetReplication sets the Replication field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetReplication(replication *Replication) { + t.Replication = replication + t.require(taskFieldReplication) +} + +// SetInitialEntities sets the InitialEntities field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetInitialEntities(initialEntities []*TaskEntity) { + t.InitialEntities = initialEntities + t.require(taskFieldInitialEntities) +} + +// SetOwner sets the Owner field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Task) SetOwner(owner *Owner) { + t.Owner = owner + t.require(taskFieldOwner) +} + func (t *Task) UnmarshalJSON(data []byte) error { type embed Task var unmarshaler = struct { @@ -870,7 +1561,8 @@ func (t *Task) MarshalJSON() ([]byte, error) { ScheduledTime: internal.NewOptionalDateTime(t.ScheduledTime), CreateTime: internal.NewOptionalDateTime(t.CreateTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) } func (t *Task) String() string { @@ -886,12 +1578,20 @@ func (t *Task) String() string { } // Wrapper of an entity passed in Tasking, used to hold an additional information, and as a future extension point. +var ( + taskEntityFieldEntity = big.NewInt(1 << 0) + taskEntityFieldSnapshot = big.NewInt(1 << 1) +) + type TaskEntity struct { // The wrapped entity-manager entity. Entity *Entity `json:"entity,omitempty" url:"entity,omitempty"` // Indicates that this entity was generated from a snapshot of a live entity. Snapshot *bool `json:"snapshot,omitempty" url:"snapshot,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -914,6 +1614,27 @@ func (t *TaskEntity) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskEntity) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetEntity sets the Entity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskEntity) SetEntity(entity *Entity) { + t.Entity = entity + t.require(taskEntityFieldEntity) +} + +// SetSnapshot sets the Snapshot field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskEntity) SetSnapshot(snapshot *bool) { + t.Snapshot = snapshot + t.require(taskEntityFieldSnapshot) +} + func (t *TaskEntity) UnmarshalJSON(data []byte) error { type unmarshaler TaskEntity var value unmarshaler @@ -930,6 +1651,17 @@ func (t *TaskEntity) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskEntity) MarshalJSON() ([]byte, error) { + type embed TaskEntity + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskEntity) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -943,6 +1675,12 @@ func (t *TaskEntity) String() string { } // TaskError contains an error code and message typically associated to a Task. +var ( + taskErrorFieldCode = big.NewInt(1 << 0) + taskErrorFieldMessage = big.NewInt(1 << 1) + taskErrorFieldErrorDetails = big.NewInt(1 << 2) +) + type TaskError struct { // Error code for Task error. Code *TaskErrorCode `json:"code,omitempty" url:"code,omitempty"` @@ -951,6 +1689,9 @@ type TaskError struct { // Any additional details regarding this error. ErrorDetails *GoogleProtobufAny `json:"errorDetails,omitempty" url:"errorDetails,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -980,6 +1721,34 @@ func (t *TaskError) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskError) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetCode sets the Code field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskError) SetCode(code *TaskErrorCode) { + t.Code = code + t.require(taskErrorFieldCode) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskError) SetMessage(message *string) { + t.Message = message + t.require(taskErrorFieldMessage) +} + +// SetErrorDetails sets the ErrorDetails field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskError) SetErrorDetails(errorDetails *GoogleProtobufAny) { + t.ErrorDetails = errorDetails + t.require(taskErrorFieldErrorDetails) +} + func (t *TaskError) UnmarshalJSON(data []byte) error { type unmarshaler TaskError var value unmarshaler @@ -996,6 +1765,17 @@ func (t *TaskError) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskError) MarshalJSON() ([]byte, error) { + type embed TaskError + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskError) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -1040,6 +1820,11 @@ func (t TaskErrorCode) Ptr() *TaskErrorCode { return &t } +var ( + taskQueryResultsFieldTasks = big.NewInt(1 << 0) + taskQueryResultsFieldNextPageToken = big.NewInt(1 << 1) +) + type TaskQueryResults struct { Tasks []*Task `json:"tasks,omitempty" url:"tasks,omitempty"` // Incomplete results can be detected by a non-empty nextPageToken field in the query results. In order to retrieve @@ -1048,6 +1833,9 @@ type TaskQueryResults struct { // results are retrieved. NextPageToken *string `json:"nextPageToken,omitempty" url:"nextPageToken,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1070,6 +1858,27 @@ func (t *TaskQueryResults) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskQueryResults) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTasks sets the Tasks field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQueryResults) SetTasks(tasks []*Task) { + t.Tasks = tasks + t.require(taskQueryResultsFieldTasks) +} + +// SetNextPageToken sets the NextPageToken field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQueryResults) SetNextPageToken(nextPageToken *string) { + t.NextPageToken = nextPageToken + t.require(taskQueryResultsFieldNextPageToken) +} + func (t *TaskQueryResults) UnmarshalJSON(data []byte) error { type unmarshaler TaskQueryResults var value unmarshaler @@ -1086,6 +1895,17 @@ func (t *TaskQueryResults) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskQueryResults) MarshalJSON() ([]byte, error) { + type embed TaskQueryResults + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskQueryResults) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -1101,6 +1921,16 @@ func (t *TaskQueryResults) String() string { // TaskStatus is contains information regarding the status of a Task at any given time. Can include related information // // such as any progress towards Task completion, or any associated results if Task completed. +var ( + taskStatusFieldStatus = big.NewInt(1 << 0) + taskStatusFieldTaskError = big.NewInt(1 << 1) + taskStatusFieldProgress = big.NewInt(1 << 2) + taskStatusFieldResult = big.NewInt(1 << 3) + taskStatusFieldStartTime = big.NewInt(1 << 4) + taskStatusFieldEstimate = big.NewInt(1 << 5) + taskStatusFieldAllocation = big.NewInt(1 << 6) +) + type TaskStatus struct { // Status of the Task. Status *TaskStatusStatus `json:"status,omitempty" url:"status,omitempty"` @@ -1117,6 +1947,9 @@ type TaskStatus struct { // Any allocated agents of the Task. Allocation *Allocation `json:"allocation,omitempty" url:"allocation,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1174,6 +2007,62 @@ func (t *TaskStatus) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskStatus) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetStatus(status *TaskStatusStatus) { + t.Status = status + t.require(taskStatusFieldStatus) +} + +// SetTaskError sets the TaskError field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetTaskError(taskError *TaskError) { + t.TaskError = taskError + t.require(taskStatusFieldTaskError) +} + +// SetProgress sets the Progress field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetProgress(progress *GoogleProtobufAny) { + t.Progress = progress + t.require(taskStatusFieldProgress) +} + +// SetResult sets the Result field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetResult(result *GoogleProtobufAny) { + t.Result = result + t.require(taskStatusFieldResult) +} + +// SetStartTime sets the StartTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetStartTime(startTime *time.Time) { + t.StartTime = startTime + t.require(taskStatusFieldStartTime) +} + +// SetEstimate sets the Estimate field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetEstimate(estimate *GoogleProtobufAny) { + t.Estimate = estimate + t.require(taskStatusFieldEstimate) +} + +// SetAllocation sets the Allocation field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatus) SetAllocation(allocation *Allocation) { + t.Allocation = allocation + t.require(taskStatusFieldAllocation) +} + func (t *TaskStatus) UnmarshalJSON(data []byte) error { type embed TaskStatus var unmarshaler = struct { @@ -1205,7 +2094,8 @@ func (t *TaskStatus) MarshalJSON() ([]byte, error) { embed: embed(*t), StartTime: internal.NewOptionalDateTime(t.StartTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) } func (t *TaskStatus) String() string { @@ -1283,6 +2173,12 @@ func (t TaskStatusStatus) Ptr() *TaskStatusStatus { } // Version of a Task. +var ( + taskVersionFieldTaskID = big.NewInt(1 << 0) + taskVersionFieldDefinitionVersion = big.NewInt(1 << 1) + taskVersionFieldStatusVersion = big.NewInt(1 << 2) +) + type TaskVersion struct { // The unique ID for this Task. TaskID *string `json:"taskId,omitempty" url:"taskId,omitempty"` @@ -1291,6 +2187,9 @@ type TaskVersion struct { // Increments on changes to TaskStatus. 0 is unset, starts at 1 on creation. StatusVersion *int `json:"statusVersion,omitempty" url:"statusVersion,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1320,6 +2219,34 @@ func (t *TaskVersion) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskVersion) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTaskID sets the TaskID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskVersion) SetTaskID(taskID *string) { + t.TaskID = taskID + t.require(taskVersionFieldTaskID) +} + +// SetDefinitionVersion sets the DefinitionVersion field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskVersion) SetDefinitionVersion(definitionVersion *int) { + t.DefinitionVersion = definitionVersion + t.require(taskVersionFieldDefinitionVersion) +} + +// SetStatusVersion sets the StatusVersion field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskVersion) SetStatusVersion(statusVersion *int) { + t.StatusVersion = statusVersion + t.require(taskVersionFieldStatusVersion) +} + func (t *TaskVersion) UnmarshalJSON(data []byte) error { type unmarshaler TaskVersion var value unmarshaler @@ -1336,6 +2263,17 @@ func (t *TaskVersion) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskVersion) MarshalJSON() ([]byte, error) { + type embed TaskVersion + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskVersion) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -1349,10 +2287,17 @@ func (t *TaskVersion) String() string { } // A User Principal representing a human. +var ( + userFieldUserID = big.NewInt(1 << 0) +) + type User struct { // The User ID associated with this User. UserID *string `json:"userId,omitempty" url:"userId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1368,6 +2313,20 @@ func (u *User) GetExtraProperties() map[string]interface{} { return u.extraProperties } +func (u *User) require(field *big.Int) { + if u.explicitFields == nil { + u.explicitFields = big.NewInt(0) + } + u.explicitFields.Or(u.explicitFields, field) +} + +// SetUserID sets the UserID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (u *User) SetUserID(userID *string) { + u.UserID = userID + u.require(userFieldUserID) +} + func (u *User) UnmarshalJSON(data []byte) error { type unmarshaler User var value unmarshaler @@ -1384,6 +2343,17 @@ func (u *User) UnmarshalJSON(data []byte) error { return nil } +func (u *User) MarshalJSON() ([]byte, error) { + type embed User + var marshaler = struct { + embed + }{ + embed: embed(*u), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, u.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (u *User) String() string { if len(u.rawJSON) > 0 { if value, err := internal.StringifyJSON(u.rawJSON); err == nil { @@ -1396,10 +2366,17 @@ func (u *User) String() string { return fmt.Sprintf("%#v", u) } +var ( + taskQueryStatusFilterFieldStatus = big.NewInt(1 << 0) +) + type TaskQueryStatusFilter struct { // Status of the Task to filter by, inclusive. Status *TaskQueryStatusFilterStatus `json:"status,omitempty" url:"status,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1415,6 +2392,20 @@ func (t *TaskQueryStatusFilter) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskQueryStatusFilter) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQueryStatusFilter) SetStatus(status *TaskQueryStatusFilterStatus) { + t.Status = status + t.require(taskQueryStatusFilterFieldStatus) +} + func (t *TaskQueryStatusFilter) UnmarshalJSON(data []byte) error { type unmarshaler TaskQueryStatusFilter var value unmarshaler @@ -1431,6 +2422,17 @@ func (t *TaskQueryStatusFilter) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskQueryStatusFilter) MarshalJSON() ([]byte, error) { + type embed TaskQueryStatusFilter + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskQueryStatusFilter) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -1506,12 +2508,20 @@ func (t TaskQueryStatusFilterStatus) Ptr() *TaskQueryStatusFilterStatus { } // If provided, only provides Tasks updated within the time range. +var ( + taskQueryUpdateTimeRangeFieldStartTime = big.NewInt(1 << 0) + taskQueryUpdateTimeRangeFieldEndTime = big.NewInt(1 << 1) +) + type TaskQueryUpdateTimeRange struct { // If provided, returns Tasks only updated after this time. StartTime *string `json:"startTime,omitempty" url:"startTime,omitempty"` // If provided, returns Tasks only updated before this time. EndTime *string `json:"endTime,omitempty" url:"endTime,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1534,6 +2544,27 @@ func (t *TaskQueryUpdateTimeRange) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskQueryUpdateTimeRange) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetStartTime sets the StartTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQueryUpdateTimeRange) SetStartTime(startTime *string) { + t.StartTime = startTime + t.require(taskQueryUpdateTimeRangeFieldStartTime) +} + +// SetEndTime sets the EndTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskQueryUpdateTimeRange) SetEndTime(endTime *string) { + t.EndTime = endTime + t.require(taskQueryUpdateTimeRangeFieldEndTime) +} + func (t *TaskQueryUpdateTimeRange) UnmarshalJSON(data []byte) error { type unmarshaler TaskQueryUpdateTimeRange var value unmarshaler @@ -1550,6 +2581,17 @@ func (t *TaskQueryUpdateTimeRange) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskQueryUpdateTimeRange) MarshalJSON() ([]byte, error) { + type embed TaskQueryUpdateTimeRange + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskQueryUpdateTimeRange) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -1562,6 +2604,12 @@ func (t *TaskQueryUpdateTimeRange) String() string { return fmt.Sprintf("%#v", t) } +var ( + taskStatusUpdateFieldStatusVersion = big.NewInt(1 << 0) + taskStatusUpdateFieldNewStatus = big.NewInt(1 << 1) + taskStatusUpdateFieldAuthor = big.NewInt(1 << 2) +) + type TaskStatusUpdate struct { // The status version of the task to update. This version number increments to indicate the task's // current stage in its status lifecycle. Specifically, whenever a task's status updates, the status @@ -1571,4 +2619,35 @@ type TaskStatusUpdate struct { // The new status of the task. NewStatus *TaskStatus `json:"newStatus,omitempty" url:"-"` Author *Principal `json:"author,omitempty" url:"-"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` +} + +func (t *TaskStatusUpdate) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetStatusVersion sets the StatusVersion field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatusUpdate) SetStatusVersion(statusVersion *int) { + t.StatusVersion = statusVersion + t.require(taskStatusUpdateFieldStatusVersion) +} + +// SetNewStatus sets the NewStatus field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatusUpdate) SetNewStatus(newStatus *TaskStatus) { + t.NewStatus = newStatus + t.require(taskStatusUpdateFieldNewStatus) +} + +// SetAuthor sets the Author field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskStatusUpdate) SetAuthor(author *Principal) { + t.Author = author + t.require(taskStatusUpdateFieldAuthor) } diff --git a/tasks/client.go b/tasks/client.go index 10ce67b..6b0589c 100644 --- a/tasks/client.go +++ b/tasks/client.go @@ -4,25 +4,24 @@ package tasks import ( context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" - http "net/http" ) type Client struct { WithRawResponse *RawClient + options *core.RequestOptions baseURL string caller *internal.Caller - header http.Header } -func NewClient(opts ...option.RequestOption) *Client { - options := core.NewRequestOptions(opts...) +func NewClient(options *core.RequestOptions) *Client { return &Client{ WithRawResponse: NewRawClient(options), + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -30,7 +29,6 @@ func NewClient(opts ...option.RequestOption) *Client { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } @@ -38,9 +36,9 @@ func NewClient(opts ...option.RequestOption) *Client { // be asynchronously updated by their destined agent. func (c *Client) CreateTask( ctx context.Context, - request *v2.TaskCreation, + request *Lattice.TaskCreation, opts ...option.RequestOption, -) (*v2.Task, error) { +) (*Lattice.Task, error) { response, err := c.WithRawResponse.CreateTask( ctx, request, @@ -57,7 +55,7 @@ func (c *Client) GetTask( // ID of task to return taskID string, opts ...option.RequestOption, -) (*v2.Task, error) { +) (*Lattice.Task, error) { response, err := c.WithRawResponse.GetTask( ctx, taskID, @@ -74,9 +72,9 @@ func (c *Client) UpdateTaskStatus( ctx context.Context, // ID of task to update status of taskID string, - request *v2.TaskStatusUpdate, + request *Lattice.TaskStatusUpdate, opts ...option.RequestOption, -) (*v2.Task, error) { +) (*Lattice.Task, error) { response, err := c.WithRawResponse.UpdateTaskStatus( ctx, taskID, @@ -92,9 +90,9 @@ func (c *Client) UpdateTaskStatus( // Query for tasks by a specified search criteria. func (c *Client) QueryTasks( ctx context.Context, - request *v2.TaskQuery, + request *Lattice.TaskQuery, opts ...option.RequestOption, -) (*v2.TaskQueryResults, error) { +) (*Lattice.TaskQueryResults, error) { response, err := c.WithRawResponse.QueryTasks( ctx, request, @@ -111,9 +109,9 @@ func (c *Client) QueryTasks( // period you will be expected to reinitiate a new request. func (c *Client) ListenAsAgent( ctx context.Context, - request *v2.AgentListener, + request *Lattice.AgentListener, opts ...option.RequestOption, -) (*v2.AgentRequest, error) { +) (*Lattice.AgentRequest, error) { response, err := c.WithRawResponse.ListenAsAgent( ctx, request, diff --git a/tasks/raw_client.go b/tasks/raw_client.go index 75d15f8..dcd38dd 100644 --- a/tasks/raw_client.go +++ b/tasks/raw_client.go @@ -4,7 +4,7 @@ package tasks import ( context "context" - v2 "github.com/anduril/lattice-sdk-go/v2" + Lattice "github.com/anduril/lattice-sdk-go/v2" core "github.com/anduril/lattice-sdk-go/v2/core" internal "github.com/anduril/lattice-sdk-go/v2/internal" option "github.com/anduril/lattice-sdk-go/v2/option" @@ -14,11 +14,12 @@ import ( type RawClient struct { baseURL string caller *internal.Caller - header http.Header + options *core.RequestOptions } func NewRawClient(options *core.RequestOptions) *RawClient { return &RawClient{ + options: options, baseURL: options.BaseURL, caller: internal.NewCaller( &internal.CallerParams{ @@ -26,15 +27,14 @@ func NewRawClient(options *core.RequestOptions) *RawClient { MaxAttempts: options.MaxAttempts, }, ), - header: options.ToHeader(), } } func (r *RawClient) CreateTask( ctx context.Context, - request *v2.TaskCreation, + request *Lattice.TaskCreation, opts ...option.RequestOption, -) (*core.Response[*v2.Task], error) { +) (*core.Response[*Lattice.Task], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -43,23 +43,11 @@ func (r *RawClient) CreateTask( ) endpointURL := baseURL + "/api/v1/tasks" headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - } - var response *v2.Task + var response *Lattice.Task raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -72,13 +60,13 @@ func (r *RawClient) CreateTask( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Task]{ + return &core.Response[*Lattice.Task]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -90,7 +78,7 @@ func (r *RawClient) GetTask( // ID of task to return taskID string, opts ...option.RequestOption, -) (*core.Response[*v2.Task], error) { +) (*core.Response[*Lattice.Task], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -102,27 +90,10 @@ func (r *RawClient) GetTask( taskID, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.Task + var response *Lattice.Task raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -134,13 +105,13 @@ func (r *RawClient) GetTask( QueryParameters: options.QueryParameters, Client: options.HTTPClient, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Task]{ + return &core.Response[*Lattice.Task]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -151,9 +122,9 @@ func (r *RawClient) UpdateTaskStatus( ctx context.Context, // ID of task to update status of taskID string, - request *v2.TaskStatusUpdate, + request *Lattice.TaskStatusUpdate, opts ...option.RequestOption, -) (*core.Response[*v2.Task], error) { +) (*core.Response[*Lattice.Task], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -165,28 +136,11 @@ func (r *RawClient) UpdateTaskStatus( taskID, ) headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.Task + var response *Lattice.Task raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -199,13 +153,13 @@ func (r *RawClient) UpdateTaskStatus( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.Task]{ + return &core.Response[*Lattice.Task]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -214,9 +168,9 @@ func (r *RawClient) UpdateTaskStatus( func (r *RawClient) QueryTasks( ctx context.Context, - request *v2.TaskQuery, + request *Lattice.TaskQuery, opts ...option.RequestOption, -) (*core.Response[*v2.TaskQueryResults], error) { +) (*core.Response[*Lattice.TaskQueryResults], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -225,28 +179,11 @@ func (r *RawClient) QueryTasks( ) endpointURL := baseURL + "/api/v1/tasks/query" headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &v2.NotFoundError{ - APIError: apiError, - } - }, - } - var response *v2.TaskQueryResults + var response *Lattice.TaskQueryResults raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -259,13 +196,13 @@ func (r *RawClient) QueryTasks( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.TaskQueryResults]{ + return &core.Response[*Lattice.TaskQueryResults]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, @@ -274,9 +211,9 @@ func (r *RawClient) QueryTasks( func (r *RawClient) ListenAsAgent( ctx context.Context, - request *v2.AgentListener, + request *Lattice.AgentListener, opts ...option.RequestOption, -) (*core.Response[*v2.AgentRequest], error) { +) (*core.Response[*Lattice.AgentRequest], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -285,23 +222,11 @@ func (r *RawClient) ListenAsAgent( ) endpointURL := baseURL + "/api/v1/agent/listen" headers := internal.MergeHeaders( - r.header.Clone(), + r.options.ToHeader(), options.ToHeader(), ) headers.Add("Content-Type", "application/json") - errorCodes := internal.ErrorCodes{ - 400: func(apiError *core.APIError) error { - return &v2.BadRequestError{ - APIError: apiError, - } - }, - 401: func(apiError *core.APIError) error { - return &v2.UnauthorizedError{ - APIError: apiError, - } - }, - } - var response *v2.AgentRequest + var response *Lattice.AgentRequest raw, err := r.caller.Call( ctx, &internal.CallParams{ @@ -314,13 +239,13 @@ func (r *RawClient) ListenAsAgent( Client: options.HTTPClient, Request: request, Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), + ErrorDecoder: internal.NewErrorDecoder(Lattice.ErrorCodes), }, ) if err != nil { return nil, err } - return &core.Response[*v2.AgentRequest]{ + return &core.Response[*Lattice.AgentRequest]{ StatusCode: raw.StatusCode, Header: raw.Header, Body: response, diff --git a/tasks/tasks_test/tasks_test.go b/tasks/tasks_test/tasks_test.go new file mode 100644 index 0000000..cc110a8 --- /dev/null +++ b/tasks/tasks_test/tasks_test.go @@ -0,0 +1,282 @@ +// Code generated by Fern. DO NOT EDIT. + +package tasks_test + +import ( + context "context" + fmt "fmt" + v2 "github.com/anduril/lattice-sdk-go/v2" + client "github.com/anduril/lattice-sdk-go/v2/client" + option "github.com/anduril/lattice-sdk-go/v2/option" + require "github.com/stretchr/testify/require" + gowiremock "github.com/wiremock/go-wiremock" + wiremocktestcontainersgo "github.com/wiremock/wiremock-testcontainers-go" + http "net/http" + os "os" + testing "testing" +) + +// TestMain sets up shared test fixtures for all tests in this package// Global test fixtures +var ( + WireMockContainer *wiremocktestcontainersgo.WireMockContainer + WireMockBaseURL string + WireMockClient *gowiremock.Client +) + +// TestMain sets up shared test fixtures for all tests in this package +func TestMain(m *testing.M) { + // Setup shared WireMock container + ctx := context.Background() + container, err := wiremocktestcontainersgo.RunContainerAndStopOnCleanup( + ctx, + &testing.T{}, + wiremocktestcontainersgo.WithImage("docker.io/wiremock/wiremock:3.9.1"), + ) + if err != nil { + fmt.Printf("Failed to start WireMock container: %v\n", err) + os.Exit(1) + } + + // Store global references + WireMockContainer = container + + // Try to get the base URL using the standard method first + baseURL, err := container.Endpoint(ctx, "") + if err == nil { + // Standard method worked (running outside DinD) + // This uses the mapped port (e.g., localhost:59553) + WireMockBaseURL = "http://" + baseURL + WireMockClient = container.Client + } else { + // Standard method failed, use internal IP fallback (DinD environment) + fmt.Printf("Standard endpoint resolution failed, using internal IP fallback: %v\n", err) + + inspect, err := container.Inspect(ctx) + if err != nil { + fmt.Printf("Failed to inspect WireMock container: %v\n", err) + os.Exit(1) + } + + // Find the IP address from the container's networks + var containerIP string + for _, network := range inspect.NetworkSettings.Networks { + if network.IPAddress != "" { + containerIP = network.IPAddress + break + } + } + + if containerIP == "" { + fmt.Printf("Failed to get WireMock container IP address\n") + os.Exit(1) + } + + // In DinD, use the internal port directly (8080 for WireMock HTTP) + // Don't use the mapped port since it doesn't exist in this environment + WireMockBaseURL = fmt.Sprintf("http://%s:8080", containerIP) + + // The container.Client was created with a bad URL, so we need a new one + WireMockClient = gowiremock.NewClient(WireMockBaseURL) + } + + fmt.Printf("WireMock available at: %s\n", WireMockBaseURL) + + // Run all tests + code := m.Run() + + // Cleanup + if WireMockContainer != nil { + WireMockContainer.Terminate(ctx) + } + + // Exit with the same code as the tests + os.Exit(code) +} + +func TestTasksCreateTaskWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Post(gowiremock.URLPathTemplate("/api/v1/tasks")).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"version": map[string]interface{}{"taskId": "taskId", "definitionVersion": 1, "statusVersion": 1}, "displayName": "displayName", "specification": map[string]interface{}{"@type": "@type"}, "createdBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdatedBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdateTime": "2024-01-15T09:30:00Z", "status": map[string]interface{}{"status": "STATUS_INVALID", "taskError": map[string]interface{}{"code": "ERROR_CODE_INVALID", "message": "message"}, "progress": map[string]interface{}{"@type": "@type"}, "result": map[string]interface{}{"@type": "@type"}, "startTime": "2024-01-15T09:30:00Z", "estimate": map[string]interface{}{"@type": "@type"}, "allocation": map[string]interface{}{"activeAgents": []interface{}{map[string]interface{}{}}}}, "scheduledTime": "2024-01-15T09:30:00Z", "relations": map[string]interface{}{"parentTaskId": "parentTaskId"}, "description": "description", "isExecutedElsewhere": true, "createTime": "2024-01-15T09:30:00Z", "replication": map[string]interface{}{"staleTime": "2024-01-15T09:30:00Z"}, "initialEntities": []interface{}{map[string]interface{}{"snapshot": true}}, "owner": map[string]interface{}{"entityId": "entityId"}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.TaskCreation{} + _, invocationErr := client.Tasks.CreateTask( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestTasksGetTaskWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Get(gowiremock.URLPathTemplate("/api/v1/tasks/{taskId}")).WithPathParam( + "taskId", + gowiremock.Matching("taskId"), + ).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"version": map[string]interface{}{"taskId": "taskId", "definitionVersion": 1, "statusVersion": 1}, "displayName": "displayName", "specification": map[string]interface{}{"@type": "@type"}, "createdBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdatedBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdateTime": "2024-01-15T09:30:00Z", "status": map[string]interface{}{"status": "STATUS_INVALID", "taskError": map[string]interface{}{"code": "ERROR_CODE_INVALID", "message": "message"}, "progress": map[string]interface{}{"@type": "@type"}, "result": map[string]interface{}{"@type": "@type"}, "startTime": "2024-01-15T09:30:00Z", "estimate": map[string]interface{}{"@type": "@type"}, "allocation": map[string]interface{}{"activeAgents": []interface{}{map[string]interface{}{}}}}, "scheduledTime": "2024-01-15T09:30:00Z", "relations": map[string]interface{}{"parentTaskId": "parentTaskId"}, "description": "description", "isExecutedElsewhere": true, "createTime": "2024-01-15T09:30:00Z", "replication": map[string]interface{}{"staleTime": "2024-01-15T09:30:00Z"}, "initialEntities": []interface{}{map[string]interface{}{"snapshot": true}}, "owner": map[string]interface{}{"entityId": "entityId"}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + _, invocationErr := client.Tasks.GetTask( + context.TODO(), + "taskId", + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestTasksUpdateTaskStatusWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Put(gowiremock.URLPathTemplate("/api/v1/tasks/{taskId}/status")).WithPathParam( + "taskId", + gowiremock.Matching("taskId"), + ).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"version": map[string]interface{}{"taskId": "taskId", "definitionVersion": 1, "statusVersion": 1}, "displayName": "displayName", "specification": map[string]interface{}{"@type": "@type"}, "createdBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdatedBy": map[string]interface{}{"system": map[string]interface{}{"serviceName": "serviceName", "entityId": "entityId", "managesOwnScheduling": true}, "user": map[string]interface{}{"userId": "userId"}, "team": map[string]interface{}{"entityId": "entityId", "members": []interface{}{map[string]interface{}{}}}}, "lastUpdateTime": "2024-01-15T09:30:00Z", "status": map[string]interface{}{"status": "STATUS_INVALID", "taskError": map[string]interface{}{"code": "ERROR_CODE_INVALID", "message": "message"}, "progress": map[string]interface{}{"@type": "@type"}, "result": map[string]interface{}{"@type": "@type"}, "startTime": "2024-01-15T09:30:00Z", "estimate": map[string]interface{}{"@type": "@type"}, "allocation": map[string]interface{}{"activeAgents": []interface{}{map[string]interface{}{}}}}, "scheduledTime": "2024-01-15T09:30:00Z", "relations": map[string]interface{}{"parentTaskId": "parentTaskId"}, "description": "description", "isExecutedElsewhere": true, "createTime": "2024-01-15T09:30:00Z", "replication": map[string]interface{}{"staleTime": "2024-01-15T09:30:00Z"}, "initialEntities": []interface{}{map[string]interface{}{"snapshot": true}}, "owner": map[string]interface{}{"entityId": "entityId"}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.TaskStatusUpdate{} + _, invocationErr := client.Tasks.UpdateTaskStatus( + context.TODO(), + "taskId", + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestTasksQueryTasksWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Post(gowiremock.URLPathTemplate("/api/v1/tasks/query")).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"tasks": []interface{}{map[string]interface{}{"displayName": "displayName", "lastUpdateTime": "2024-01-15T09:30:00Z", "scheduledTime": "2024-01-15T09:30:00Z", "description": "description", "isExecutedElsewhere": true, "createTime": "2024-01-15T09:30:00Z", "initialEntities": []interface{}{map[string]interface{}{}}}}, "nextPageToken": "nextPageToken"}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.TaskQuery{} + _, invocationErr := client.Tasks.QueryTasks( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} + +func TestTasksListenAsAgentWithWireMock( + t *testing.T, +) { + // wiremock client and server initialized in shared main_test.go + defer WireMockClient.Reset() + stub := gowiremock.Post(gowiremock.URLPathTemplate("/api/v1/agent/listen")).WithBodyPattern(gowiremock.MatchesJsonSchema(`{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "required": [], + "properties": { + + }, + "additionalProperties": true + }`, "V202012")).WillReturnResponse( + gowiremock.NewResponse().WithJSONBody( + map[string]interface{}{"executeRequest": map[string]interface{}{"task": map[string]interface{}{"displayName": "displayName", "lastUpdateTime": "2024-01-15T09:30:00Z", "scheduledTime": "2024-01-15T09:30:00Z", "description": "description", "isExecutedElsewhere": true, "createTime": "2024-01-15T09:30:00Z", "initialEntities": []interface{}{map[string]interface{}{}}}}, "cancelRequest": map[string]interface{}{"taskId": "taskId"}, "completeRequest": map[string]interface{}{"taskId": "taskId"}}, + ).WithStatus(http.StatusOK), + ) + err := WireMockClient.StubFor(stub) + require.NoError(t, err, "Failed to create WireMock stub") + + client := client.NewClient( + option.WithBaseURL( + WireMockBaseURL, + ), + ) + request := &Lattice.AgentListener{} + _, invocationErr := client.Tasks.ListenAsAgent( + context.TODO(), + request, + ) + + require.NoError(t, invocationErr, "Client method call should succeed") + ok, countErr := WireMockClient.Verify(stub.Request(), 1) + require.NoError(t, countErr, "Failed to verify WireMock request was matched") + require.True(t, ok, "WireMock request was not matched") +} diff --git a/types.go b/types.go index a020796..65c9668 100644 --- a/types.go +++ b/types.go @@ -6,9 +6,15 @@ import ( json "encoding/json" fmt "fmt" internal "github.com/anduril/lattice-sdk-go/v2/internal" + big "math/big" time "time" ) +var ( + acmDetailsFieldAcmType = big.NewInt(1 << 0) + acmDetailsFieldAcmDescription = big.NewInt(1 << 1) +) + type AcmDetails struct { AcmType *AcmDetailsAcmType `json:"acmType,omitempty" url:"acmType,omitempty"` // Used for loosely typed associations, such as assignment to a specific fires unit. @@ -16,6 +22,9 @@ type AcmDetails struct { // Limit to 150 characters. AcmDescription *string `json:"acmDescription,omitempty" url:"acmDescription,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -38,6 +47,27 @@ func (a *AcmDetails) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *AcmDetails) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetAcmType sets the AcmType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AcmDetails) SetAcmType(acmType *AcmDetailsAcmType) { + a.AcmType = acmType + a.require(acmDetailsFieldAcmType) +} + +// SetAcmDescription sets the AcmDescription field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AcmDetails) SetAcmDescription(acmDescription *string) { + a.AcmDescription = acmDescription + a.require(acmDetailsFieldAcmDescription) +} + func (a *AcmDetails) UnmarshalJSON(data []byte) error { type unmarshaler AcmDetails var value unmarshaler @@ -54,6 +84,17 @@ func (a *AcmDetails) UnmarshalJSON(data []byte) error { return nil } +func (a *AcmDetails) MarshalJSON() ([]byte, error) { + type embed AcmDetails + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *AcmDetails) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -92,6 +133,10 @@ func (a AcmDetailsAcmType) Ptr() *AcmDetailsAcmType { // // from sensor to target, indicating track(s) currently prioritized by a robot. type ActiveTarget struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -100,6 +145,13 @@ func (a *ActiveTarget) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *ActiveTarget) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + func (a *ActiveTarget) UnmarshalJSON(data []byte) error { type unmarshaler ActiveTarget var value unmarshaler @@ -116,6 +168,17 @@ func (a *ActiveTarget) UnmarshalJSON(data []byte) error { return nil } +func (a *ActiveTarget) MarshalJSON() ([]byte, error) { + type embed ActiveTarget + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *ActiveTarget) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -129,10 +192,17 @@ func (a *ActiveTarget) String() string { } // Represents an Agent in the COP. +var ( + agentFieldEntityID = big.NewInt(1 << 0) +) + type Agent struct { // Entity ID of the agent. EntityID *string `json:"entityId,omitempty" url:"entityId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -148,6 +218,20 @@ func (a *Agent) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *Agent) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Agent) SetEntityID(entityID *string) { + a.EntityID = entityID + a.require(agentFieldEntityID) +} + func (a *Agent) UnmarshalJSON(data []byte) error { type unmarshaler Agent var value unmarshaler @@ -164,6 +248,17 @@ func (a *Agent) UnmarshalJSON(data []byte) error { return nil } +func (a *Agent) MarshalJSON() ([]byte, error) { + type embed Agent + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *Agent) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -179,6 +274,14 @@ func (a *Agent) String() string { // An alert informs operators of critical events related to system performance and mission // // execution. An alert is produced as a result of one or more alert conditions. +var ( + alertFieldAlertCode = big.NewInt(1 << 0) + alertFieldDescription = big.NewInt(1 << 1) + alertFieldLevel = big.NewInt(1 << 2) + alertFieldActivatedTime = big.NewInt(1 << 3) + alertFieldActiveConditions = big.NewInt(1 << 4) +) + type Alert struct { // Short, machine-readable code that describes this alert. This code is intended to provide systems off-asset // @@ -196,6 +299,9 @@ type Alert struct { // Set of conditions which have activated this alert. ActiveConditions []*AlertCondition `json:"activeConditions,omitempty" url:"activeConditions,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -239,6 +345,48 @@ func (a *Alert) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *Alert) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetAlertCode sets the AlertCode field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Alert) SetAlertCode(alertCode *string) { + a.AlertCode = alertCode + a.require(alertFieldAlertCode) +} + +// SetDescription sets the Description field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Alert) SetDescription(description *string) { + a.Description = description + a.require(alertFieldDescription) +} + +// SetLevel sets the Level field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Alert) SetLevel(level *AlertLevel) { + a.Level = level + a.require(alertFieldLevel) +} + +// SetActivatedTime sets the ActivatedTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Alert) SetActivatedTime(activatedTime *time.Time) { + a.ActivatedTime = activatedTime + a.require(alertFieldActivatedTime) +} + +// SetActiveConditions sets the ActiveConditions field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Alert) SetActiveConditions(activeConditions []*AlertCondition) { + a.ActiveConditions = activeConditions + a.require(alertFieldActiveConditions) +} + func (a *Alert) UnmarshalJSON(data []byte) error { type embed Alert var unmarshaler = struct { @@ -270,7 +418,8 @@ func (a *Alert) MarshalJSON() ([]byte, error) { embed: embed(*a), ActivatedTime: internal.NewOptionalDateTime(a.ActivatedTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) } func (a *Alert) String() string { @@ -286,6 +435,11 @@ func (a *Alert) String() string { } // A condition which may trigger an alert. +var ( + alertConditionFieldConditionCode = big.NewInt(1 << 0) + alertConditionFieldDescription = big.NewInt(1 << 1) +) + type AlertCondition struct { // Short, machine-readable code that describes this condition. This code is intended to provide systems off-asset // @@ -297,6 +451,9 @@ type AlertCondition struct { // provides no dynamic substitutions, then prefer lookup based on condition_code. Description *string `json:"description,omitempty" url:"description,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -319,6 +476,27 @@ func (a *AlertCondition) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *AlertCondition) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetConditionCode sets the ConditionCode field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AlertCondition) SetConditionCode(conditionCode *string) { + a.ConditionCode = conditionCode + a.require(alertConditionFieldConditionCode) +} + +// SetDescription sets the Description field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AlertCondition) SetDescription(description *string) { + a.Description = description + a.require(alertConditionFieldDescription) +} + func (a *AlertCondition) UnmarshalJSON(data []byte) error { type unmarshaler AlertCondition var value unmarshaler @@ -335,6 +513,17 @@ func (a *AlertCondition) UnmarshalJSON(data []byte) error { return nil } +func (a *AlertCondition) MarshalJSON() ([]byte, error) { + type embed AlertCondition + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *AlertCondition) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -377,11 +566,19 @@ func (a AlertLevel) Ptr() *AlertLevel { } // Available for any Entities with alternate ids in other systems. +var ( + aliasesFieldAlternateIDs = big.NewInt(1 << 0) + aliasesFieldName = big.NewInt(1 << 1) +) + type Aliases struct { AlternateIDs []*AlternateID `json:"alternateIds,omitempty" url:"alternateIds,omitempty"` // The best available version of the entity's display name. Name *string `json:"name,omitempty" url:"name,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -404,6 +601,27 @@ func (a *Aliases) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *Aliases) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetAlternateIDs sets the AlternateIDs field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Aliases) SetAlternateIDs(alternateIDs []*AlternateID) { + a.AlternateIDs = alternateIDs + a.require(aliasesFieldAlternateIDs) +} + +// SetName sets the Name field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *Aliases) SetName(name *string) { + a.Name = name + a.require(aliasesFieldName) +} + func (a *Aliases) UnmarshalJSON(data []byte) error { type unmarshaler Aliases var value unmarshaler @@ -420,6 +638,17 @@ func (a *Aliases) UnmarshalJSON(data []byte) error { return nil } +func (a *Aliases) MarshalJSON() ([]byte, error) { + type embed Aliases + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *Aliases) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -433,10 +662,18 @@ func (a *Aliases) String() string { } // An alternate id for an Entity. +var ( + alternateIDFieldID = big.NewInt(1 << 0) + alternateIDFieldType = big.NewInt(1 << 1) +) + type AlternateID struct { ID *string `json:"id,omitempty" url:"id,omitempty"` Type *AlternateIDType `json:"type,omitempty" url:"type,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -459,6 +696,27 @@ func (a *AlternateID) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *AlternateID) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetID sets the ID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AlternateID) SetID(id *string) { + a.ID = id + a.require(alternateIDFieldID) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AlternateID) SetType(type_ *AlternateIDType) { + a.Type = type_ + a.require(alternateIDFieldType) +} + func (a *AlternateID) UnmarshalJSON(data []byte) error { type unmarshaler AlternateID var value unmarshaler @@ -475,6 +733,17 @@ func (a *AlternateID) UnmarshalJSON(data []byte) error { return nil } +func (a *AlternateID) MarshalJSON() ([]byte, error) { + type embed AlternateID + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *AlternateID) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -573,6 +842,11 @@ func (a AlternateIDType) Ptr() *AlternateIDType { } // The direction from which the signal is received +var ( + angleOfArrivalFieldRelativePose = big.NewInt(1 << 0) + angleOfArrivalFieldBearingElevationCovarianceRad2 = big.NewInt(1 << 1) +) + type AngleOfArrival struct { // Origin (LLA) and attitude (relative to ENU) of a ray pointing towards the detection. The attitude represents a // @@ -586,6 +860,9 @@ type AngleOfArrival struct { // myy = elevation variance in rad^2 BearingElevationCovarianceRad2 *TMat2 `json:"bearingElevationCovarianceRad2,omitempty" url:"bearingElevationCovarianceRad2,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -608,6 +885,27 @@ func (a *AngleOfArrival) GetExtraProperties() map[string]interface{} { return a.extraProperties } +func (a *AngleOfArrival) require(field *big.Int) { + if a.explicitFields == nil { + a.explicitFields = big.NewInt(0) + } + a.explicitFields.Or(a.explicitFields, field) +} + +// SetRelativePose sets the RelativePose field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AngleOfArrival) SetRelativePose(relativePose *Pose) { + a.RelativePose = relativePose + a.require(angleOfArrivalFieldRelativePose) +} + +// SetBearingElevationCovarianceRad2 sets the BearingElevationCovarianceRad2 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (a *AngleOfArrival) SetBearingElevationCovarianceRad2(bearingElevationCovarianceRad2 *TMat2) { + a.BearingElevationCovarianceRad2 = bearingElevationCovarianceRad2 + a.require(angleOfArrivalFieldBearingElevationCovarianceRad2) +} + func (a *AngleOfArrival) UnmarshalJSON(data []byte) error { type unmarshaler AngleOfArrival var value unmarshaler @@ -624,6 +922,17 @@ func (a *AngleOfArrival) UnmarshalJSON(data []byte) error { return nil } +func (a *AngleOfArrival) MarshalJSON() ([]byte, error) { + type embed AngleOfArrival + var marshaler = struct { + embed + }{ + embed: embed(*a), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, a.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (a *AngleOfArrival) String() string { if len(a.rawJSON) > 0 { if value, err := internal.StringifyJSON(a.rawJSON); err == nil { @@ -637,9 +946,16 @@ func (a *AngleOfArrival) String() string { } // Describes the bandwidth of a signal +var ( + bandwidthFieldBandwidthHz = big.NewInt(1 << 0) +) + type Bandwidth struct { BandwidthHz *float64 `json:"bandwidthHz,omitempty" url:"bandwidthHz,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -655,6 +971,20 @@ func (b *Bandwidth) GetExtraProperties() map[string]interface{} { return b.extraProperties } +func (b *Bandwidth) require(field *big.Int) { + if b.explicitFields == nil { + b.explicitFields = big.NewInt(0) + } + b.explicitFields.Or(b.explicitFields, field) +} + +// SetBandwidthHz sets the BandwidthHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (b *Bandwidth) SetBandwidthHz(bandwidthHz *float64) { + b.BandwidthHz = bandwidthHz + b.require(bandwidthFieldBandwidthHz) +} + func (b *Bandwidth) UnmarshalJSON(data []byte) error { type unmarshaler Bandwidth var value unmarshaler @@ -671,6 +1001,17 @@ func (b *Bandwidth) UnmarshalJSON(data []byte) error { return nil } +func (b *Bandwidth) MarshalJSON() ([]byte, error) { + type embed Bandwidth + var marshaler = struct { + embed + }{ + embed: embed(*b), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, b.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (b *Bandwidth) String() string { if len(b.rawJSON) > 0 { if value, err := internal.StringifyJSON(b.rawJSON); err == nil { @@ -684,10 +1025,18 @@ func (b *Bandwidth) String() string { } // A component that describes the min and max bandwidths of a sensor +var ( + bandwidthRangeFieldMinimumBandwidth = big.NewInt(1 << 0) + bandwidthRangeFieldMaximumBandwidth = big.NewInt(1 << 1) +) + type BandwidthRange struct { MinimumBandwidth *Bandwidth `json:"minimumBandwidth,omitempty" url:"minimumBandwidth,omitempty"` MaximumBandwidth *Bandwidth `json:"maximumBandwidth,omitempty" url:"maximumBandwidth,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -710,6 +1059,27 @@ func (b *BandwidthRange) GetExtraProperties() map[string]interface{} { return b.extraProperties } +func (b *BandwidthRange) require(field *big.Int) { + if b.explicitFields == nil { + b.explicitFields = big.NewInt(0) + } + b.explicitFields.Or(b.explicitFields, field) +} + +// SetMinimumBandwidth sets the MinimumBandwidth field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (b *BandwidthRange) SetMinimumBandwidth(minimumBandwidth *Bandwidth) { + b.MinimumBandwidth = minimumBandwidth + b.require(bandwidthRangeFieldMinimumBandwidth) +} + +// SetMaximumBandwidth sets the MaximumBandwidth field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (b *BandwidthRange) SetMaximumBandwidth(maximumBandwidth *Bandwidth) { + b.MaximumBandwidth = maximumBandwidth + b.require(bandwidthRangeFieldMaximumBandwidth) +} + func (b *BandwidthRange) UnmarshalJSON(data []byte) error { type unmarshaler BandwidthRange var value unmarshaler @@ -726,6 +1096,17 @@ func (b *BandwidthRange) UnmarshalJSON(data []byte) error { return nil } +func (b *BandwidthRange) MarshalJSON() ([]byte, error) { + type embed BandwidthRange + var marshaler = struct { + embed + }{ + embed: embed(*b), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, b.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (b *BandwidthRange) String() string { if len(b.rawJSON) > 0 { if value, err := internal.StringifyJSON(b.rawJSON); err == nil { @@ -739,6 +1120,11 @@ func (b *BandwidthRange) String() string { } // A component that describes an entity's security classification levels. +var ( + classificationFieldDefault = big.NewInt(1 << 0) + classificationFieldFields = big.NewInt(1 << 1) +) + type Classification struct { // The default classification information which should be assumed to apply to everything in // @@ -749,6 +1135,9 @@ type Classification struct { // over the default classification information. Fields []*FieldClassificationInformation `json:"fields,omitempty" url:"fields,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -771,6 +1160,27 @@ func (c *Classification) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *Classification) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetDefault sets the Default field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Classification) SetDefault(default_ *ClassificationInformation) { + c.Default = default_ + c.require(classificationFieldDefault) +} + +// SetFields sets the Fields field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Classification) SetFields(fields []*FieldClassificationInformation) { + c.Fields = fields + c.require(classificationFieldFields) +} + func (c *Classification) UnmarshalJSON(data []byte) error { type unmarshaler Classification var value unmarshaler @@ -787,6 +1197,17 @@ func (c *Classification) UnmarshalJSON(data []byte) error { return nil } +func (c *Classification) MarshalJSON() ([]byte, error) { + type embed Classification + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *Classification) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -805,12 +1226,20 @@ func (c *Classification) String() string { // // > example: A summarized classification marking of "TOPSECRET//NOFORN//FISA" // would be defined as: { "level": 5, "caveats": [ "NOFORN, "FISA" ] } +var ( + classificationInformationFieldLevel = big.NewInt(1 << 0) + classificationInformationFieldCaveats = big.NewInt(1 << 1) +) + type ClassificationInformation struct { // Classification level to be applied to the information in question. Level *ClassificationInformationLevel `json:"level,omitempty" url:"level,omitempty"` // Caveats that may further restrict how the information can be disseminated. Caveats []string `json:"caveats,omitempty" url:"caveats,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -833,6 +1262,27 @@ func (c *ClassificationInformation) GetExtraProperties() map[string]interface{} return c.extraProperties } +func (c *ClassificationInformation) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetLevel sets the Level field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ClassificationInformation) SetLevel(level *ClassificationInformationLevel) { + c.Level = level + c.require(classificationInformationFieldLevel) +} + +// SetCaveats sets the Caveats field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ClassificationInformation) SetCaveats(caveats []string) { + c.Caveats = caveats + c.require(classificationInformationFieldCaveats) +} + func (c *ClassificationInformation) UnmarshalJSON(data []byte) error { type unmarshaler ClassificationInformation var value unmarshaler @@ -849,6 +1299,17 @@ func (c *ClassificationInformation) UnmarshalJSON(data []byte) error { return nil } +func (c *ClassificationInformation) MarshalJSON() ([]byte, error) { + type embed ClassificationInformation + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *ClassificationInformation) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -896,6 +1357,13 @@ func (c ClassificationInformationLevel) Ptr() *ClassificationInformationLevel { return &c } +var ( + colorFieldRed = big.NewInt(1 << 0) + colorFieldGreen = big.NewInt(1 << 1) + colorFieldBlue = big.NewInt(1 << 2) + colorFieldAlpha = big.NewInt(1 << 3) +) + type Color struct { // The amount of red in the color as a value in the interval [0, 1]. Red *float64 `json:"red,omitempty" url:"red,omitempty"` @@ -917,6 +1385,9 @@ type Color struct { // (as if the alpha value had been explicitly given a value of 1.0). Alpha *float64 `json:"alpha,omitempty" url:"alpha,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -953,6 +1424,41 @@ func (c *Color) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *Color) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetRed sets the Red field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Color) SetRed(red *float64) { + c.Red = red + c.require(colorFieldRed) +} + +// SetGreen sets the Green field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Color) SetGreen(green *float64) { + c.Green = green + c.require(colorFieldGreen) +} + +// SetBlue sets the Blue field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Color) SetBlue(blue *float64) { + c.Blue = blue + c.require(colorFieldBlue) +} + +// SetAlpha sets the Alpha field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Color) SetAlpha(alpha *float64) { + c.Alpha = alpha + c.require(colorFieldAlpha) +} + func (c *Color) UnmarshalJSON(data []byte) error { type unmarshaler Color var value unmarshaler @@ -969,6 +1475,17 @@ func (c *Color) UnmarshalJSON(data []byte) error { return nil } +func (c *Color) MarshalJSON() ([]byte, error) { + type embed Color + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *Color) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -982,6 +1499,14 @@ func (c *Color) String() string { } // Health of an individual component. +var ( + componentHealthFieldID = big.NewInt(1 << 0) + componentHealthFieldName = big.NewInt(1 << 1) + componentHealthFieldHealth = big.NewInt(1 << 2) + componentHealthFieldMessages = big.NewInt(1 << 3) + componentHealthFieldUpdateTime = big.NewInt(1 << 4) +) + type ComponentHealth struct { // Consistent internal ID for this component. ID *string `json:"id,omitempty" url:"id,omitempty"` @@ -996,6 +1521,9 @@ type ComponentHealth struct { // If this timestamp is unset, the data is assumed to be most recent UpdateTime *time.Time `json:"updateTime,omitempty" url:"updateTime,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1039,6 +1567,48 @@ func (c *ComponentHealth) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *ComponentHealth) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetID sets the ID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentHealth) SetID(id *string) { + c.ID = id + c.require(componentHealthFieldID) +} + +// SetName sets the Name field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentHealth) SetName(name *string) { + c.Name = name + c.require(componentHealthFieldName) +} + +// SetHealth sets the Health field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentHealth) SetHealth(health *ComponentHealthHealth) { + c.Health = health + c.require(componentHealthFieldHealth) +} + +// SetMessages sets the Messages field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentHealth) SetMessages(messages []*ComponentMessage) { + c.Messages = messages + c.require(componentHealthFieldMessages) +} + +// SetUpdateTime sets the UpdateTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentHealth) SetUpdateTime(updateTime *time.Time) { + c.UpdateTime = updateTime + c.require(componentHealthFieldUpdateTime) +} + func (c *ComponentHealth) UnmarshalJSON(data []byte) error { type embed ComponentHealth var unmarshaler = struct { @@ -1070,7 +1640,8 @@ func (c *ComponentHealth) MarshalJSON() ([]byte, error) { embed: embed(*c), UpdateTime: internal.NewOptionalDateTime(c.UpdateTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) } func (c *ComponentHealth) String() string { @@ -1121,12 +1692,20 @@ func (c ComponentHealthHealth) Ptr() *ComponentHealthHealth { } // A message describing the component's health status. +var ( + componentMessageFieldStatus = big.NewInt(1 << 0) + componentMessageFieldMessage = big.NewInt(1 << 1) +) + type ComponentMessage struct { // The status associated with this message. Status *ComponentMessageStatus `json:"status,omitempty" url:"status,omitempty"` // The human-readable content of the message. Message *string `json:"message,omitempty" url:"message,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1149,6 +1728,27 @@ func (c *ComponentMessage) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *ComponentMessage) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentMessage) SetStatus(status *ComponentMessageStatus) { + c.Status = status + c.require(componentMessageFieldStatus) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ComponentMessage) SetMessage(message *string) { + c.Message = message + c.require(componentMessageFieldMessage) +} + func (c *ComponentMessage) UnmarshalJSON(data []byte) error { type unmarshaler ComponentMessage var value unmarshaler @@ -1165,6 +1765,17 @@ func (c *ComponentMessage) UnmarshalJSON(data []byte) error { return nil } +func (c *ComponentMessage) MarshalJSON() ([]byte, error) { + type embed ComponentMessage + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *ComponentMessage) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -1215,9 +1826,16 @@ func (c ComponentMessageStatus) Ptr() *ComponentMessageStatus { // Determines the type of control area being represented by the geo-entity, // // in which an asset can, or cannot, operate. +var ( + controlAreaDetailsFieldType = big.NewInt(1 << 0) +) + type ControlAreaDetails struct { Type *ControlAreaDetailsType `json:"type,omitempty" url:"type,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1233,6 +1851,20 @@ func (c *ControlAreaDetails) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *ControlAreaDetails) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *ControlAreaDetails) SetType(type_ *ControlAreaDetailsType) { + c.Type = type_ + c.require(controlAreaDetailsFieldType) +} + func (c *ControlAreaDetails) UnmarshalJSON(data []byte) error { type unmarshaler ControlAreaDetails var value unmarshaler @@ -1249,8 +1881,19 @@ func (c *ControlAreaDetails) UnmarshalJSON(data []byte) error { return nil } -func (c *ControlAreaDetails) String() string { - if len(c.rawJSON) > 0 { +func (c *ControlAreaDetails) MarshalJSON() ([]byte, error) { + type embed ControlAreaDetails + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + +func (c *ControlAreaDetails) String() string { + if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { return value } @@ -1295,6 +1938,13 @@ func (c ControlAreaDetailsType) Ptr() *ControlAreaDetailsType { // Available for Entities that are a correlated (N to 1) set of entities. This will be present on // // each entity in the set. +var ( + correlationFieldPrimary = big.NewInt(1 << 0) + correlationFieldSecondary = big.NewInt(1 << 1) + correlationFieldMembership = big.NewInt(1 << 2) + correlationFieldDecorrelation = big.NewInt(1 << 3) +) + type Correlation struct { // This entity is the primary of a correlation meaning that it serves as the representative // @@ -1315,6 +1965,9 @@ type Correlation struct { // correlator from re-correlating them at a later time. Decorrelation *Decorrelation `json:"decorrelation,omitempty" url:"decorrelation,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1351,6 +2004,41 @@ func (c *Correlation) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *Correlation) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetPrimary sets the Primary field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Correlation) SetPrimary(primary *PrimaryCorrelation) { + c.Primary = primary + c.require(correlationFieldPrimary) +} + +// SetSecondary sets the Secondary field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Correlation) SetSecondary(secondary *SecondaryCorrelation) { + c.Secondary = secondary + c.require(correlationFieldSecondary) +} + +// SetMembership sets the Membership field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Correlation) SetMembership(membership *CorrelationMembership) { + c.Membership = membership + c.require(correlationFieldMembership) +} + +// SetDecorrelation sets the Decorrelation field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *Correlation) SetDecorrelation(decorrelation *Decorrelation) { + c.Decorrelation = decorrelation + c.require(correlationFieldDecorrelation) +} + func (c *Correlation) UnmarshalJSON(data []byte) error { type unmarshaler Correlation var value unmarshaler @@ -1367,6 +2055,17 @@ func (c *Correlation) UnmarshalJSON(data []byte) error { return nil } +func (c *Correlation) MarshalJSON() ([]byte, error) { + type embed Correlation + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *Correlation) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -1379,6 +2078,13 @@ func (c *Correlation) String() string { return fmt.Sprintf("%#v", c) } +var ( + correlationMembershipFieldCorrelationSetID = big.NewInt(1 << 0) + correlationMembershipFieldPrimary = big.NewInt(1 << 1) + correlationMembershipFieldNonPrimary = big.NewInt(1 << 2) + correlationMembershipFieldMetadata = big.NewInt(1 << 3) +) + type CorrelationMembership struct { // The ID of the correlation set this entity belongs to. CorrelationSetID *string `json:"correlationSetId,omitempty" url:"correlationSetId,omitempty"` @@ -1393,6 +2099,9 @@ type CorrelationMembership struct { // Additional metadata on this correlation. Metadata *CorrelationMetadata `json:"metadata,omitempty" url:"metadata,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1429,6 +2138,41 @@ func (c *CorrelationMembership) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *CorrelationMembership) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetCorrelationSetID sets the CorrelationSetID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMembership) SetCorrelationSetID(correlationSetID *string) { + c.CorrelationSetID = correlationSetID + c.require(correlationMembershipFieldCorrelationSetID) +} + +// SetPrimary sets the Primary field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMembership) SetPrimary(primary *PrimaryMembership) { + c.Primary = primary + c.require(correlationMembershipFieldPrimary) +} + +// SetNonPrimary sets the NonPrimary field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMembership) SetNonPrimary(nonPrimary *NonPrimaryMembership) { + c.NonPrimary = nonPrimary + c.require(correlationMembershipFieldNonPrimary) +} + +// SetMetadata sets the Metadata field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMembership) SetMetadata(metadata *CorrelationMetadata) { + c.Metadata = metadata + c.require(correlationMembershipFieldMetadata) +} + func (c *CorrelationMembership) UnmarshalJSON(data []byte) error { type unmarshaler CorrelationMembership var value unmarshaler @@ -1445,6 +2189,17 @@ func (c *CorrelationMembership) UnmarshalJSON(data []byte) error { return nil } +func (c *CorrelationMembership) MarshalJSON() ([]byte, error) { + type embed CorrelationMembership + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *CorrelationMembership) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -1457,6 +2212,12 @@ func (c *CorrelationMembership) String() string { return fmt.Sprintf("%#v", c) } +var ( + correlationMetadataFieldProvenance = big.NewInt(1 << 0) + correlationMetadataFieldReplicationMode = big.NewInt(1 << 1) + correlationMetadataFieldType = big.NewInt(1 << 2) +) + type CorrelationMetadata struct { // Who or what added this entity to the (de)correlation. Provenance *Provenance `json:"provenance,omitempty" url:"provenance,omitempty"` @@ -1472,6 +2233,9 @@ type CorrelationMetadata struct { // What type of (de)correlation was this entity added with. Type *CorrelationMetadataType `json:"type,omitempty" url:"type,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1501,6 +2265,34 @@ func (c *CorrelationMetadata) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *CorrelationMetadata) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetProvenance sets the Provenance field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMetadata) SetProvenance(provenance *Provenance) { + c.Provenance = provenance + c.require(correlationMetadataFieldProvenance) +} + +// SetReplicationMode sets the ReplicationMode field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMetadata) SetReplicationMode(replicationMode *CorrelationMetadataReplicationMode) { + c.ReplicationMode = replicationMode + c.require(correlationMetadataFieldReplicationMode) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CorrelationMetadata) SetType(type_ *CorrelationMetadataType) { + c.Type = type_ + c.require(correlationMetadataFieldType) +} + func (c *CorrelationMetadata) UnmarshalJSON(data []byte) error { type unmarshaler CorrelationMetadata var value unmarshaler @@ -1517,6 +2309,17 @@ func (c *CorrelationMetadata) UnmarshalJSON(data []byte) error { return nil } +func (c *CorrelationMetadata) MarshalJSON() ([]byte, error) { + type embed CorrelationMetadata + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *CorrelationMetadata) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -1588,6 +2391,11 @@ func (c CorrelationMetadataType) Ptr() *CorrelationMetadataType { return &c } +var ( + cronWindowFieldCronExpression = big.NewInt(1 << 0) + cronWindowFieldDurationMillis = big.NewInt(1 << 1) +) + type CronWindow struct { // in UTC, describes when and at what cadence this window starts, in the quartz flavor of cron // @@ -1602,6 +2410,9 @@ type CronWindow struct { // describes the duration DurationMillis *string `json:"durationMillis,omitempty" url:"durationMillis,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1624,6 +2435,27 @@ func (c *CronWindow) GetExtraProperties() map[string]interface{} { return c.extraProperties } +func (c *CronWindow) require(field *big.Int) { + if c.explicitFields == nil { + c.explicitFields = big.NewInt(0) + } + c.explicitFields.Or(c.explicitFields, field) +} + +// SetCronExpression sets the CronExpression field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CronWindow) SetCronExpression(cronExpression *string) { + c.CronExpression = cronExpression + c.require(cronWindowFieldCronExpression) +} + +// SetDurationMillis sets the DurationMillis field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (c *CronWindow) SetDurationMillis(durationMillis *string) { + c.DurationMillis = durationMillis + c.require(cronWindowFieldDurationMillis) +} + func (c *CronWindow) UnmarshalJSON(data []byte) error { type unmarshaler CronWindow var value unmarshaler @@ -1640,6 +2472,17 @@ func (c *CronWindow) UnmarshalJSON(data []byte) error { return nil } +func (c *CronWindow) MarshalJSON() ([]byte, error) { + type embed CronWindow + var marshaler = struct { + embed + }{ + embed: embed(*c), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (c *CronWindow) String() string { if len(c.rawJSON) > 0 { if value, err := internal.StringifyJSON(c.rawJSON); err == nil { @@ -1652,10 +2495,17 @@ func (c *CronWindow) String() string { return fmt.Sprintf("%#v", c) } +var ( + decorrelatedAllFieldMetadata = big.NewInt(1 << 0) +) + type DecorrelatedAll struct { // Metadata about the decorrelation. Metadata *CorrelationMetadata `json:"metadata,omitempty" url:"metadata,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1671,6 +2521,20 @@ func (d *DecorrelatedAll) GetExtraProperties() map[string]interface{} { return d.extraProperties } +func (d *DecorrelatedAll) require(field *big.Int) { + if d.explicitFields == nil { + d.explicitFields = big.NewInt(0) + } + d.explicitFields.Or(d.explicitFields, field) +} + +// SetMetadata sets the Metadata field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *DecorrelatedAll) SetMetadata(metadata *CorrelationMetadata) { + d.Metadata = metadata + d.require(decorrelatedAllFieldMetadata) +} + func (d *DecorrelatedAll) UnmarshalJSON(data []byte) error { type unmarshaler DecorrelatedAll var value unmarshaler @@ -1687,6 +2551,17 @@ func (d *DecorrelatedAll) UnmarshalJSON(data []byte) error { return nil } +func (d *DecorrelatedAll) MarshalJSON() ([]byte, error) { + type embed DecorrelatedAll + var marshaler = struct { + embed + }{ + embed: embed(*d), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, d.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (d *DecorrelatedAll) String() string { if len(d.rawJSON) > 0 { if value, err := internal.StringifyJSON(d.rawJSON); err == nil { @@ -1699,12 +2574,20 @@ func (d *DecorrelatedAll) String() string { return fmt.Sprintf("%#v", d) } +var ( + decorrelatedSingleFieldEntityID = big.NewInt(1 << 0) + decorrelatedSingleFieldMetadata = big.NewInt(1 << 1) +) + type DecorrelatedSingle struct { // The entity that was decorrelated against. EntityID *string `json:"entityId,omitempty" url:"entityId,omitempty"` // Metadata about the decorrelation. Metadata *CorrelationMetadata `json:"metadata,omitempty" url:"metadata,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1727,6 +2610,27 @@ func (d *DecorrelatedSingle) GetExtraProperties() map[string]interface{} { return d.extraProperties } +func (d *DecorrelatedSingle) require(field *big.Int) { + if d.explicitFields == nil { + d.explicitFields = big.NewInt(0) + } + d.explicitFields.Or(d.explicitFields, field) +} + +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *DecorrelatedSingle) SetEntityID(entityID *string) { + d.EntityID = entityID + d.require(decorrelatedSingleFieldEntityID) +} + +// SetMetadata sets the Metadata field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *DecorrelatedSingle) SetMetadata(metadata *CorrelationMetadata) { + d.Metadata = metadata + d.require(decorrelatedSingleFieldMetadata) +} + func (d *DecorrelatedSingle) UnmarshalJSON(data []byte) error { type unmarshaler DecorrelatedSingle var value unmarshaler @@ -1743,6 +2647,17 @@ func (d *DecorrelatedSingle) UnmarshalJSON(data []byte) error { return nil } +func (d *DecorrelatedSingle) MarshalJSON() ([]byte, error) { + type embed DecorrelatedSingle + var marshaler = struct { + embed + }{ + embed: embed(*d), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, d.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (d *DecorrelatedSingle) String() string { if len(d.rawJSON) > 0 { if value, err := internal.StringifyJSON(d.rawJSON); err == nil { @@ -1755,6 +2670,11 @@ func (d *DecorrelatedSingle) String() string { return fmt.Sprintf("%#v", d) } +var ( + decorrelationFieldAll = big.NewInt(1 << 0) + decorrelationFieldDecorrelatedEntities = big.NewInt(1 << 1) +) + type Decorrelation struct { // This will be specified if this entity was decorrelated against all other entities. All *DecorrelatedAll `json:"all,omitempty" url:"all,omitempty"` @@ -1767,6 +2687,9 @@ type Decorrelation struct { // type and replication mode. DecorrelatedEntities []*DecorrelatedSingle `json:"decorrelatedEntities,omitempty" url:"decorrelatedEntities,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1789,6 +2712,27 @@ func (d *Decorrelation) GetExtraProperties() map[string]interface{} { return d.extraProperties } +func (d *Decorrelation) require(field *big.Int) { + if d.explicitFields == nil { + d.explicitFields = big.NewInt(0) + } + d.explicitFields.Or(d.explicitFields, field) +} + +// SetAll sets the All field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *Decorrelation) SetAll(all *DecorrelatedAll) { + d.All = all + d.require(decorrelationFieldAll) +} + +// SetDecorrelatedEntities sets the DecorrelatedEntities field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *Decorrelation) SetDecorrelatedEntities(decorrelatedEntities []*DecorrelatedSingle) { + d.DecorrelatedEntities = decorrelatedEntities + d.require(decorrelationFieldDecorrelatedEntities) +} + func (d *Decorrelation) UnmarshalJSON(data []byte) error { type unmarshaler Decorrelation var value unmarshaler @@ -1805,6 +2749,17 @@ func (d *Decorrelation) UnmarshalJSON(data []byte) error { return nil } +func (d *Decorrelation) MarshalJSON() ([]byte, error) { + type embed Decorrelation + var marshaler = struct { + embed + }{ + embed: embed(*d), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, d.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (d *Decorrelation) String() string { if len(d.rawJSON) > 0 { if value, err := internal.StringifyJSON(d.rawJSON); err == nil { @@ -1817,10 +2772,17 @@ func (d *Decorrelation) String() string { return fmt.Sprintf("%#v", d) } +var ( + dimensionsFieldLengthM = big.NewInt(1 << 0) +) + type Dimensions struct { // Length of the entity in meters LengthM *float64 `json:"lengthM,omitempty" url:"lengthM,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1836,6 +2798,20 @@ func (d *Dimensions) GetExtraProperties() map[string]interface{} { return d.extraProperties } +func (d *Dimensions) require(field *big.Int) { + if d.explicitFields == nil { + d.explicitFields = big.NewInt(0) + } + d.explicitFields.Or(d.explicitFields, field) +} + +// SetLengthM sets the LengthM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (d *Dimensions) SetLengthM(lengthM *float64) { + d.LengthM = lengthM + d.require(dimensionsFieldLengthM) +} + func (d *Dimensions) UnmarshalJSON(data []byte) error { type unmarshaler Dimensions var value unmarshaler @@ -1852,6 +2828,17 @@ func (d *Dimensions) UnmarshalJSON(data []byte) error { return nil } +func (d *Dimensions) MarshalJSON() ([]byte, error) { + type embed Dimensions + var marshaler = struct { + embed + }{ + embed: embed(*d), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, d.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (d *Dimensions) String() string { if len(d.rawJSON) > 0 { if value, err := internal.StringifyJSON(d.rawJSON); err == nil { @@ -1868,9 +2855,16 @@ func (d *Dimensions) String() string { // // same unit or echelon. Ex: A group of tanks within a armored company or that same company // as a member of a battalion. +var ( + echelonFieldArmyEchelon = big.NewInt(1 << 0) +) + type Echelon struct { ArmyEchelon *EchelonArmyEchelon `json:"armyEchelon,omitempty" url:"armyEchelon,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1886,6 +2880,20 @@ func (e *Echelon) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *Echelon) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetArmyEchelon sets the ArmyEchelon field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Echelon) SetArmyEchelon(armyEchelon *EchelonArmyEchelon) { + e.ArmyEchelon = armyEchelon + e.require(echelonFieldArmyEchelon) +} + func (e *Echelon) UnmarshalJSON(data []byte) error { type unmarshaler Echelon var value unmarshaler @@ -1902,6 +2910,17 @@ func (e *Echelon) UnmarshalJSON(data []byte) error { return nil } +func (e *Echelon) MarshalJSON() ([]byte, error) { + type embed Echelon + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *Echelon) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -1964,11 +2983,19 @@ func (e EchelonArmyEchelon) Ptr() *EchelonArmyEchelon { } // A representation of a single emitter notation. +var ( + emitterNotationFieldEmitterNotation = big.NewInt(1 << 0) + emitterNotationFieldConfidence = big.NewInt(1 << 1) +) + type EmitterNotation struct { EmitterNotation *string `json:"emitterNotation,omitempty" url:"emitterNotation,omitempty"` // confidence as a percentage that the emitter notation in this component is accurate Confidence *float64 `json:"confidence,omitempty" url:"confidence,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -1991,6 +3018,27 @@ func (e *EmitterNotation) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *EmitterNotation) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetEmitterNotation sets the EmitterNotation field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EmitterNotation) SetEmitterNotation(emitterNotation *string) { + e.EmitterNotation = emitterNotation + e.require(emitterNotationFieldEmitterNotation) +} + +// SetConfidence sets the Confidence field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *EmitterNotation) SetConfidence(confidence *float64) { + e.Confidence = confidence + e.require(emitterNotationFieldConfidence) +} + func (e *EmitterNotation) UnmarshalJSON(data []byte) error { type unmarshaler EmitterNotation var value unmarshaler @@ -2007,6 +3055,17 @@ func (e *EmitterNotation) UnmarshalJSON(data []byte) error { return nil } +func (e *EmitterNotation) MarshalJSON() ([]byte, error) { + type embed EmitterNotation + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *EmitterNotation) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -2022,6 +3081,46 @@ func (e *EmitterNotation) String() string { // The entity object represents a single known object within the Lattice operational environment. It contains // // all data associated with the entity, such as its name, ID, and other relevant components. +var ( + entityFieldEntityID = big.NewInt(1 << 0) + entityFieldDescription = big.NewInt(1 << 1) + entityFieldIsLive = big.NewInt(1 << 2) + entityFieldCreatedTime = big.NewInt(1 << 3) + entityFieldExpiryTime = big.NewInt(1 << 4) + entityFieldNoExpiry = big.NewInt(1 << 5) + entityFieldStatus = big.NewInt(1 << 6) + entityFieldLocation = big.NewInt(1 << 7) + entityFieldLocationUncertainty = big.NewInt(1 << 8) + entityFieldGeoShape = big.NewInt(1 << 9) + entityFieldGeoDetails = big.NewInt(1 << 10) + entityFieldAliases = big.NewInt(1 << 11) + entityFieldTracked = big.NewInt(1 << 12) + entityFieldCorrelation = big.NewInt(1 << 13) + entityFieldMilView = big.NewInt(1 << 14) + entityFieldOntology = big.NewInt(1 << 15) + entityFieldSensors = big.NewInt(1 << 16) + entityFieldPayloads = big.NewInt(1 << 17) + entityFieldPowerState = big.NewInt(1 << 18) + entityFieldProvenance = big.NewInt(1 << 19) + entityFieldOverrides = big.NewInt(1 << 20) + entityFieldIndicators = big.NewInt(1 << 21) + entityFieldTargetPriority = big.NewInt(1 << 22) + entityFieldSignal = big.NewInt(1 << 23) + entityFieldTransponderCodes = big.NewInt(1 << 24) + entityFieldDataClassification = big.NewInt(1 << 25) + entityFieldTaskCatalog = big.NewInt(1 << 26) + entityFieldMedia = big.NewInt(1 << 27) + entityFieldRelationships = big.NewInt(1 << 28) + entityFieldVisualDetails = big.NewInt(1 << 29) + entityFieldDimensions = big.NewInt(1 << 30) + entityFieldRouteDetails = big.NewInt(1 << 31) + entityFieldSchedules = big.NewInt(1 << 32) + entityFieldHealth = big.NewInt(1 << 33) + entityFieldGroupDetails = big.NewInt(1 << 34) + entityFieldSupplies = big.NewInt(1 << 35) + entityFieldOrbit = big.NewInt(1 << 36) +) + type Entity struct { // A Globally Unique Identifier (GUID) for your entity. If this field is empty, the Entity Manager API // @@ -2124,6 +3223,9 @@ type Entity struct { // Orbit information for space objects. Orbit *Orbit `json:"orbit,omitempty" url:"orbit,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2391,98 +3493,402 @@ func (e *Entity) GetExtraProperties() map[string]interface{} { return e.extraProperties } -func (e *Entity) UnmarshalJSON(data []byte) error { - type embed Entity - var unmarshaler = struct { - embed - CreatedTime *internal.DateTime `json:"createdTime,omitempty"` - ExpiryTime *internal.DateTime `json:"expiryTime,omitempty"` - }{ - embed: embed(*e), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *e = Entity(unmarshaler.embed) - e.CreatedTime = unmarshaler.CreatedTime.TimePtr() - e.ExpiryTime = unmarshaler.ExpiryTime.TimePtr() - extraProperties, err := internal.ExtractExtraProperties(data, *e) - if err != nil { - return err +func (e *Entity) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) } - e.extraProperties = extraProperties - e.rawJSON = json.RawMessage(data) - return nil + e.explicitFields.Or(e.explicitFields, field) } -func (e *Entity) MarshalJSON() ([]byte, error) { - type embed Entity - var marshaler = struct { - embed - CreatedTime *internal.DateTime `json:"createdTime,omitempty"` - ExpiryTime *internal.DateTime `json:"expiryTime,omitempty"` - }{ - embed: embed(*e), - CreatedTime: internal.NewOptionalDateTime(e.CreatedTime), - ExpiryTime: internal.NewOptionalDateTime(e.ExpiryTime), - } - return json.Marshal(marshaler) +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetEntityID(entityID *string) { + e.EntityID = entityID + e.require(entityFieldEntityID) } -func (e *Entity) String() string { - if len(e.rawJSON) > 0 { - if value, err := internal.StringifyJSON(e.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) +// SetDescription sets the Description field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetDescription(description *string) { + e.Description = description + e.require(entityFieldDescription) } -type Enu struct { - E *float64 `json:"e,omitempty" url:"e,omitempty"` - N *float64 `json:"n,omitempty" url:"n,omitempty"` - U *float64 `json:"u,omitempty" url:"u,omitempty"` +// SetIsLive sets the IsLive field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetIsLive(isLive *bool) { + e.IsLive = isLive + e.require(entityFieldIsLive) +} - extraProperties map[string]interface{} - rawJSON json.RawMessage +// SetCreatedTime sets the CreatedTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetCreatedTime(createdTime *time.Time) { + e.CreatedTime = createdTime + e.require(entityFieldCreatedTime) } -func (e *Enu) GetE() *float64 { - if e == nil { - return nil - } - return e.E +// SetExpiryTime sets the ExpiryTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetExpiryTime(expiryTime *time.Time) { + e.ExpiryTime = expiryTime + e.require(entityFieldExpiryTime) } -func (e *Enu) GetN() *float64 { - if e == nil { - return nil - } - return e.N +// SetNoExpiry sets the NoExpiry field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetNoExpiry(noExpiry *bool) { + e.NoExpiry = noExpiry + e.require(entityFieldNoExpiry) } -func (e *Enu) GetU() *float64 { - if e == nil { - return nil - } - return e.U +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetStatus(status *Status) { + e.Status = status + e.require(entityFieldStatus) } -func (e *Enu) GetExtraProperties() map[string]interface{} { - return e.extraProperties +// SetLocation sets the Location field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetLocation(location *Location) { + e.Location = location + e.require(entityFieldLocation) } -func (e *Enu) UnmarshalJSON(data []byte) error { - type unmarshaler Enu - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = Enu(value) - extraProperties, err := internal.ExtractExtraProperties(data, *e) +// SetLocationUncertainty sets the LocationUncertainty field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetLocationUncertainty(locationUncertainty *LocationUncertainty) { + e.LocationUncertainty = locationUncertainty + e.require(entityFieldLocationUncertainty) +} + +// SetGeoShape sets the GeoShape field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetGeoShape(geoShape *GeoShape) { + e.GeoShape = geoShape + e.require(entityFieldGeoShape) +} + +// SetGeoDetails sets the GeoDetails field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetGeoDetails(geoDetails *GeoDetails) { + e.GeoDetails = geoDetails + e.require(entityFieldGeoDetails) +} + +// SetAliases sets the Aliases field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetAliases(aliases *Aliases) { + e.Aliases = aliases + e.require(entityFieldAliases) +} + +// SetTracked sets the Tracked field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetTracked(tracked *Tracked) { + e.Tracked = tracked + e.require(entityFieldTracked) +} + +// SetCorrelation sets the Correlation field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetCorrelation(correlation *Correlation) { + e.Correlation = correlation + e.require(entityFieldCorrelation) +} + +// SetMilView sets the MilView field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetMilView(milView *MilView) { + e.MilView = milView + e.require(entityFieldMilView) +} + +// SetOntology sets the Ontology field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetOntology(ontology *Ontology) { + e.Ontology = ontology + e.require(entityFieldOntology) +} + +// SetSensors sets the Sensors field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetSensors(sensors *Sensors) { + e.Sensors = sensors + e.require(entityFieldSensors) +} + +// SetPayloads sets the Payloads field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetPayloads(payloads *Payloads) { + e.Payloads = payloads + e.require(entityFieldPayloads) +} + +// SetPowerState sets the PowerState field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetPowerState(powerState *PowerState) { + e.PowerState = powerState + e.require(entityFieldPowerState) +} + +// SetProvenance sets the Provenance field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetProvenance(provenance *Provenance) { + e.Provenance = provenance + e.require(entityFieldProvenance) +} + +// SetOverrides sets the Overrides field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetOverrides(overrides *Overrides) { + e.Overrides = overrides + e.require(entityFieldOverrides) +} + +// SetIndicators sets the Indicators field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetIndicators(indicators *Indicators) { + e.Indicators = indicators + e.require(entityFieldIndicators) +} + +// SetTargetPriority sets the TargetPriority field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetTargetPriority(targetPriority *TargetPriority) { + e.TargetPriority = targetPriority + e.require(entityFieldTargetPriority) +} + +// SetSignal sets the Signal field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetSignal(signal *Signal) { + e.Signal = signal + e.require(entityFieldSignal) +} + +// SetTransponderCodes sets the TransponderCodes field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetTransponderCodes(transponderCodes *TransponderCodes) { + e.TransponderCodes = transponderCodes + e.require(entityFieldTransponderCodes) +} + +// SetDataClassification sets the DataClassification field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetDataClassification(dataClassification *Classification) { + e.DataClassification = dataClassification + e.require(entityFieldDataClassification) +} + +// SetTaskCatalog sets the TaskCatalog field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetTaskCatalog(taskCatalog *TaskCatalog) { + e.TaskCatalog = taskCatalog + e.require(entityFieldTaskCatalog) +} + +// SetMedia sets the Media field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetMedia(media *Media) { + e.Media = media + e.require(entityFieldMedia) +} + +// SetRelationships sets the Relationships field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetRelationships(relationships *Relationships) { + e.Relationships = relationships + e.require(entityFieldRelationships) +} + +// SetVisualDetails sets the VisualDetails field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetVisualDetails(visualDetails *VisualDetails) { + e.VisualDetails = visualDetails + e.require(entityFieldVisualDetails) +} + +// SetDimensions sets the Dimensions field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetDimensions(dimensions *Dimensions) { + e.Dimensions = dimensions + e.require(entityFieldDimensions) +} + +// SetRouteDetails sets the RouteDetails field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetRouteDetails(routeDetails *RouteDetails) { + e.RouteDetails = routeDetails + e.require(entityFieldRouteDetails) +} + +// SetSchedules sets the Schedules field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetSchedules(schedules *Schedules) { + e.Schedules = schedules + e.require(entityFieldSchedules) +} + +// SetHealth sets the Health field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetHealth(health *Health) { + e.Health = health + e.require(entityFieldHealth) +} + +// SetGroupDetails sets the GroupDetails field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetGroupDetails(groupDetails *GroupDetails) { + e.GroupDetails = groupDetails + e.require(entityFieldGroupDetails) +} + +// SetSupplies sets the Supplies field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetSupplies(supplies *Supplies) { + e.Supplies = supplies + e.require(entityFieldSupplies) +} + +// SetOrbit sets the Orbit field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *Entity) SetOrbit(orbit *Orbit) { + e.Orbit = orbit + e.require(entityFieldOrbit) +} + +func (e *Entity) UnmarshalJSON(data []byte) error { + type embed Entity + var unmarshaler = struct { + embed + CreatedTime *internal.DateTime `json:"createdTime,omitempty"` + ExpiryTime *internal.DateTime `json:"expiryTime,omitempty"` + }{ + embed: embed(*e), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *e = Entity(unmarshaler.embed) + e.CreatedTime = unmarshaler.CreatedTime.TimePtr() + e.ExpiryTime = unmarshaler.ExpiryTime.TimePtr() + extraProperties, err := internal.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + e.rawJSON = json.RawMessage(data) + return nil +} + +func (e *Entity) MarshalJSON() ([]byte, error) { + type embed Entity + var marshaler = struct { + embed + CreatedTime *internal.DateTime `json:"createdTime,omitempty"` + ExpiryTime *internal.DateTime `json:"expiryTime,omitempty"` + }{ + embed: embed(*e), + CreatedTime: internal.NewOptionalDateTime(e.CreatedTime), + ExpiryTime: internal.NewOptionalDateTime(e.ExpiryTime), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + +func (e *Entity) String() string { + if len(e.rawJSON) > 0 { + if value, err := internal.StringifyJSON(e.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +var ( + enuFieldE = big.NewInt(1 << 0) + enuFieldN = big.NewInt(1 << 1) + enuFieldU = big.NewInt(1 << 2) +) + +type Enu struct { + E *float64 `json:"e,omitempty" url:"e,omitempty"` + N *float64 `json:"n,omitempty" url:"n,omitempty"` + U *float64 `json:"u,omitempty" url:"u,omitempty"` + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (e *Enu) GetE() *float64 { + if e == nil { + return nil + } + return e.E +} + +func (e *Enu) GetN() *float64 { + if e == nil { + return nil + } + return e.N +} + +func (e *Enu) GetU() *float64 { + if e == nil { + return nil + } + return e.U +} + +func (e *Enu) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *Enu) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetE sets the E field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (_SetE *Enu) SetE(e *float64) { + _SetE.E = e + _SetE.require(enuFieldE) +} + +// SetN sets the N field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (_SetE *Enu) SetN(n *float64) { + _SetE.N = n + _SetE.require(enuFieldN) +} + +// SetU sets the U field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (_SetE *Enu) SetU(u *float64) { + _SetE.U = u + _SetE.require(enuFieldU) +} + +func (e *Enu) UnmarshalJSON(data []byte) error { + type unmarshaler Enu + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = Enu(value) + extraProperties, err := internal.ExtractExtraProperties(data, *e) if err != nil { return err } @@ -2491,6 +3897,17 @@ func (e *Enu) UnmarshalJSON(data []byte) error { return nil } +func (e *Enu) MarshalJSON() ([]byte, error) { + type embed Enu + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *Enu) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -2504,6 +3921,13 @@ func (e *Enu) String() string { } // Indicates ellipse characteristics and probability that an entity lies within the defined ellipse. +var ( + errorEllipseFieldProbability = big.NewInt(1 << 0) + errorEllipseFieldSemiMajorAxisM = big.NewInt(1 << 1) + errorEllipseFieldSemiMinorAxisM = big.NewInt(1 << 2) + errorEllipseFieldOrientationD = big.NewInt(1 << 3) +) + type ErrorEllipse struct { // Defines the probability in percentage that an entity lies within the given ellipse: 0-1. Probability *float64 `json:"probability,omitempty" url:"probability,omitempty"` @@ -2514,6 +3938,9 @@ type ErrorEllipse struct { // The orientation of the semi-major relative to true north in degrees from clockwise: 0-180 due to symmetry across the semi-minor axis. OrientationD *float64 `json:"orientationD,omitempty" url:"orientationD,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2550,6 +3977,41 @@ func (e *ErrorEllipse) GetExtraProperties() map[string]interface{} { return e.extraProperties } +func (e *ErrorEllipse) require(field *big.Int) { + if e.explicitFields == nil { + e.explicitFields = big.NewInt(0) + } + e.explicitFields.Or(e.explicitFields, field) +} + +// SetProbability sets the Probability field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *ErrorEllipse) SetProbability(probability *float64) { + e.Probability = probability + e.require(errorEllipseFieldProbability) +} + +// SetSemiMajorAxisM sets the SemiMajorAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *ErrorEllipse) SetSemiMajorAxisM(semiMajorAxisM *float64) { + e.SemiMajorAxisM = semiMajorAxisM + e.require(errorEllipseFieldSemiMajorAxisM) +} + +// SetSemiMinorAxisM sets the SemiMinorAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *ErrorEllipse) SetSemiMinorAxisM(semiMinorAxisM *float64) { + e.SemiMinorAxisM = semiMinorAxisM + e.require(errorEllipseFieldSemiMinorAxisM) +} + +// SetOrientationD sets the OrientationD field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (e *ErrorEllipse) SetOrientationD(orientationD *float64) { + e.OrientationD = orientationD + e.require(errorEllipseFieldOrientationD) +} + func (e *ErrorEllipse) UnmarshalJSON(data []byte) error { type unmarshaler ErrorEllipse var value unmarshaler @@ -2566,6 +4028,17 @@ func (e *ErrorEllipse) UnmarshalJSON(data []byte) error { return nil } +func (e *ErrorEllipse) MarshalJSON() ([]byte, error) { + type embed ErrorEllipse + var marshaler = struct { + embed + }{ + embed: embed(*e), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, e.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (e *ErrorEllipse) String() string { if len(e.rawJSON) > 0 { if value, err := internal.StringifyJSON(e.rawJSON); err == nil { @@ -2579,6 +4052,11 @@ func (e *ErrorEllipse) String() string { } // A field specific classification information definition. +var ( + fieldClassificationInformationFieldFieldPath = big.NewInt(1 << 0) + fieldClassificationInformationFieldClassificationInformation = big.NewInt(1 << 1) +) + type FieldClassificationInformation struct { // Proto field path which is the string representation of a field. // @@ -2587,6 +4065,9 @@ type FieldClassificationInformation struct { // The information which makes up the field level classification marking. ClassificationInformation *ClassificationInformation `json:"classificationInformation,omitempty" url:"classificationInformation,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2609,6 +4090,27 @@ func (f *FieldClassificationInformation) GetExtraProperties() map[string]interfa return f.extraProperties } +func (f *FieldClassificationInformation) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + +// SetFieldPath sets the FieldPath field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldClassificationInformation) SetFieldPath(fieldPath *string) { + f.FieldPath = fieldPath + f.require(fieldClassificationInformationFieldFieldPath) +} + +// SetClassificationInformation sets the ClassificationInformation field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldClassificationInformation) SetClassificationInformation(classificationInformation *ClassificationInformation) { + f.ClassificationInformation = classificationInformation + f.require(fieldClassificationInformationFieldClassificationInformation) +} + func (f *FieldClassificationInformation) UnmarshalJSON(data []byte) error { type unmarshaler FieldClassificationInformation var value unmarshaler @@ -2625,6 +4127,17 @@ func (f *FieldClassificationInformation) UnmarshalJSON(data []byte) error { return nil } +func (f *FieldClassificationInformation) MarshalJSON() ([]byte, error) { + type embed FieldClassificationInformation + var marshaler = struct { + embed + }{ + embed: embed(*f), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (f *FieldClassificationInformation) String() string { if len(f.rawJSON) > 0 { if value, err := internal.StringifyJSON(f.rawJSON); err == nil { @@ -2638,6 +4151,18 @@ func (f *FieldClassificationInformation) String() string { } // Sensor Field Of View closely resembling fov.proto SensorFieldOfView. +var ( + fieldOfViewFieldFovID = big.NewInt(1 << 0) + fieldOfViewFieldMountID = big.NewInt(1 << 1) + fieldOfViewFieldProjectedFrustum = big.NewInt(1 << 2) + fieldOfViewFieldProjectedCenterRay = big.NewInt(1 << 3) + fieldOfViewFieldCenterRayPose = big.NewInt(1 << 4) + fieldOfViewFieldHorizontalFov = big.NewInt(1 << 5) + fieldOfViewFieldVerticalFov = big.NewInt(1 << 6) + fieldOfViewFieldRange = big.NewInt(1 << 7) + fieldOfViewFieldMode = big.NewInt(1 << 8) +) + type FieldOfView struct { // The Id for one instance of a FieldOfView, persisted across multiple updates to provide continuity during // @@ -2667,6 +4192,9 @@ type FieldOfView struct { // tighter bounded tracking. Mode *FieldOfViewMode `json:"mode,omitempty" url:"mode,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2738,6 +4266,76 @@ func (f *FieldOfView) GetExtraProperties() map[string]interface{} { return f.extraProperties } +func (f *FieldOfView) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + +// SetFovID sets the FovID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetFovID(fovID *int) { + f.FovID = fovID + f.require(fieldOfViewFieldFovID) +} + +// SetMountID sets the MountID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetMountID(mountID *string) { + f.MountID = mountID + f.require(fieldOfViewFieldMountID) +} + +// SetProjectedFrustum sets the ProjectedFrustum field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetProjectedFrustum(projectedFrustum *ProjectedFrustum) { + f.ProjectedFrustum = projectedFrustum + f.require(fieldOfViewFieldProjectedFrustum) +} + +// SetProjectedCenterRay sets the ProjectedCenterRay field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetProjectedCenterRay(projectedCenterRay *Position) { + f.ProjectedCenterRay = projectedCenterRay + f.require(fieldOfViewFieldProjectedCenterRay) +} + +// SetCenterRayPose sets the CenterRayPose field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetCenterRayPose(centerRayPose *Pose) { + f.CenterRayPose = centerRayPose + f.require(fieldOfViewFieldCenterRayPose) +} + +// SetHorizontalFov sets the HorizontalFov field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetHorizontalFov(horizontalFov *float64) { + f.HorizontalFov = horizontalFov + f.require(fieldOfViewFieldHorizontalFov) +} + +// SetVerticalFov sets the VerticalFov field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetVerticalFov(verticalFov *float64) { + f.VerticalFov = verticalFov + f.require(fieldOfViewFieldVerticalFov) +} + +// SetRange sets the Range field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetRange(range_ *float64) { + f.Range = range_ + f.require(fieldOfViewFieldRange) +} + +// SetMode sets the Mode field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FieldOfView) SetMode(mode *FieldOfViewMode) { + f.Mode = mode + f.require(fieldOfViewFieldMode) +} + func (f *FieldOfView) UnmarshalJSON(data []byte) error { type unmarshaler FieldOfView var value unmarshaler @@ -2754,6 +4352,17 @@ func (f *FieldOfView) UnmarshalJSON(data []byte) error { return nil } +func (f *FieldOfView) MarshalJSON() ([]byte, error) { + type embed FieldOfView + var marshaler = struct { + embed + }{ + embed: embed(*f), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (f *FieldOfView) String() string { if len(f.rawJSON) > 0 { if value, err := internal.StringifyJSON(f.rawJSON); err == nil { @@ -2806,6 +4415,10 @@ func (f FieldOfViewMode) Ptr() *FieldOfViewMode { // A fix of a signal. No extra fields but it is expected that location should be populated when using this report. type Fixed struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2814,6 +4427,13 @@ func (f *Fixed) GetExtraProperties() map[string]interface{} { return f.extraProperties } +func (f *Fixed) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + func (f *Fixed) UnmarshalJSON(data []byte) error { type unmarshaler Fixed var value unmarshaler @@ -2830,6 +4450,17 @@ func (f *Fixed) UnmarshalJSON(data []byte) error { return nil } +func (f *Fixed) MarshalJSON() ([]byte, error) { + type embed Fixed + var marshaler = struct { + embed + }{ + embed: embed(*f), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (f *Fixed) String() string { if len(f.rawJSON) > 0 { if value, err := internal.StringifyJSON(f.rawJSON); err == nil { @@ -2843,10 +4474,17 @@ func (f *Fixed) String() string { } // A component for describing frequency. +var ( + frequencyFieldFrequencyHz = big.NewInt(1 << 0) +) + type Frequency struct { // Indicates a frequency of a signal (Hz) with its standard deviation. FrequencyHz *Measurement `json:"frequencyHz,omitempty" url:"frequencyHz,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2862,6 +4500,20 @@ func (f *Frequency) GetExtraProperties() map[string]interface{} { return f.extraProperties } +func (f *Frequency) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + +// SetFrequencyHz sets the FrequencyHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Frequency) SetFrequencyHz(frequencyHz *Measurement) { + f.FrequencyHz = frequencyHz + f.require(frequencyFieldFrequencyHz) +} + func (f *Frequency) UnmarshalJSON(data []byte) error { type unmarshaler Frequency var value unmarshaler @@ -2878,6 +4530,17 @@ func (f *Frequency) UnmarshalJSON(data []byte) error { return nil } +func (f *Frequency) MarshalJSON() ([]byte, error) { + type embed Frequency + var marshaler = struct { + embed + }{ + embed: embed(*f), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (f *Frequency) String() string { if len(f.rawJSON) > 0 { if value, err := internal.StringifyJSON(f.rawJSON); err == nil { @@ -2891,12 +4554,20 @@ func (f *Frequency) String() string { } // A component to represent a frequency range. +var ( + frequencyRangeFieldMinimumFrequencyHz = big.NewInt(1 << 0) + frequencyRangeFieldMaximumFrequencyHz = big.NewInt(1 << 1) +) + type FrequencyRange struct { // Indicates the lowest measured frequency of a signal (Hz). MinimumFrequencyHz *Frequency `json:"minimumFrequencyHz,omitempty" url:"minimumFrequencyHz,omitempty"` // Indicates the maximum measured frequency of a signal (Hz). MaximumFrequencyHz *Frequency `json:"maximumFrequencyHz,omitempty" url:"maximumFrequencyHz,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -2919,6 +4590,27 @@ func (f *FrequencyRange) GetExtraProperties() map[string]interface{} { return f.extraProperties } +func (f *FrequencyRange) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + +// SetMinimumFrequencyHz sets the MinimumFrequencyHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FrequencyRange) SetMinimumFrequencyHz(minimumFrequencyHz *Frequency) { + f.MinimumFrequencyHz = minimumFrequencyHz + f.require(frequencyRangeFieldMinimumFrequencyHz) +} + +// SetMaximumFrequencyHz sets the MaximumFrequencyHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *FrequencyRange) SetMaximumFrequencyHz(maximumFrequencyHz *Frequency) { + f.MaximumFrequencyHz = maximumFrequencyHz + f.require(frequencyRangeFieldMaximumFrequencyHz) +} + func (f *FrequencyRange) UnmarshalJSON(data []byte) error { type unmarshaler FrequencyRange var value unmarshaler @@ -2935,6 +4627,17 @@ func (f *FrequencyRange) UnmarshalJSON(data []byte) error { return nil } +func (f *FrequencyRange) MarshalJSON() ([]byte, error) { + type embed FrequencyRange + var marshaler = struct { + embed + }{ + embed: embed(*f), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (f *FrequencyRange) String() string { if len(f.rawJSON) > 0 { if value, err := internal.StringifyJSON(f.rawJSON); err == nil { @@ -2948,6 +4651,17 @@ func (f *FrequencyRange) String() string { } // Fuel describes an entity's repository of fuels stores including current amount, operational requirements, and maximum authorized capacity +var ( + fuelFieldFuelID = big.NewInt(1 << 0) + fuelFieldName = big.NewInt(1 << 1) + fuelFieldReportedDate = big.NewInt(1 << 2) + fuelFieldAmountGallons = big.NewInt(1 << 3) + fuelFieldMaxAuthorizedCapacityGallons = big.NewInt(1 << 4) + fuelFieldOperationalRequirementGallons = big.NewInt(1 << 5) + fuelFieldDataClassification = big.NewInt(1 << 6) + fuelFieldDataSource = big.NewInt(1 << 7) +) + type Fuel struct { // unique fuel identifier FuelID *string `json:"fuelId,omitempty" url:"fuelId,omitempty"` @@ -2968,6 +4682,9 @@ type Fuel struct { // source of information DataSource *string `json:"dataSource,omitempty" url:"dataSource,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3032,6 +4749,69 @@ func (f *Fuel) GetExtraProperties() map[string]interface{} { return f.extraProperties } +func (f *Fuel) require(field *big.Int) { + if f.explicitFields == nil { + f.explicitFields = big.NewInt(0) + } + f.explicitFields.Or(f.explicitFields, field) +} + +// SetFuelID sets the FuelID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetFuelID(fuelID *string) { + f.FuelID = fuelID + f.require(fuelFieldFuelID) +} + +// SetName sets the Name field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetName(name *string) { + f.Name = name + f.require(fuelFieldName) +} + +// SetReportedDate sets the ReportedDate field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetReportedDate(reportedDate *time.Time) { + f.ReportedDate = reportedDate + f.require(fuelFieldReportedDate) +} + +// SetAmountGallons sets the AmountGallons field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetAmountGallons(amountGallons *int) { + f.AmountGallons = amountGallons + f.require(fuelFieldAmountGallons) +} + +// SetMaxAuthorizedCapacityGallons sets the MaxAuthorizedCapacityGallons field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetMaxAuthorizedCapacityGallons(maxAuthorizedCapacityGallons *int) { + f.MaxAuthorizedCapacityGallons = maxAuthorizedCapacityGallons + f.require(fuelFieldMaxAuthorizedCapacityGallons) +} + +// SetOperationalRequirementGallons sets the OperationalRequirementGallons field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetOperationalRequirementGallons(operationalRequirementGallons *int) { + f.OperationalRequirementGallons = operationalRequirementGallons + f.require(fuelFieldOperationalRequirementGallons) +} + +// SetDataClassification sets the DataClassification field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetDataClassification(dataClassification *Classification) { + f.DataClassification = dataClassification + f.require(fuelFieldDataClassification) +} + +// SetDataSource sets the DataSource field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (f *Fuel) SetDataSource(dataSource *string) { + f.DataSource = dataSource + f.require(fuelFieldDataSource) +} + func (f *Fuel) UnmarshalJSON(data []byte) error { type embed Fuel var unmarshaler = struct { @@ -3063,7 +4843,8 @@ func (f *Fuel) MarshalJSON() ([]byte, error) { embed: embed(*f), ReportedDate: internal.NewOptionalDateTime(f.ReportedDate), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields) + return json.Marshal(explicitMarshaler) } func (f *Fuel) String() string { @@ -3079,11 +4860,20 @@ func (f *Fuel) String() string { } // A component that describes a geo-entity. +var ( + geoDetailsFieldType = big.NewInt(1 << 0) + geoDetailsFieldControlArea = big.NewInt(1 << 1) + geoDetailsFieldAcm = big.NewInt(1 << 2) +) + type GeoDetails struct { Type *GeoDetailsType `json:"type,omitempty" url:"type,omitempty"` ControlArea *ControlAreaDetails `json:"controlArea,omitempty" url:"controlArea,omitempty"` Acm *AcmDetails `json:"acm,omitempty" url:"acm,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3113,6 +4903,34 @@ func (g *GeoDetails) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoDetails) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoDetails) SetType(type_ *GeoDetailsType) { + g.Type = type_ + g.require(geoDetailsFieldType) +} + +// SetControlArea sets the ControlArea field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoDetails) SetControlArea(controlArea *ControlAreaDetails) { + g.ControlArea = controlArea + g.require(geoDetailsFieldControlArea) +} + +// SetAcm sets the Acm field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoDetails) SetAcm(acm *AcmDetails) { + g.Acm = acm + g.require(geoDetailsFieldAcm) +} + func (g *GeoDetails) UnmarshalJSON(data []byte) error { type unmarshaler GeoDetails var value unmarshaler @@ -3129,6 +4947,17 @@ func (g *GeoDetails) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoDetails) MarshalJSON() ([]byte, error) { + type embed GeoDetails + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoDetails) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3185,6 +5014,13 @@ func (g GeoDetailsType) Ptr() *GeoDetailsType { // // For a circle, the major and minor axis would be the same values. // This shape is NOT Geo-JSON compatible. +var ( + geoEllipseFieldSemiMajorAxisM = big.NewInt(1 << 0) + geoEllipseFieldSemiMinorAxisM = big.NewInt(1 << 1) + geoEllipseFieldOrientationD = big.NewInt(1 << 2) + geoEllipseFieldHeightM = big.NewInt(1 << 3) +) + type GeoEllipse struct { // Defines the distance from the center point of the ellipse to the furthest distance on the perimeter in meters. SemiMajorAxisM *float64 `json:"semiMajorAxisM,omitempty" url:"semiMajorAxisM,omitempty"` @@ -3195,6 +5031,9 @@ type GeoEllipse struct { // Optional height above entity position to extrude in meters. A non-zero value creates an elliptic cylinder HeightM *float64 `json:"heightM,omitempty" url:"heightM,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3231,6 +5070,41 @@ func (g *GeoEllipse) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoEllipse) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetSemiMajorAxisM sets the SemiMajorAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipse) SetSemiMajorAxisM(semiMajorAxisM *float64) { + g.SemiMajorAxisM = semiMajorAxisM + g.require(geoEllipseFieldSemiMajorAxisM) +} + +// SetSemiMinorAxisM sets the SemiMinorAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipse) SetSemiMinorAxisM(semiMinorAxisM *float64) { + g.SemiMinorAxisM = semiMinorAxisM + g.require(geoEllipseFieldSemiMinorAxisM) +} + +// SetOrientationD sets the OrientationD field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipse) SetOrientationD(orientationD *float64) { + g.OrientationD = orientationD + g.require(geoEllipseFieldOrientationD) +} + +// SetHeightM sets the HeightM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipse) SetHeightM(heightM *float64) { + g.HeightM = heightM + g.require(geoEllipseFieldHeightM) +} + func (g *GeoEllipse) UnmarshalJSON(data []byte) error { type unmarshaler GeoEllipse var value unmarshaler @@ -3247,6 +5121,17 @@ func (g *GeoEllipse) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoEllipse) MarshalJSON() ([]byte, error) { + type embed GeoEllipse + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoEllipse) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3263,6 +5148,12 @@ func (g *GeoEllipse) String() string { // // Principal axis lengths are defined in entity body space // This shape is NOT Geo-JSON compatible. +var ( + geoEllipsoidFieldForwardAxisM = big.NewInt(1 << 0) + geoEllipsoidFieldSideAxisM = big.NewInt(1 << 1) + geoEllipsoidFieldUpAxisM = big.NewInt(1 << 2) +) + type GeoEllipsoid struct { // Defines the distance from the center point to the surface along the forward axis ForwardAxisM *float64 `json:"forwardAxisM,omitempty" url:"forwardAxisM,omitempty"` @@ -3271,6 +5162,9 @@ type GeoEllipsoid struct { // Defines the distance from the center point to the surface along the up axis UpAxisM *float64 `json:"upAxisM,omitempty" url:"upAxisM,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3300,6 +5194,34 @@ func (g *GeoEllipsoid) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoEllipsoid) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetForwardAxisM sets the ForwardAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipsoid) SetForwardAxisM(forwardAxisM *float64) { + g.ForwardAxisM = forwardAxisM + g.require(geoEllipsoidFieldForwardAxisM) +} + +// SetSideAxisM sets the SideAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipsoid) SetSideAxisM(sideAxisM *float64) { + g.SideAxisM = sideAxisM + g.require(geoEllipsoidFieldSideAxisM) +} + +// SetUpAxisM sets the UpAxisM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoEllipsoid) SetUpAxisM(upAxisM *float64) { + g.UpAxisM = upAxisM + g.require(geoEllipsoidFieldUpAxisM) +} + func (g *GeoEllipsoid) UnmarshalJSON(data []byte) error { type unmarshaler GeoEllipsoid var value unmarshaler @@ -3316,6 +5238,17 @@ func (g *GeoEllipsoid) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoEllipsoid) MarshalJSON() ([]byte, error) { + type embed GeoEllipsoid + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoEllipsoid) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3331,9 +5264,16 @@ func (g *GeoEllipsoid) String() string { // A line shaped geo-entity. // // See https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4 +var ( + geoLineFieldPositions = big.NewInt(1 << 0) +) + type GeoLine struct { Positions []*Position `json:"positions,omitempty" url:"positions,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3349,6 +5289,20 @@ func (g *GeoLine) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoLine) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetPositions sets the Positions field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoLine) SetPositions(positions []*Position) { + g.Positions = positions + g.require(geoLineFieldPositions) +} + func (g *GeoLine) UnmarshalJSON(data []byte) error { type unmarshaler GeoLine var value unmarshaler @@ -3365,6 +5319,17 @@ func (g *GeoLine) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoLine) MarshalJSON() ([]byte, error) { + type embed GeoLine + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoLine) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3380,9 +5345,16 @@ func (g *GeoLine) String() string { // A point shaped geo-entity. // // See https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2 +var ( + geoPointFieldPosition = big.NewInt(1 << 0) +) + type GeoPoint struct { Position *Position `json:"position,omitempty" url:"position,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3398,6 +5370,20 @@ func (g *GeoPoint) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoPoint) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetPosition sets the Position field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoPoint) SetPosition(position *Position) { + g.Position = position + g.require(geoPointFieldPosition) +} + func (g *GeoPoint) UnmarshalJSON(data []byte) error { type unmarshaler GeoPoint var value unmarshaler @@ -3414,6 +5400,17 @@ func (g *GeoPoint) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoPoint) MarshalJSON() ([]byte, error) { + type embed GeoPoint + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoPoint) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3429,6 +5426,11 @@ func (g *GeoPoint) String() string { // A polygon shaped geo-entity. // // See https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6, only canonical representations accepted +var ( + geoPolygonFieldRings = big.NewInt(1 << 0) + geoPolygonFieldIsRectangle = big.NewInt(1 << 1) +) + type GeoPolygon struct { // An array of LinearRings where the first item is the exterior ring and subsequent items are interior rings. Rings []*LinearRing `json:"rings,omitempty" url:"rings,omitempty"` @@ -3438,6 +5440,9 @@ type GeoPolygon struct { // - each point has the same height (either all present and equal, or all not present) IsRectangle *bool `json:"isRectangle,omitempty" url:"isRectangle,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3460,6 +5465,27 @@ func (g *GeoPolygon) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoPolygon) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetRings sets the Rings field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoPolygon) SetRings(rings []*LinearRing) { + g.Rings = rings + g.require(geoPolygonFieldRings) +} + +// SetIsRectangle sets the IsRectangle field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoPolygon) SetIsRectangle(isRectangle *bool) { + g.IsRectangle = isRectangle + g.require(geoPolygonFieldIsRectangle) +} + func (g *GeoPolygon) UnmarshalJSON(data []byte) error { type unmarshaler GeoPolygon var value unmarshaler @@ -3476,6 +5502,17 @@ func (g *GeoPolygon) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoPolygon) MarshalJSON() ([]byte, error) { + type embed GeoPolygon + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoPolygon) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3489,6 +5526,11 @@ func (g *GeoPolygon) String() string { } // A position in a GeoPolygon with an optional extruded height. +var ( + geoPolygonPositionFieldPosition = big.NewInt(1 << 0) + geoPolygonPositionFieldHeightM = big.NewInt(1 << 1) +) + type GeoPolygonPosition struct { // base position. if no altitude set, its on the ground. Position *Position `json:"position,omitempty" url:"position,omitempty"` @@ -3498,6 +5540,9 @@ type GeoPolygonPosition struct { // strictly GeoJSON compatible polygons will not have this set. HeightM *float64 `json:"heightM,omitempty" url:"heightM,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3520,6 +5565,27 @@ func (g *GeoPolygonPosition) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoPolygonPosition) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetPosition sets the Position field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoPolygonPosition) SetPosition(position *Position) { + g.Position = position + g.require(geoPolygonPositionFieldPosition) +} + +// SetHeightM sets the HeightM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoPolygonPosition) SetHeightM(heightM *float64) { + g.HeightM = heightM + g.require(geoPolygonPositionFieldHeightM) +} + func (g *GeoPolygonPosition) UnmarshalJSON(data []byte) error { type unmarshaler GeoPolygonPosition var value unmarshaler @@ -3536,6 +5602,17 @@ func (g *GeoPolygonPosition) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoPolygonPosition) MarshalJSON() ([]byte, error) { + type embed GeoPolygonPosition + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoPolygonPosition) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3549,6 +5626,14 @@ func (g *GeoPolygonPosition) String() string { } // A component that describes the shape of a geo-entity. +var ( + geoShapeFieldPoint = big.NewInt(1 << 0) + geoShapeFieldLine = big.NewInt(1 << 1) + geoShapeFieldPolygon = big.NewInt(1 << 2) + geoShapeFieldEllipse = big.NewInt(1 << 3) + geoShapeFieldEllipsoid = big.NewInt(1 << 4) +) + type GeoShape struct { Point *GeoPoint `json:"point,omitempty" url:"point,omitempty"` Line *GeoLine `json:"line,omitempty" url:"line,omitempty"` @@ -3556,6 +5641,9 @@ type GeoShape struct { Ellipse *GeoEllipse `json:"ellipse,omitempty" url:"ellipse,omitempty"` Ellipsoid *GeoEllipsoid `json:"ellipsoid,omitempty" url:"ellipsoid,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3599,6 +5687,48 @@ func (g *GeoShape) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GeoShape) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetPoint sets the Point field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoShape) SetPoint(point *GeoPoint) { + g.Point = point + g.require(geoShapeFieldPoint) +} + +// SetLine sets the Line field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoShape) SetLine(line *GeoLine) { + g.Line = line + g.require(geoShapeFieldLine) +} + +// SetPolygon sets the Polygon field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoShape) SetPolygon(polygon *GeoPolygon) { + g.Polygon = polygon + g.require(geoShapeFieldPolygon) +} + +// SetEllipse sets the Ellipse field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoShape) SetEllipse(ellipse *GeoEllipse) { + g.Ellipse = ellipse + g.require(geoShapeFieldEllipse) +} + +// SetEllipsoid sets the Ellipsoid field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GeoShape) SetEllipsoid(ellipsoid *GeoEllipsoid) { + g.Ellipsoid = ellipsoid + g.require(geoShapeFieldEllipsoid) +} + func (g *GeoShape) UnmarshalJSON(data []byte) error { type unmarshaler GeoShape var value unmarshaler @@ -3615,6 +5745,17 @@ func (g *GeoShape) UnmarshalJSON(data []byte) error { return nil } +func (g *GeoShape) MarshalJSON() ([]byte, error) { + type embed GeoShape + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GeoShape) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3627,11 +5768,18 @@ func (g *GeoShape) String() string { return fmt.Sprintf("%#v", g) } -// Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. +// Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. +var ( + googleProtobufAnyFieldType = big.NewInt(1 << 0) +) + type GoogleProtobufAny struct { // The type of the serialized message. Type *string `json:"@type,omitempty" url:"@type,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + ExtraProperties map[string]interface{} `json:"-" url:"-"` rawJSON json.RawMessage @@ -3648,6 +5796,20 @@ func (g *GoogleProtobufAny) GetExtraProperties() map[string]interface{} { return g.ExtraProperties } +func (g *GoogleProtobufAny) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GoogleProtobufAny) SetType(type_ *string) { + g.Type = type_ + g.require(googleProtobufAnyFieldType) +} + func (g *GoogleProtobufAny) UnmarshalJSON(data []byte) error { type embed GoogleProtobufAny var unmarshaler = struct { @@ -3675,7 +5837,8 @@ func (g *GoogleProtobufAny) MarshalJSON() ([]byte, error) { }{ embed: embed(*g), } - return internal.MarshalJSONWithExtraProperties(marshaler, g.ExtraProperties) + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return internal.MarshalJSONWithExtraProperties(explicitMarshaler, g.ExtraProperties) } func (g *GoogleProtobufAny) String() string { @@ -3695,6 +5858,10 @@ func (g *GoogleProtobufAny) String() string { // represents an Entity Group and (2) the related entity is a child member of this group. The presence of this // relationship alone determines that the type of group is an Entity Group. type GroupChild struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3703,6 +5870,13 @@ func (g *GroupChild) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GroupChild) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + func (g *GroupChild) UnmarshalJSON(data []byte) error { type unmarshaler GroupChild var value unmarshaler @@ -3719,6 +5893,17 @@ func (g *GroupChild) UnmarshalJSON(data []byte) error { return nil } +func (g *GroupChild) MarshalJSON() ([]byte, error) { + type embed GroupChild + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GroupChild) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3732,10 +5917,18 @@ func (g *GroupChild) String() string { } // Details related to grouping for this entity +var ( + groupDetailsFieldTeam = big.NewInt(1 << 0) + groupDetailsFieldEchelon = big.NewInt(1 << 1) +) + type GroupDetails struct { Team *Team `json:"team,omitempty" url:"team,omitempty"` Echelon *Echelon `json:"echelon,omitempty" url:"echelon,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3758,6 +5951,27 @@ func (g *GroupDetails) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GroupDetails) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + +// SetTeam sets the Team field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GroupDetails) SetTeam(team *Team) { + g.Team = team + g.require(groupDetailsFieldTeam) +} + +// SetEchelon sets the Echelon field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (g *GroupDetails) SetEchelon(echelon *Echelon) { + g.Echelon = echelon + g.require(groupDetailsFieldEchelon) +} + func (g *GroupDetails) UnmarshalJSON(data []byte) error { type unmarshaler GroupDetails var value unmarshaler @@ -3774,6 +5988,17 @@ func (g *GroupDetails) UnmarshalJSON(data []byte) error { return nil } +func (g *GroupDetails) MarshalJSON() ([]byte, error) { + type embed GroupDetails + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GroupDetails) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3791,6 +6016,10 @@ func (g *GroupDetails) String() string { // the Entity Group represented by the related entity. The presence of this relationship alone determines that // the type of group that this entity is a member of is an Entity Group. type GroupParent struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3799,6 +6028,13 @@ func (g *GroupParent) GetExtraProperties() map[string]interface{} { return g.extraProperties } +func (g *GroupParent) require(field *big.Int) { + if g.explicitFields == nil { + g.explicitFields = big.NewInt(0) + } + g.explicitFields.Or(g.explicitFields, field) +} + func (g *GroupParent) UnmarshalJSON(data []byte) error { type unmarshaler GroupParent var value unmarshaler @@ -3815,6 +6051,17 @@ func (g *GroupParent) UnmarshalJSON(data []byte) error { return nil } +func (g *GroupParent) MarshalJSON() ([]byte, error) { + type embed GroupParent + var marshaler = struct { + embed + }{ + embed: embed(*g), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (g *GroupParent) String() string { if len(g.rawJSON) > 0 { if value, err := internal.StringifyJSON(g.rawJSON); err == nil { @@ -3828,6 +6075,14 @@ func (g *GroupParent) String() string { } // General health of the entity as reported by the entity. +var ( + healthFieldConnectionStatus = big.NewInt(1 << 0) + healthFieldHealthStatus = big.NewInt(1 << 1) + healthFieldComponents = big.NewInt(1 << 2) + healthFieldUpdateTime = big.NewInt(1 << 3) + healthFieldActiveAlerts = big.NewInt(1 << 4) +) + type Health struct { // Status indicating whether the entity is able to communicate with Entity Manager. ConnectionStatus *HealthConnectionStatus `json:"connectionStatus,omitempty" url:"connectionStatus,omitempty"` @@ -3848,6 +6103,9 @@ type Health struct { // are cleared. In other words, only active alerts should be reported here. ActiveAlerts []*Alert `json:"activeAlerts,omitempty" url:"activeAlerts,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -3891,6 +6149,48 @@ func (h *Health) GetExtraProperties() map[string]interface{} { return h.extraProperties } +func (h *Health) require(field *big.Int) { + if h.explicitFields == nil { + h.explicitFields = big.NewInt(0) + } + h.explicitFields.Or(h.explicitFields, field) +} + +// SetConnectionStatus sets the ConnectionStatus field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *Health) SetConnectionStatus(connectionStatus *HealthConnectionStatus) { + h.ConnectionStatus = connectionStatus + h.require(healthFieldConnectionStatus) +} + +// SetHealthStatus sets the HealthStatus field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *Health) SetHealthStatus(healthStatus *HealthHealthStatus) { + h.HealthStatus = healthStatus + h.require(healthFieldHealthStatus) +} + +// SetComponents sets the Components field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *Health) SetComponents(components []*ComponentHealth) { + h.Components = components + h.require(healthFieldComponents) +} + +// SetUpdateTime sets the UpdateTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *Health) SetUpdateTime(updateTime *time.Time) { + h.UpdateTime = updateTime + h.require(healthFieldUpdateTime) +} + +// SetActiveAlerts sets the ActiveAlerts field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *Health) SetActiveAlerts(activeAlerts []*Alert) { + h.ActiveAlerts = activeAlerts + h.require(healthFieldActiveAlerts) +} + func (h *Health) UnmarshalJSON(data []byte) error { type embed Health var unmarshaler = struct { @@ -3922,7 +6222,8 @@ func (h *Health) MarshalJSON() ([]byte, error) { embed: embed(*h), UpdateTime: internal.NewOptionalDateTime(h.UpdateTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, h.explicitFields) + return json.Marshal(explicitMarshaler) } func (h *Health) String() string { @@ -3999,6 +6300,13 @@ func (h HealthHealthStatus) Ptr() *HealthHealthStatus { } // Describes whether something is a high value target or not. +var ( + highValueTargetFieldIsHighValueTarget = big.NewInt(1 << 0) + highValueTargetFieldTargetPriority = big.NewInt(1 << 1) + highValueTargetFieldTargetMatches = big.NewInt(1 << 2) + highValueTargetFieldIsHighPayoffTarget = big.NewInt(1 << 3) +) + type HighValueTarget struct { // Indicates whether the target matches any description from a high value target list. IsHighValueTarget *bool `json:"isHighValueTarget,omitempty" url:"isHighValueTarget,omitempty"` @@ -4014,6 +6322,9 @@ type HighValueTarget struct { // Indicates whether the target is a 'High Payoff Target'. Targets can be one or both of high value and high payoff. IsHighPayoffTarget *bool `json:"isHighPayoffTarget,omitempty" url:"isHighPayoffTarget,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4050,6 +6361,41 @@ func (h *HighValueTarget) GetExtraProperties() map[string]interface{} { return h.extraProperties } +func (h *HighValueTarget) require(field *big.Int) { + if h.explicitFields == nil { + h.explicitFields = big.NewInt(0) + } + h.explicitFields.Or(h.explicitFields, field) +} + +// SetIsHighValueTarget sets the IsHighValueTarget field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTarget) SetIsHighValueTarget(isHighValueTarget *bool) { + h.IsHighValueTarget = isHighValueTarget + h.require(highValueTargetFieldIsHighValueTarget) +} + +// SetTargetPriority sets the TargetPriority field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTarget) SetTargetPriority(targetPriority *int) { + h.TargetPriority = targetPriority + h.require(highValueTargetFieldTargetPriority) +} + +// SetTargetMatches sets the TargetMatches field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTarget) SetTargetMatches(targetMatches []*HighValueTargetMatch) { + h.TargetMatches = targetMatches + h.require(highValueTargetFieldTargetMatches) +} + +// SetIsHighPayoffTarget sets the IsHighPayoffTarget field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTarget) SetIsHighPayoffTarget(isHighPayoffTarget *bool) { + h.IsHighPayoffTarget = isHighPayoffTarget + h.require(highValueTargetFieldIsHighPayoffTarget) +} + func (h *HighValueTarget) UnmarshalJSON(data []byte) error { type unmarshaler HighValueTarget var value unmarshaler @@ -4066,6 +6412,17 @@ func (h *HighValueTarget) UnmarshalJSON(data []byte) error { return nil } +func (h *HighValueTarget) MarshalJSON() ([]byte, error) { + type embed HighValueTarget + var marshaler = struct { + embed + }{ + embed: embed(*h), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, h.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (h *HighValueTarget) String() string { if len(h.rawJSON) > 0 { if value, err := internal.StringifyJSON(h.rawJSON); err == nil { @@ -4078,6 +6435,11 @@ func (h *HighValueTarget) String() string { return fmt.Sprintf("%#v", h) } +var ( + highValueTargetMatchFieldHighValueTargetListID = big.NewInt(1 << 0) + highValueTargetMatchFieldHighValueTargetDescriptionID = big.NewInt(1 << 1) +) + type HighValueTargetMatch struct { // The ID of the high value target list that matches the target description. HighValueTargetListID *string `json:"highValueTargetListId,omitempty" url:"highValueTargetListId,omitempty"` @@ -4086,6 +6448,9 @@ type HighValueTargetMatch struct { // The ID is considered to be a globally unique identifier across all high value target IDs. HighValueTargetDescriptionID *string `json:"highValueTargetDescriptionId,omitempty" url:"highValueTargetDescriptionId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4108,6 +6473,27 @@ func (h *HighValueTargetMatch) GetExtraProperties() map[string]interface{} { return h.extraProperties } +func (h *HighValueTargetMatch) require(field *big.Int) { + if h.explicitFields == nil { + h.explicitFields = big.NewInt(0) + } + h.explicitFields.Or(h.explicitFields, field) +} + +// SetHighValueTargetListID sets the HighValueTargetListID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTargetMatch) SetHighValueTargetListID(highValueTargetListID *string) { + h.HighValueTargetListID = highValueTargetListID + h.require(highValueTargetMatchFieldHighValueTargetListID) +} + +// SetHighValueTargetDescriptionID sets the HighValueTargetDescriptionID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (h *HighValueTargetMatch) SetHighValueTargetDescriptionID(highValueTargetDescriptionID *string) { + h.HighValueTargetDescriptionID = highValueTargetDescriptionID + h.require(highValueTargetMatchFieldHighValueTargetDescriptionID) +} + func (h *HighValueTargetMatch) UnmarshalJSON(data []byte) error { type unmarshaler HighValueTargetMatch var value unmarshaler @@ -4124,6 +6510,17 @@ func (h *HighValueTargetMatch) UnmarshalJSON(data []byte) error { return nil } +func (h *HighValueTargetMatch) MarshalJSON() ([]byte, error) { + type embed HighValueTargetMatch + var marshaler = struct { + embed + }{ + embed: embed(*h), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, h.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (h *HighValueTargetMatch) String() string { if len(h.rawJSON) > 0 { if value, err := internal.StringifyJSON(h.rawJSON); err == nil { @@ -4137,6 +6534,15 @@ func (h *HighValueTargetMatch) String() string { } // Indicators to describe entity to consumers. +var ( + indicatorsFieldSimulated = big.NewInt(1 << 0) + indicatorsFieldExercise = big.NewInt(1 << 1) + indicatorsFieldEmergency = big.NewInt(1 << 2) + indicatorsFieldC2 = big.NewInt(1 << 3) + indicatorsFieldEgressable = big.NewInt(1 << 4) + indicatorsFieldStarred = big.NewInt(1 << 5) +) + type Indicators struct { Simulated *bool `json:"simulated,omitempty" url:"simulated,omitempty"` Exercise *bool `json:"exercise,omitempty" url:"exercise,omitempty"` @@ -4149,6 +6555,9 @@ type Indicators struct { // A signal of arbitrary importance such that the entity should be globally marked for all users Starred *bool `json:"starred,omitempty" url:"starred,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4199,6 +6608,55 @@ func (i *Indicators) GetExtraProperties() map[string]interface{} { return i.extraProperties } +func (i *Indicators) require(field *big.Int) { + if i.explicitFields == nil { + i.explicitFields = big.NewInt(0) + } + i.explicitFields.Or(i.explicitFields, field) +} + +// SetSimulated sets the Simulated field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetSimulated(simulated *bool) { + i.Simulated = simulated + i.require(indicatorsFieldSimulated) +} + +// SetExercise sets the Exercise field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetExercise(exercise *bool) { + i.Exercise = exercise + i.require(indicatorsFieldExercise) +} + +// SetEmergency sets the Emergency field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetEmergency(emergency *bool) { + i.Emergency = emergency + i.require(indicatorsFieldEmergency) +} + +// SetC2 sets the C2 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetC2(c2 *bool) { + i.C2 = c2 + i.require(indicatorsFieldC2) +} + +// SetEgressable sets the Egressable field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetEgressable(egressable *bool) { + i.Egressable = egressable + i.require(indicatorsFieldEgressable) +} + +// SetStarred sets the Starred field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (i *Indicators) SetStarred(starred *bool) { + i.Starred = starred + i.require(indicatorsFieldStarred) +} + func (i *Indicators) UnmarshalJSON(data []byte) error { type unmarshaler Indicators var value unmarshaler @@ -4215,6 +6673,17 @@ func (i *Indicators) UnmarshalJSON(data []byte) error { return nil } +func (i *Indicators) MarshalJSON() ([]byte, error) { + type embed Indicators + var marshaler = struct { + embed + }{ + embed: embed(*i), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, i.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (i *Indicators) String() string { if len(i.rawJSON) > 0 { if value, err := internal.StringifyJSON(i.rawJSON); err == nil { @@ -4228,6 +6697,12 @@ func (i *Indicators) String() string { } // A line of bearing of a signal. +var ( + lineOfBearingFieldAngleOfArrival = big.NewInt(1 << 0) + lineOfBearingFieldRangeEstimateM = big.NewInt(1 << 1) + lineOfBearingFieldMaxRangeM = big.NewInt(1 << 2) +) + type LineOfBearing struct { // The direction pointing from this entity to the detection AngleOfArrival *AngleOfArrival `json:"angleOfArrival,omitempty" url:"angleOfArrival,omitempty"` @@ -4236,6 +6711,9 @@ type LineOfBearing struct { // The maximum distance of the detection MaxRangeM *Measurement `json:"maxRangeM,omitempty" url:"maxRangeM,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4265,6 +6743,34 @@ func (l *LineOfBearing) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *LineOfBearing) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetAngleOfArrival sets the AngleOfArrival field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LineOfBearing) SetAngleOfArrival(angleOfArrival *AngleOfArrival) { + l.AngleOfArrival = angleOfArrival + l.require(lineOfBearingFieldAngleOfArrival) +} + +// SetRangeEstimateM sets the RangeEstimateM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LineOfBearing) SetRangeEstimateM(rangeEstimateM *Measurement) { + l.RangeEstimateM = rangeEstimateM + l.require(lineOfBearingFieldRangeEstimateM) +} + +// SetMaxRangeM sets the MaxRangeM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LineOfBearing) SetMaxRangeM(maxRangeM *Measurement) { + l.MaxRangeM = maxRangeM + l.require(lineOfBearingFieldMaxRangeM) +} + func (l *LineOfBearing) UnmarshalJSON(data []byte) error { type unmarshaler LineOfBearing var value unmarshaler @@ -4281,6 +6787,17 @@ func (l *LineOfBearing) UnmarshalJSON(data []byte) error { return nil } +func (l *LineOfBearing) MarshalJSON() ([]byte, error) { + type embed LineOfBearing + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *LineOfBearing) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -4294,9 +6811,16 @@ func (l *LineOfBearing) String() string { } // A closed ring of points. The first and last point must be the same. +var ( + linearRingFieldPositions = big.NewInt(1 << 0) +) + type LinearRing struct { Positions []*GeoPolygonPosition `json:"positions,omitempty" url:"positions,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4312,6 +6836,20 @@ func (l *LinearRing) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *LinearRing) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetPositions sets the Positions field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LinearRing) SetPositions(positions []*GeoPolygonPosition) { + l.Positions = positions + l.require(linearRingFieldPositions) +} + func (l *LinearRing) UnmarshalJSON(data []byte) error { type unmarshaler LinearRing var value unmarshaler @@ -4328,6 +6866,17 @@ func (l *LinearRing) UnmarshalJSON(data []byte) error { return nil } +func (l *LinearRing) MarshalJSON() ([]byte, error) { + type embed LinearRing + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *LinearRing) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -4340,6 +6889,14 @@ func (l *LinearRing) String() string { return fmt.Sprintf("%#v", l) } +var ( + llaFieldLon = big.NewInt(1 << 0) + llaFieldLat = big.NewInt(1 << 1) + llaFieldAlt = big.NewInt(1 << 2) + llaFieldIs2D = big.NewInt(1 << 3) + llaFieldAltitudeReference = big.NewInt(1 << 4) +) + type Lla struct { Lon *float64 `json:"lon,omitempty" url:"lon,omitempty"` Lat *float64 `json:"lat,omitempty" url:"lat,omitempty"` @@ -4351,6 +6908,9 @@ type Lla struct { // determine what zero means. AltitudeReference *LlaAltitudeReference `json:"altitudeReference,omitempty" url:"altitudeReference,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4394,6 +6954,48 @@ func (l *Lla) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *Lla) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetLon sets the Lon field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Lla) SetLon(lon *float64) { + l.Lon = lon + l.require(llaFieldLon) +} + +// SetLat sets the Lat field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Lla) SetLat(lat *float64) { + l.Lat = lat + l.require(llaFieldLat) +} + +// SetAlt sets the Alt field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Lla) SetAlt(alt *float64) { + l.Alt = alt + l.require(llaFieldAlt) +} + +// SetIs2D sets the Is2D field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Lla) SetIs2D(is2D *bool) { + l.Is2D = is2D + l.require(llaFieldIs2D) +} + +// SetAltitudeReference sets the AltitudeReference field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Lla) SetAltitudeReference(altitudeReference *LlaAltitudeReference) { + l.AltitudeReference = altitudeReference + l.require(llaFieldAltitudeReference) +} + func (l *Lla) UnmarshalJSON(data []byte) error { type unmarshaler Lla var value unmarshaler @@ -4410,6 +7012,17 @@ func (l *Lla) UnmarshalJSON(data []byte) error { return nil } +func (l *Lla) MarshalJSON() ([]byte, error) { + type embed Lla + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *Lla) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -4464,6 +7077,14 @@ func (l LlaAltitudeReference) Ptr() *LlaAltitudeReference { } // Available for Entities that have a single or primary Location. +var ( + locationFieldPosition = big.NewInt(1 << 0) + locationFieldVelocityEnu = big.NewInt(1 << 1) + locationFieldSpeedMps = big.NewInt(1 << 2) + locationFieldAcceleration = big.NewInt(1 << 3) + locationFieldAttitudeEnu = big.NewInt(1 << 4) +) + type Location struct { // see Position definition for details. Position *Position `json:"position,omitempty" url:"position,omitempty"` @@ -4476,6 +7097,9 @@ type Location struct { // quaternion to translate from entity body frame to it's ENU frame AttitudeEnu *Quaternion `json:"attitudeEnu,omitempty" url:"attitudeEnu,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4519,6 +7143,48 @@ func (l *Location) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *Location) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetPosition sets the Position field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Location) SetPosition(position *Position) { + l.Position = position + l.require(locationFieldPosition) +} + +// SetVelocityEnu sets the VelocityEnu field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Location) SetVelocityEnu(velocityEnu *Enu) { + l.VelocityEnu = velocityEnu + l.require(locationFieldVelocityEnu) +} + +// SetSpeedMps sets the SpeedMps field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Location) SetSpeedMps(speedMps *float64) { + l.SpeedMps = speedMps + l.require(locationFieldSpeedMps) +} + +// SetAcceleration sets the Acceleration field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Location) SetAcceleration(acceleration *Enu) { + l.Acceleration = acceleration + l.require(locationFieldAcceleration) +} + +// SetAttitudeEnu sets the AttitudeEnu field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *Location) SetAttitudeEnu(attitudeEnu *Quaternion) { + l.AttitudeEnu = attitudeEnu + l.require(locationFieldAttitudeEnu) +} + func (l *Location) UnmarshalJSON(data []byte) error { type unmarshaler Location var value unmarshaler @@ -4535,6 +7201,17 @@ func (l *Location) UnmarshalJSON(data []byte) error { return nil } +func (l *Location) MarshalJSON() ([]byte, error) { + type embed Location + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *Location) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -4548,6 +7225,12 @@ func (l *Location) String() string { } // Uncertainty of entity position and velocity, if available. +var ( + locationUncertaintyFieldPositionEnuCov = big.NewInt(1 << 0) + locationUncertaintyFieldVelocityEnuCov = big.NewInt(1 << 1) + locationUncertaintyFieldPositionErrorEllipse = big.NewInt(1 << 2) +) + type LocationUncertainty struct { // Positional covariance represented by the upper triangle of the covariance matrix. It is valid to populate // @@ -4560,6 +7243,9 @@ type LocationUncertainty struct { // An ellipse that describes the certainty probability and error boundary for a given geolocation. PositionErrorEllipse *ErrorEllipse `json:"positionErrorEllipse,omitempty" url:"positionErrorEllipse,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4589,6 +7275,34 @@ func (l *LocationUncertainty) GetExtraProperties() map[string]interface{} { return l.extraProperties } +func (l *LocationUncertainty) require(field *big.Int) { + if l.explicitFields == nil { + l.explicitFields = big.NewInt(0) + } + l.explicitFields.Or(l.explicitFields, field) +} + +// SetPositionEnuCov sets the PositionEnuCov field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LocationUncertainty) SetPositionEnuCov(positionEnuCov *TMat3) { + l.PositionEnuCov = positionEnuCov + l.require(locationUncertaintyFieldPositionEnuCov) +} + +// SetVelocityEnuCov sets the VelocityEnuCov field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LocationUncertainty) SetVelocityEnuCov(velocityEnuCov *TMat3) { + l.VelocityEnuCov = velocityEnuCov + l.require(locationUncertaintyFieldVelocityEnuCov) +} + +// SetPositionErrorEllipse sets the PositionErrorEllipse field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (l *LocationUncertainty) SetPositionErrorEllipse(positionErrorEllipse *ErrorEllipse) { + l.PositionErrorEllipse = positionErrorEllipse + l.require(locationUncertaintyFieldPositionErrorEllipse) +} + func (l *LocationUncertainty) UnmarshalJSON(data []byte) error { type unmarshaler LocationUncertainty var value unmarshaler @@ -4605,6 +7319,17 @@ func (l *LocationUncertainty) UnmarshalJSON(data []byte) error { return nil } +func (l *LocationUncertainty) MarshalJSON() ([]byte, error) { + type embed LocationUncertainty + var marshaler = struct { + embed + }{ + embed: embed(*l), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, l.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (l *LocationUncertainty) String() string { if len(l.rawJSON) > 0 { if value, err := internal.StringifyJSON(l.rawJSON); err == nil { @@ -4617,6 +7342,18 @@ func (l *LocationUncertainty) String() string { return fmt.Sprintf("%#v", l) } +var ( + meanKeplerianElementsFieldEpoch = big.NewInt(1 << 0) + meanKeplerianElementsFieldSemiMajorAxisKm = big.NewInt(1 << 1) + meanKeplerianElementsFieldMeanMotion = big.NewInt(1 << 2) + meanKeplerianElementsFieldEccentricity = big.NewInt(1 << 3) + meanKeplerianElementsFieldInclinationDeg = big.NewInt(1 << 4) + meanKeplerianElementsFieldRaOfAscNodeDeg = big.NewInt(1 << 5) + meanKeplerianElementsFieldArgOfPericenterDeg = big.NewInt(1 << 6) + meanKeplerianElementsFieldMeanAnomalyDeg = big.NewInt(1 << 7) + meanKeplerianElementsFieldGm = big.NewInt(1 << 8) +) + type MeanKeplerianElements struct { // UTC time of validity Epoch *time.Time `json:"epoch,omitempty" url:"epoch,omitempty"` @@ -4636,6 +7373,9 @@ type MeanKeplerianElements struct { // Optional: gravitational coefficient (Gravitational Constant x central mass) in kg^3 / s^2 Gm *float64 `json:"gm,omitempty" url:"gm,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4689,22 +7429,92 @@ func (m *MeanKeplerianElements) GetArgOfPericenterDeg() *float64 { return m.ArgOfPericenterDeg } -func (m *MeanKeplerianElements) GetMeanAnomalyDeg() *float64 { - if m == nil { - return nil - } - return m.MeanAnomalyDeg +func (m *MeanKeplerianElements) GetMeanAnomalyDeg() *float64 { + if m == nil { + return nil + } + return m.MeanAnomalyDeg +} + +func (m *MeanKeplerianElements) GetGm() *float64 { + if m == nil { + return nil + } + return m.Gm +} + +func (m *MeanKeplerianElements) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *MeanKeplerianElements) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetEpoch sets the Epoch field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetEpoch(epoch *time.Time) { + m.Epoch = epoch + m.require(meanKeplerianElementsFieldEpoch) +} + +// SetSemiMajorAxisKm sets the SemiMajorAxisKm field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetSemiMajorAxisKm(semiMajorAxisKm *float64) { + m.SemiMajorAxisKm = semiMajorAxisKm + m.require(meanKeplerianElementsFieldSemiMajorAxisKm) +} + +// SetMeanMotion sets the MeanMotion field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetMeanMotion(meanMotion *float64) { + m.MeanMotion = meanMotion + m.require(meanKeplerianElementsFieldMeanMotion) +} + +// SetEccentricity sets the Eccentricity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetEccentricity(eccentricity *float64) { + m.Eccentricity = eccentricity + m.require(meanKeplerianElementsFieldEccentricity) +} + +// SetInclinationDeg sets the InclinationDeg field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetInclinationDeg(inclinationDeg *float64) { + m.InclinationDeg = inclinationDeg + m.require(meanKeplerianElementsFieldInclinationDeg) +} + +// SetRaOfAscNodeDeg sets the RaOfAscNodeDeg field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetRaOfAscNodeDeg(raOfAscNodeDeg *float64) { + m.RaOfAscNodeDeg = raOfAscNodeDeg + m.require(meanKeplerianElementsFieldRaOfAscNodeDeg) +} + +// SetArgOfPericenterDeg sets the ArgOfPericenterDeg field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetArgOfPericenterDeg(argOfPericenterDeg *float64) { + m.ArgOfPericenterDeg = argOfPericenterDeg + m.require(meanKeplerianElementsFieldArgOfPericenterDeg) } -func (m *MeanKeplerianElements) GetGm() *float64 { - if m == nil { - return nil - } - return m.Gm +// SetMeanAnomalyDeg sets the MeanAnomalyDeg field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetMeanAnomalyDeg(meanAnomalyDeg *float64) { + m.MeanAnomalyDeg = meanAnomalyDeg + m.require(meanKeplerianElementsFieldMeanAnomalyDeg) } -func (m *MeanKeplerianElements) GetExtraProperties() map[string]interface{} { - return m.extraProperties +// SetGm sets the Gm field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MeanKeplerianElements) SetGm(gm *float64) { + m.Gm = gm + m.require(meanKeplerianElementsFieldGm) } func (m *MeanKeplerianElements) UnmarshalJSON(data []byte) error { @@ -4738,7 +7548,8 @@ func (m *MeanKeplerianElements) MarshalJSON() ([]byte, error) { embed: embed(*m), Epoch: internal.NewOptionalDateTime(m.Epoch), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) } func (m *MeanKeplerianElements) String() string { @@ -4754,12 +7565,20 @@ func (m *MeanKeplerianElements) String() string { } // A component that describes some measured value with error. +var ( + measurementFieldValue = big.NewInt(1 << 0) + measurementFieldSigma = big.NewInt(1 << 1) +) + type Measurement struct { // The value of the measurement. Value *float64 `json:"value,omitempty" url:"value,omitempty"` // Estimated one standard deviation in same unit as the value. Sigma *float64 `json:"sigma,omitempty" url:"sigma,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4782,6 +7601,27 @@ func (m *Measurement) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *Measurement) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetValue sets the Value field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Measurement) SetValue(value *float64) { + m.Value = value + m.require(measurementFieldValue) +} + +// SetSigma sets the Sigma field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Measurement) SetSigma(sigma *float64) { + m.Sigma = sigma + m.require(measurementFieldSigma) +} + func (m *Measurement) UnmarshalJSON(data []byte) error { type unmarshaler Measurement var value unmarshaler @@ -4798,6 +7638,17 @@ func (m *Measurement) UnmarshalJSON(data []byte) error { return nil } +func (m *Measurement) MarshalJSON() ([]byte, error) { + type embed Measurement + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *Measurement) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -4811,9 +7662,16 @@ func (m *Measurement) String() string { } // Media associated with an entity. +var ( + mediaFieldMedia = big.NewInt(1 << 0) +) + type Media struct { Media []*MediaItem `json:"media,omitempty" url:"media,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4829,6 +7687,20 @@ func (m *Media) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *Media) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetMedia sets the Media field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Media) SetMedia(media []*MediaItem) { + m.Media = media + m.require(mediaFieldMedia) +} + func (m *Media) UnmarshalJSON(data []byte) error { type unmarshaler Media var value unmarshaler @@ -4845,6 +7717,17 @@ func (m *Media) UnmarshalJSON(data []byte) error { return nil } +func (m *Media) MarshalJSON() ([]byte, error) { + type embed Media + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *Media) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -4857,11 +7740,19 @@ func (m *Media) String() string { return fmt.Sprintf("%#v", m) } +var ( + mediaItemFieldType = big.NewInt(1 << 0) + mediaItemFieldRelativePath = big.NewInt(1 << 1) +) + type MediaItem struct { Type *MediaItemType `json:"type,omitempty" url:"type,omitempty"` // The path, relative to the environment base URL, where media related to an entity can be accessed RelativePath *string `json:"relativePath,omitempty" url:"relativePath,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4884,6 +7775,27 @@ func (m *MediaItem) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *MediaItem) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MediaItem) SetType(type_ *MediaItemType) { + m.Type = type_ + m.require(mediaItemFieldType) +} + +// SetRelativePath sets the RelativePath field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MediaItem) SetRelativePath(relativePath *string) { + m.RelativePath = relativePath + m.require(mediaItemFieldRelativePath) +} + func (m *MediaItem) UnmarshalJSON(data []byte) error { type unmarshaler MediaItem var value unmarshaler @@ -4900,6 +7812,17 @@ func (m *MediaItem) UnmarshalJSON(data []byte) error { return nil } +func (m *MediaItem) MarshalJSON() ([]byte, error) { + type embed MediaItem + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *MediaItem) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -4941,6 +7864,10 @@ func (m MediaItemType) Ptr() *MediaItemType { // // data has at least partially been merged from the related entity. type MergedFrom struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -4949,6 +7876,13 @@ func (m *MergedFrom) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *MergedFrom) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + func (m *MergedFrom) UnmarshalJSON(data []byte) error { type unmarshaler MergedFrom var value unmarshaler @@ -4965,6 +7899,17 @@ func (m *MergedFrom) UnmarshalJSON(data []byte) error { return nil } +func (m *MergedFrom) MarshalJSON() ([]byte, error) { + type embed MergedFrom + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *MergedFrom) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -4978,11 +7923,20 @@ func (m *MergedFrom) String() string { } // Provides the disposition, environment, and nationality of an Entity. +var ( + milViewFieldDisposition = big.NewInt(1 << 0) + milViewFieldEnvironment = big.NewInt(1 << 1) + milViewFieldNationality = big.NewInt(1 << 2) +) + type MilView struct { Disposition *MilViewDisposition `json:"disposition,omitempty" url:"disposition,omitempty"` Environment *MilViewEnvironment `json:"environment,omitempty" url:"environment,omitempty"` Nationality *MilViewNationality `json:"nationality,omitempty" url:"nationality,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5012,6 +7966,34 @@ func (m *MilView) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *MilView) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetDisposition sets the Disposition field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MilView) SetDisposition(disposition *MilViewDisposition) { + m.Disposition = disposition + m.require(milViewFieldDisposition) +} + +// SetEnvironment sets the Environment field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MilView) SetEnvironment(environment *MilViewEnvironment) { + m.Environment = environment + m.require(milViewFieldEnvironment) +} + +// SetNationality sets the Nationality field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *MilView) SetNationality(nationality *MilViewNationality) { + m.Nationality = nationality + m.require(milViewFieldNationality) +} + func (m *MilView) UnmarshalJSON(data []byte) error { type unmarshaler MilView var value unmarshaler @@ -5028,6 +8010,17 @@ func (m *MilView) UnmarshalJSON(data []byte) error { return nil } +func (m *MilView) MarshalJSON() ([]byte, error) { + type embed MilView + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *MilView) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -5470,6 +8463,12 @@ func (m MilViewNationality) Ptr() *MilViewNationality { } // Describes the Mode 5 transponder interrogation status and codes. +var ( + mode5FieldMode5InterrogationResponse = big.NewInt(1 << 0) + mode5FieldMode5 = big.NewInt(1 << 1) + mode5FieldMode5PlatformID = big.NewInt(1 << 2) +) + type Mode5 struct { // The validity of the response from the Mode 5 interrogation. Mode5InterrogationResponse *Mode5Mode5InterrogationResponse `json:"mode5InterrogationResponse,omitempty" url:"mode5InterrogationResponse,omitempty"` @@ -5478,6 +8477,9 @@ type Mode5 struct { // The Mode 5 platform identification code. Mode5PlatformID *int `json:"mode5PlatformId,omitempty" url:"mode5PlatformId,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5507,6 +8509,34 @@ func (m *Mode5) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *Mode5) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetMode5InterrogationResponse sets the Mode5InterrogationResponse field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Mode5) SetMode5InterrogationResponse(mode5InterrogationResponse *Mode5Mode5InterrogationResponse) { + m.Mode5InterrogationResponse = mode5InterrogationResponse + m.require(mode5FieldMode5InterrogationResponse) +} + +// SetMode5 sets the Mode5 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Mode5) SetMode5(mode5 *int) { + m.Mode5 = mode5 + m.require(mode5FieldMode5) +} + +// SetMode5PlatformID sets the Mode5PlatformID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *Mode5) SetMode5PlatformID(mode5PlatformID *int) { + m.Mode5PlatformID = mode5PlatformID + m.require(mode5FieldMode5PlatformID) +} + func (m *Mode5) UnmarshalJSON(data []byte) error { type unmarshaler Mode5 var value unmarshaler @@ -5523,6 +8553,17 @@ func (m *Mode5) UnmarshalJSON(data []byte) error { return nil } +func (m *Mode5) MarshalJSON() ([]byte, error) { + type embed Mode5 + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *Mode5) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -5565,6 +8606,11 @@ func (m Mode5Mode5InterrogationResponse) Ptr() *Mode5Mode5InterrogationResponse } // Describes the Mode S codes. +var ( + modeSFieldID = big.NewInt(1 << 0) + modeSFieldAddress = big.NewInt(1 << 1) +) + type ModeS struct { // Mode S identifier which comprises of 8 alphanumeric characters. ID *string `json:"id,omitempty" url:"id,omitempty"` @@ -5573,6 +8619,9 @@ type ModeS struct { // considered unique. Address *int `json:"address,omitempty" url:"address,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5595,6 +8644,27 @@ func (m *ModeS) GetExtraProperties() map[string]interface{} { return m.extraProperties } +func (m *ModeS) require(field *big.Int) { + if m.explicitFields == nil { + m.explicitFields = big.NewInt(0) + } + m.explicitFields.Or(m.explicitFields, field) +} + +// SetID sets the ID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *ModeS) SetID(id *string) { + m.ID = id + m.require(modeSFieldID) +} + +// SetAddress sets the Address field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (m *ModeS) SetAddress(address *int) { + m.Address = address + m.require(modeSFieldAddress) +} + func (m *ModeS) UnmarshalJSON(data []byte) error { type unmarshaler ModeS var value unmarshaler @@ -5611,6 +8681,17 @@ func (m *ModeS) UnmarshalJSON(data []byte) error { return nil } +func (m *ModeS) MarshalJSON() ([]byte, error) { + type embed ModeS + var marshaler = struct { + embed + }{ + embed: embed(*m), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, m.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (m *ModeS) String() string { if len(m.rawJSON) > 0 { if value, err := internal.StringifyJSON(m.rawJSON); err == nil { @@ -5624,6 +8705,10 @@ func (m *ModeS) String() string { } type NonPrimaryMembership struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5632,6 +8717,13 @@ func (n *NonPrimaryMembership) GetExtraProperties() map[string]interface{} { return n.extraProperties } +func (n *NonPrimaryMembership) require(field *big.Int) { + if n.explicitFields == nil { + n.explicitFields = big.NewInt(0) + } + n.explicitFields.Or(n.explicitFields, field) +} + func (n *NonPrimaryMembership) UnmarshalJSON(data []byte) error { type unmarshaler NonPrimaryMembership var value unmarshaler @@ -5648,6 +8740,17 @@ func (n *NonPrimaryMembership) UnmarshalJSON(data []byte) error { return nil } +func (n *NonPrimaryMembership) MarshalJSON() ([]byte, error) { + type embed NonPrimaryMembership + var marshaler = struct { + embed + }{ + embed: embed(*n), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, n.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (n *NonPrimaryMembership) String() string { if len(n.rawJSON) > 0 { if value, err := internal.StringifyJSON(n.rawJSON); err == nil { @@ -5661,6 +8764,12 @@ func (n *NonPrimaryMembership) String() string { } // Ontology of the entity. +var ( + ontologyFieldPlatformType = big.NewInt(1 << 0) + ontologyFieldSpecificType = big.NewInt(1 << 1) + ontologyFieldTemplate = big.NewInt(1 << 2) +) + type Ontology struct { // A string that describes the entity's high-level type with natural language. PlatformType *string `json:"platformType,omitempty" url:"platformType,omitempty"` @@ -5669,6 +8778,9 @@ type Ontology struct { // The template used when creating this entity. Specifies minimum required components. Template *OntologyTemplate `json:"template,omitempty" url:"template,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5698,6 +8810,34 @@ func (o *Ontology) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *Ontology) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetPlatformType sets the PlatformType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Ontology) SetPlatformType(platformType *string) { + o.PlatformType = platformType + o.require(ontologyFieldPlatformType) +} + +// SetSpecificType sets the SpecificType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Ontology) SetSpecificType(specificType *string) { + o.SpecificType = specificType + o.require(ontologyFieldSpecificType) +} + +// SetTemplate sets the Template field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Ontology) SetTemplate(template *OntologyTemplate) { + o.Template = template + o.require(ontologyFieldTemplate) +} + func (o *Ontology) UnmarshalJSON(data []byte) error { type unmarshaler Ontology var value unmarshaler @@ -5714,6 +8854,17 @@ func (o *Ontology) UnmarshalJSON(data []byte) error { return nil } +func (o *Ontology) MarshalJSON() ([]byte, error) { + type embed Ontology + var marshaler = struct { + embed + }{ + embed: embed(*o), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (o *Ontology) String() string { if len(o.rawJSON) > 0 { if value, err := internal.StringifyJSON(o.rawJSON); err == nil { @@ -5761,10 +8912,17 @@ func (o OntologyTemplate) Ptr() *OntologyTemplate { return &o } +var ( + orbitFieldOrbitMeanElements = big.NewInt(1 << 0) +) + type Orbit struct { // Orbit Mean Elements data, analogous to the Orbit Mean Elements Message in CCSDS 502.0-B-3 OrbitMeanElements *OrbitMeanElements `json:"orbitMeanElements,omitempty" url:"orbitMeanElements,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5780,6 +8938,20 @@ func (o *Orbit) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *Orbit) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetOrbitMeanElements sets the OrbitMeanElements field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Orbit) SetOrbitMeanElements(orbitMeanElements *OrbitMeanElements) { + o.OrbitMeanElements = orbitMeanElements + o.require(orbitFieldOrbitMeanElements) +} + func (o *Orbit) UnmarshalJSON(data []byte) error { type unmarshaler Orbit var value unmarshaler @@ -5796,6 +8968,17 @@ func (o *Orbit) UnmarshalJSON(data []byte) error { return nil } +func (o *Orbit) MarshalJSON() ([]byte, error) { + type embed Orbit + var marshaler = struct { + embed + }{ + embed: embed(*o), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (o *Orbit) String() string { if len(o.rawJSON) > 0 { if value, err := internal.StringifyJSON(o.rawJSON); err == nil { @@ -5809,11 +8992,20 @@ func (o *Orbit) String() string { } // Orbit Mean Elements data, analogous to the Orbit Mean Elements Message in CCSDS 502.0-B-3 +var ( + orbitMeanElementsFieldMetadata = big.NewInt(1 << 0) + orbitMeanElementsFieldMeanKeplerianElements = big.NewInt(1 << 1) + orbitMeanElementsFieldTleParameters = big.NewInt(1 << 2) +) + type OrbitMeanElements struct { Metadata *OrbitMeanElementsMetadata `json:"metadata,omitempty" url:"metadata,omitempty"` MeanKeplerianElements *MeanKeplerianElements `json:"meanKeplerianElements,omitempty" url:"meanKeplerianElements,omitempty"` TleParameters *TleParameters `json:"tleParameters,omitempty" url:"tleParameters,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5843,6 +9035,34 @@ func (o *OrbitMeanElements) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *OrbitMeanElements) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetMetadata sets the Metadata field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElements) SetMetadata(metadata *OrbitMeanElementsMetadata) { + o.Metadata = metadata + o.require(orbitMeanElementsFieldMetadata) +} + +// SetMeanKeplerianElements sets the MeanKeplerianElements field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElements) SetMeanKeplerianElements(meanKeplerianElements *MeanKeplerianElements) { + o.MeanKeplerianElements = meanKeplerianElements + o.require(orbitMeanElementsFieldMeanKeplerianElements) +} + +// SetTleParameters sets the TleParameters field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElements) SetTleParameters(tleParameters *TleParameters) { + o.TleParameters = tleParameters + o.require(orbitMeanElementsFieldTleParameters) +} + func (o *OrbitMeanElements) UnmarshalJSON(data []byte) error { type unmarshaler OrbitMeanElements var value unmarshaler @@ -5859,6 +9079,17 @@ func (o *OrbitMeanElements) UnmarshalJSON(data []byte) error { return nil } +func (o *OrbitMeanElements) MarshalJSON() ([]byte, error) { + type embed OrbitMeanElements + var marshaler = struct { + embed + }{ + embed: embed(*o), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (o *OrbitMeanElements) String() string { if len(o.rawJSON) > 0 { if value, err := internal.StringifyJSON(o.rawJSON); err == nil { @@ -5871,6 +9102,15 @@ func (o *OrbitMeanElements) String() string { return fmt.Sprintf("%#v", o) } +var ( + orbitMeanElementsMetadataFieldCreationDate = big.NewInt(1 << 0) + orbitMeanElementsMetadataFieldOriginator = big.NewInt(1 << 1) + orbitMeanElementsMetadataFieldMessageID = big.NewInt(1 << 2) + orbitMeanElementsMetadataFieldRefFrame = big.NewInt(1 << 3) + orbitMeanElementsMetadataFieldRefFrameEpoch = big.NewInt(1 << 4) + orbitMeanElementsMetadataFieldMeanElementTheory = big.NewInt(1 << 5) +) + type OrbitMeanElementsMetadata struct { // Creation date/time in UTC CreationDate *time.Time `json:"creationDate,omitempty" url:"creationDate,omitempty"` @@ -5884,6 +9124,9 @@ type OrbitMeanElementsMetadata struct { RefFrameEpoch *time.Time `json:"refFrameEpoch,omitempty" url:"refFrameEpoch,omitempty"` MeanElementTheory *OrbitMeanElementsMetadataMeanElementTheory `json:"meanElementTheory,omitempty" url:"meanElementTheory,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -5934,6 +9177,55 @@ func (o *OrbitMeanElementsMetadata) GetExtraProperties() map[string]interface{} return o.extraProperties } +func (o *OrbitMeanElementsMetadata) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetCreationDate sets the CreationDate field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetCreationDate(creationDate *time.Time) { + o.CreationDate = creationDate + o.require(orbitMeanElementsMetadataFieldCreationDate) +} + +// SetOriginator sets the Originator field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetOriginator(originator *string) { + o.Originator = originator + o.require(orbitMeanElementsMetadataFieldOriginator) +} + +// SetMessageID sets the MessageID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetMessageID(messageID *string) { + o.MessageID = messageID + o.require(orbitMeanElementsMetadataFieldMessageID) +} + +// SetRefFrame sets the RefFrame field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetRefFrame(refFrame *OrbitMeanElementsMetadataRefFrame) { + o.RefFrame = refFrame + o.require(orbitMeanElementsMetadataFieldRefFrame) +} + +// SetRefFrameEpoch sets the RefFrameEpoch field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetRefFrameEpoch(refFrameEpoch *time.Time) { + o.RefFrameEpoch = refFrameEpoch + o.require(orbitMeanElementsMetadataFieldRefFrameEpoch) +} + +// SetMeanElementTheory sets the MeanElementTheory field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *OrbitMeanElementsMetadata) SetMeanElementTheory(meanElementTheory *OrbitMeanElementsMetadataMeanElementTheory) { + o.MeanElementTheory = meanElementTheory + o.require(orbitMeanElementsMetadataFieldMeanElementTheory) +} + func (o *OrbitMeanElementsMetadata) UnmarshalJSON(data []byte) error { type embed OrbitMeanElementsMetadata var unmarshaler = struct { @@ -5969,7 +9261,8 @@ func (o *OrbitMeanElementsMetadata) MarshalJSON() ([]byte, error) { CreationDate: internal.NewOptionalDateTime(o.CreationDate), RefFrameEpoch: internal.NewOptionalDateTime(o.RefFrameEpoch), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) } func (o *OrbitMeanElementsMetadata) String() string { @@ -6030,6 +9323,16 @@ func (o OrbitMeanElementsMetadataRefFrame) Ptr() *OrbitMeanElementsMetadataRefFr } // Details about an override. Last write wins. +var ( + overrideFieldRequestID = big.NewInt(1 << 0) + overrideFieldFieldPath = big.NewInt(1 << 1) + overrideFieldMaskedFieldValue = big.NewInt(1 << 2) + overrideFieldStatus = big.NewInt(1 << 3) + overrideFieldProvenance = big.NewInt(1 << 4) + overrideFieldType = big.NewInt(1 << 5) + overrideFieldRequestTimestamp = big.NewInt(1 << 6) +) + type Override struct { // override request id for an override request RequestID *string `json:"requestId,omitempty" url:"requestId,omitempty"` @@ -6051,6 +9354,9 @@ type Override struct { // Timestamp of the override request. The timestamp is generated by the Entity Manager instance that receives the request. RequestTimestamp *time.Time `json:"requestTimestamp,omitempty" url:"requestTimestamp,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6108,6 +9414,62 @@ func (o *Override) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *Override) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetRequestID sets the RequestID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetRequestID(requestID *string) { + o.RequestID = requestID + o.require(overrideFieldRequestID) +} + +// SetFieldPath sets the FieldPath field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetFieldPath(fieldPath *string) { + o.FieldPath = fieldPath + o.require(overrideFieldFieldPath) +} + +// SetMaskedFieldValue sets the MaskedFieldValue field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetMaskedFieldValue(maskedFieldValue *Entity) { + o.MaskedFieldValue = maskedFieldValue + o.require(overrideFieldMaskedFieldValue) +} + +// SetStatus sets the Status field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetStatus(status *OverrideStatus) { + o.Status = status + o.require(overrideFieldStatus) +} + +// SetProvenance sets the Provenance field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetProvenance(provenance *Provenance) { + o.Provenance = provenance + o.require(overrideFieldProvenance) +} + +// SetType sets the Type field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetType(type_ *OverrideType) { + o.Type = type_ + o.require(overrideFieldType) +} + +// SetRequestTimestamp sets the RequestTimestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Override) SetRequestTimestamp(requestTimestamp *time.Time) { + o.RequestTimestamp = requestTimestamp + o.require(overrideFieldRequestTimestamp) +} + func (o *Override) UnmarshalJSON(data []byte) error { type embed Override var unmarshaler = struct { @@ -6139,7 +9501,8 @@ func (o *Override) MarshalJSON() ([]byte, error) { embed: embed(*o), RequestTimestamp: internal.NewOptionalDateTime(o.RequestTimestamp), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) } func (o *Override) String() string { @@ -6218,9 +9581,16 @@ func (o OverrideType) Ptr() *OverrideType { } // Metadata about entity overrides present. +var ( + overridesFieldOverride = big.NewInt(1 << 0) +) + type Overrides struct { Override []*Override `json:"override,omitempty" url:"override,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6236,6 +9606,20 @@ func (o *Overrides) GetExtraProperties() map[string]interface{} { return o.extraProperties } +func (o *Overrides) require(field *big.Int) { + if o.explicitFields == nil { + o.explicitFields = big.NewInt(0) + } + o.explicitFields.Or(o.explicitFields, field) +} + +// SetOverride sets the Override field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (o *Overrides) SetOverride(override []*Override) { + o.Override = override + o.require(overridesFieldOverride) +} + func (o *Overrides) UnmarshalJSON(data []byte) error { type unmarshaler Overrides var value unmarshaler @@ -6252,6 +9636,17 @@ func (o *Overrides) UnmarshalJSON(data []byte) error { return nil } +func (o *Overrides) MarshalJSON() ([]byte, error) { + type embed Overrides + var marshaler = struct { + embed + }{ + embed: embed(*o), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (o *Overrides) String() string { if len(o.rawJSON) > 0 { if value, err := internal.StringifyJSON(o.rawJSON); err == nil { @@ -6265,9 +9660,16 @@ func (o *Overrides) String() string { } // Individual payload configuration. +var ( + payloadFieldConfig = big.NewInt(1 << 0) +) + type Payload struct { Config *PayloadConfiguration `json:"config,omitempty" url:"config,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6276,11 +9678,25 @@ func (p *Payload) GetConfig() *PayloadConfiguration { if p == nil { return nil } - return p.Config + return p.Config +} + +func (p *Payload) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Payload) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) } -func (p *Payload) GetExtraProperties() map[string]interface{} { - return p.extraProperties +// SetConfig sets the Config field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Payload) SetConfig(config *PayloadConfiguration) { + p.Config = config + p.require(payloadFieldConfig) } func (p *Payload) UnmarshalJSON(data []byte) error { @@ -6299,6 +9715,17 @@ func (p *Payload) UnmarshalJSON(data []byte) error { return nil } +func (p *Payload) MarshalJSON() ([]byte, error) { + type embed Payload + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *Payload) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6311,6 +9738,14 @@ func (p *Payload) String() string { return fmt.Sprintf("%#v", p) } +var ( + payloadConfigurationFieldCapabilityID = big.NewInt(1 << 0) + payloadConfigurationFieldQuantity = big.NewInt(1 << 1) + payloadConfigurationFieldEffectiveEnvironment = big.NewInt(1 << 2) + payloadConfigurationFieldPayloadOperationalState = big.NewInt(1 << 3) + payloadConfigurationFieldPayloadDescription = big.NewInt(1 << 4) +) + type PayloadConfiguration struct { // Identifying ID for the capability. // @@ -6325,6 +9760,9 @@ type PayloadConfiguration struct { // A human readable description of the payload PayloadDescription *string `json:"payloadDescription,omitempty" url:"payloadDescription,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6368,6 +9806,48 @@ func (p *PayloadConfiguration) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PayloadConfiguration) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetCapabilityID sets the CapabilityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PayloadConfiguration) SetCapabilityID(capabilityID *string) { + p.CapabilityID = capabilityID + p.require(payloadConfigurationFieldCapabilityID) +} + +// SetQuantity sets the Quantity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PayloadConfiguration) SetQuantity(quantity *int) { + p.Quantity = quantity + p.require(payloadConfigurationFieldQuantity) +} + +// SetEffectiveEnvironment sets the EffectiveEnvironment field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PayloadConfiguration) SetEffectiveEnvironment(effectiveEnvironment []PayloadConfigurationEffectiveEnvironmentItem) { + p.EffectiveEnvironment = effectiveEnvironment + p.require(payloadConfigurationFieldEffectiveEnvironment) +} + +// SetPayloadOperationalState sets the PayloadOperationalState field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PayloadConfiguration) SetPayloadOperationalState(payloadOperationalState *PayloadConfigurationPayloadOperationalState) { + p.PayloadOperationalState = payloadOperationalState + p.require(payloadConfigurationFieldPayloadOperationalState) +} + +// SetPayloadDescription sets the PayloadDescription field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PayloadConfiguration) SetPayloadDescription(payloadDescription *string) { + p.PayloadDescription = payloadDescription + p.require(payloadConfigurationFieldPayloadDescription) +} + func (p *PayloadConfiguration) UnmarshalJSON(data []byte) error { type unmarshaler PayloadConfiguration var value unmarshaler @@ -6384,6 +9864,17 @@ func (p *PayloadConfiguration) UnmarshalJSON(data []byte) error { return nil } +func (p *PayloadConfiguration) MarshalJSON() ([]byte, error) { + type embed PayloadConfiguration + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PayloadConfiguration) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6469,9 +9960,16 @@ func (p PayloadConfigurationPayloadOperationalState) Ptr() *PayloadConfiguration } // List of payloads available for an entity. +var ( + payloadsFieldPayloadConfigurations = big.NewInt(1 << 0) +) + type Payloads struct { PayloadConfigurations []*Payload `json:"payloadConfigurations,omitempty" url:"payloadConfigurations,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6487,6 +9985,20 @@ func (p *Payloads) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *Payloads) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetPayloadConfigurations sets the PayloadConfigurations field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Payloads) SetPayloadConfigurations(payloadConfigurations []*Payload) { + p.PayloadConfigurations = payloadConfigurations + p.require(payloadsFieldPayloadConfigurations) +} + func (p *Payloads) UnmarshalJSON(data []byte) error { type unmarshaler Payloads var value unmarshaler @@ -6503,6 +10015,17 @@ func (p *Payloads) UnmarshalJSON(data []byte) error { return nil } +func (p *Payloads) MarshalJSON() ([]byte, error) { + type embed Payloads + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *Payloads) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6515,6 +10038,11 @@ func (p *Payloads) String() string { return fmt.Sprintf("%#v", p) } +var ( + poseFieldPos = big.NewInt(1 << 0) + poseFieldAttEnu = big.NewInt(1 << 1) +) + type Pose struct { // Geospatial location defined by this Pose. Pos *Lla `json:"pos,omitempty" url:"pos,omitempty"` @@ -6540,6 +10068,9 @@ type Pose struct { // ptEnu = M x ptPose AttEnu *Quaternion `json:"attEnu,omitempty" url:"attEnu,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6562,6 +10093,27 @@ func (p *Pose) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *Pose) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetPos sets the Pos field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Pose) SetPos(pos *Lla) { + p.Pos = pos + p.require(poseFieldPos) +} + +// SetAttEnu sets the AttEnu field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Pose) SetAttEnu(attEnu *Quaternion) { + p.AttEnu = attEnu + p.require(poseFieldAttEnu) +} + func (p *Pose) UnmarshalJSON(data []byte) error { type unmarshaler Pose var value unmarshaler @@ -6578,6 +10130,17 @@ func (p *Pose) UnmarshalJSON(data []byte) error { return nil } +func (p *Pose) MarshalJSON() ([]byte, error) { + type embed Pose + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *Pose) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6596,6 +10159,15 @@ func (p *Pose) String() string { // such as the Earth Gravitational Model 1996 (EGM-96) and the Earth Gravitational Model 2008 (EGM-08). // If the only altitude reference available to your integration is MSL, convert it to // Height Above Ellipsoid (HAE) and populate the altitude_hae_meters field. +var ( + positionFieldLatitudeDegrees = big.NewInt(1 << 0) + positionFieldLongitudeDegrees = big.NewInt(1 << 1) + positionFieldAltitudeHaeMeters = big.NewInt(1 << 2) + positionFieldAltitudeAglMeters = big.NewInt(1 << 3) + positionFieldAltitudeAsfMeters = big.NewInt(1 << 4) + positionFieldPressureDepthMeters = big.NewInt(1 << 5) +) + type Position struct { // WGS84 geodetic latitude in decimal degrees. LatitudeDegrees *float64 `json:"latitudeDegrees,omitempty" url:"latitudeDegrees,omitempty"` @@ -6619,6 +10191,9 @@ type Position struct { // between the interior and exterior of the vessel. If the value is not set from the upstream, this value is not set. PressureDepthMeters *float64 `json:"pressureDepthMeters,omitempty" url:"pressureDepthMeters,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6669,6 +10244,55 @@ func (p *Position) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *Position) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetLatitudeDegrees sets the LatitudeDegrees field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetLatitudeDegrees(latitudeDegrees *float64) { + p.LatitudeDegrees = latitudeDegrees + p.require(positionFieldLatitudeDegrees) +} + +// SetLongitudeDegrees sets the LongitudeDegrees field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetLongitudeDegrees(longitudeDegrees *float64) { + p.LongitudeDegrees = longitudeDegrees + p.require(positionFieldLongitudeDegrees) +} + +// SetAltitudeHaeMeters sets the AltitudeHaeMeters field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetAltitudeHaeMeters(altitudeHaeMeters *float64) { + p.AltitudeHaeMeters = altitudeHaeMeters + p.require(positionFieldAltitudeHaeMeters) +} + +// SetAltitudeAglMeters sets the AltitudeAglMeters field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetAltitudeAglMeters(altitudeAglMeters *float64) { + p.AltitudeAglMeters = altitudeAglMeters + p.require(positionFieldAltitudeAglMeters) +} + +// SetAltitudeAsfMeters sets the AltitudeAsfMeters field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetAltitudeAsfMeters(altitudeAsfMeters *float64) { + p.AltitudeAsfMeters = altitudeAsfMeters + p.require(positionFieldAltitudeAsfMeters) +} + +// SetPressureDepthMeters sets the PressureDepthMeters field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Position) SetPressureDepthMeters(pressureDepthMeters *float64) { + p.PressureDepthMeters = pressureDepthMeters + p.require(positionFieldPressureDepthMeters) +} + func (p *Position) UnmarshalJSON(data []byte) error { type unmarshaler Position var value unmarshaler @@ -6685,6 +10309,17 @@ func (p *Position) UnmarshalJSON(data []byte) error { return nil } +func (p *Position) MarshalJSON() ([]byte, error) { + type embed Position + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *Position) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6698,6 +10333,16 @@ func (p *Position) String() string { } // Represents the power level of a system. +var ( + powerLevelFieldCapacity = big.NewInt(1 << 0) + powerLevelFieldRemaining = big.NewInt(1 << 1) + powerLevelFieldPercentRemaining = big.NewInt(1 << 2) + powerLevelFieldVoltage = big.NewInt(1 << 3) + powerLevelFieldCurrentAmps = big.NewInt(1 << 4) + powerLevelFieldRunTimeToEmptyMins = big.NewInt(1 << 5) + powerLevelFieldConsumptionRateLPerS = big.NewInt(1 << 6) +) + type PowerLevel struct { // Total power capacity of the system. Capacity *float64 `json:"capacity,omitempty" url:"capacity,omitempty"` @@ -6720,6 +10365,9 @@ type PowerLevel struct { // Fuel consumption rate in liters per second. ConsumptionRateLPerS *float64 `json:"consumptionRateLPerS,omitempty" url:"consumptionRateLPerS,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6777,6 +10425,62 @@ func (p *PowerLevel) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PowerLevel) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetCapacity sets the Capacity field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetCapacity(capacity *float64) { + p.Capacity = capacity + p.require(powerLevelFieldCapacity) +} + +// SetRemaining sets the Remaining field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetRemaining(remaining *float64) { + p.Remaining = remaining + p.require(powerLevelFieldRemaining) +} + +// SetPercentRemaining sets the PercentRemaining field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetPercentRemaining(percentRemaining *float64) { + p.PercentRemaining = percentRemaining + p.require(powerLevelFieldPercentRemaining) +} + +// SetVoltage sets the Voltage field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetVoltage(voltage *float64) { + p.Voltage = voltage + p.require(powerLevelFieldVoltage) +} + +// SetCurrentAmps sets the CurrentAmps field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetCurrentAmps(currentAmps *float64) { + p.CurrentAmps = currentAmps + p.require(powerLevelFieldCurrentAmps) +} + +// SetRunTimeToEmptyMins sets the RunTimeToEmptyMins field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetRunTimeToEmptyMins(runTimeToEmptyMins *float64) { + p.RunTimeToEmptyMins = runTimeToEmptyMins + p.require(powerLevelFieldRunTimeToEmptyMins) +} + +// SetConsumptionRateLPerS sets the ConsumptionRateLPerS field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerLevel) SetConsumptionRateLPerS(consumptionRateLPerS *float64) { + p.ConsumptionRateLPerS = consumptionRateLPerS + p.require(powerLevelFieldConsumptionRateLPerS) +} + func (p *PowerLevel) UnmarshalJSON(data []byte) error { type unmarshaler PowerLevel var value unmarshaler @@ -6793,6 +10497,17 @@ func (p *PowerLevel) UnmarshalJSON(data []byte) error { return nil } +func (p *PowerLevel) MarshalJSON() ([]byte, error) { + type embed PowerLevel + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PowerLevel) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6806,6 +10521,14 @@ func (p *PowerLevel) String() string { } // Represents the state of a single power source that is connected to this entity. +var ( + powerSourceFieldPowerStatus = big.NewInt(1 << 0) + powerSourceFieldPowerType = big.NewInt(1 << 1) + powerSourceFieldPowerLevel = big.NewInt(1 << 2) + powerSourceFieldMessages = big.NewInt(1 << 3) + powerSourceFieldOffloadable = big.NewInt(1 << 4) +) + type PowerSource struct { // Status of the power source. PowerStatus *PowerSourcePowerStatus `json:"powerStatus,omitempty" url:"powerStatus,omitempty"` @@ -6822,6 +10545,9 @@ type PowerSource struct { // report whether the power source is offloadable. Offloadable *bool `json:"offloadable,omitempty" url:"offloadable,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6865,6 +10591,48 @@ func (p *PowerSource) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PowerSource) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetPowerStatus sets the PowerStatus field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerSource) SetPowerStatus(powerStatus *PowerSourcePowerStatus) { + p.PowerStatus = powerStatus + p.require(powerSourceFieldPowerStatus) +} + +// SetPowerType sets the PowerType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerSource) SetPowerType(powerType *PowerSourcePowerType) { + p.PowerType = powerType + p.require(powerSourceFieldPowerType) +} + +// SetPowerLevel sets the PowerLevel field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerSource) SetPowerLevel(powerLevel *PowerLevel) { + p.PowerLevel = powerLevel + p.require(powerSourceFieldPowerLevel) +} + +// SetMessages sets the Messages field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerSource) SetMessages(messages []string) { + p.Messages = messages + p.require(powerSourceFieldMessages) +} + +// SetOffloadable sets the Offloadable field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerSource) SetOffloadable(offloadable *bool) { + p.Offloadable = offloadable + p.require(powerSourceFieldOffloadable) +} + func (p *PowerSource) UnmarshalJSON(data []byte) error { type unmarshaler PowerSource var value unmarshaler @@ -6881,6 +10649,17 @@ func (p *PowerSource) UnmarshalJSON(data []byte) error { return nil } +func (p *PowerSource) MarshalJSON() ([]byte, error) { + type embed PowerSource + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PowerSource) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -6958,12 +10737,19 @@ func (p PowerSourcePowerType) Ptr() *PowerSourcePowerType { } // Represents the state of power sources connected to this entity. +var ( + powerStateFieldSourceIDToState = big.NewInt(1 << 0) +) + type PowerState struct { // This is a map where the key is a unique id of the power source and the value is additional information about the // // power source. SourceIDToState map[string]*PowerSource `json:"sourceIdToState,omitempty" url:"sourceIdToState,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -6979,6 +10765,20 @@ func (p *PowerState) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PowerState) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetSourceIDToState sets the SourceIDToState field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PowerState) SetSourceIDToState(sourceIDToState map[string]*PowerSource) { + p.SourceIDToState = sourceIDToState + p.require(powerStateFieldSourceIDToState) +} + func (p *PowerState) UnmarshalJSON(data []byte) error { type unmarshaler PowerState var value unmarshaler @@ -6995,6 +10795,17 @@ func (p *PowerState) UnmarshalJSON(data []byte) error { return nil } +func (p *PowerState) MarshalJSON() ([]byte, error) { + type embed PowerState + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PowerState) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -7007,10 +10818,17 @@ func (p *PowerState) String() string { return fmt.Sprintf("%#v", p) } +var ( + primaryCorrelationFieldSecondaryEntityIDs = big.NewInt(1 << 0) +) + type PrimaryCorrelation struct { // The secondary entity IDs part of this correlation. SecondaryEntityIDs []string `json:"secondaryEntityIds,omitempty" url:"secondaryEntityIds,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7026,6 +10844,20 @@ func (p *PrimaryCorrelation) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PrimaryCorrelation) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetSecondaryEntityIDs sets the SecondaryEntityIDs field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PrimaryCorrelation) SetSecondaryEntityIDs(secondaryEntityIDs []string) { + p.SecondaryEntityIDs = secondaryEntityIDs + p.require(primaryCorrelationFieldSecondaryEntityIDs) +} + func (p *PrimaryCorrelation) UnmarshalJSON(data []byte) error { type unmarshaler PrimaryCorrelation var value unmarshaler @@ -7042,6 +10874,17 @@ func (p *PrimaryCorrelation) UnmarshalJSON(data []byte) error { return nil } +func (p *PrimaryCorrelation) MarshalJSON() ([]byte, error) { + type embed PrimaryCorrelation + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PrimaryCorrelation) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -7055,6 +10898,10 @@ func (p *PrimaryCorrelation) String() string { } type PrimaryMembership struct { + + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7063,6 +10910,13 @@ func (p *PrimaryMembership) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PrimaryMembership) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + func (p *PrimaryMembership) UnmarshalJSON(data []byte) error { type unmarshaler PrimaryMembership var value unmarshaler @@ -7079,6 +10933,17 @@ func (p *PrimaryMembership) UnmarshalJSON(data []byte) error { return nil } +func (p *PrimaryMembership) MarshalJSON() ([]byte, error) { + type embed PrimaryMembership + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PrimaryMembership) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -7094,6 +10959,13 @@ func (p *PrimaryMembership) String() string { // Represents a frustum in which which all four corner points project onto the ground. All points in this message // // are optional, if the projection to the ground fails then they will not be populated. +var ( + projectedFrustumFieldUpperLeft = big.NewInt(1 << 0) + projectedFrustumFieldUpperRight = big.NewInt(1 << 1) + projectedFrustumFieldBottomRight = big.NewInt(1 << 2) + projectedFrustumFieldBottomLeft = big.NewInt(1 << 3) +) + type ProjectedFrustum struct { // Upper left point of the frustum. UpperLeft *Position `json:"upperLeft,omitempty" url:"upperLeft,omitempty"` @@ -7104,6 +10976,9 @@ type ProjectedFrustum struct { // Bottom left point of the frustum. BottomLeft *Position `json:"bottomLeft,omitempty" url:"bottomLeft,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7140,6 +11015,41 @@ func (p *ProjectedFrustum) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *ProjectedFrustum) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetUpperLeft sets the UpperLeft field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *ProjectedFrustum) SetUpperLeft(upperLeft *Position) { + p.UpperLeft = upperLeft + p.require(projectedFrustumFieldUpperLeft) +} + +// SetUpperRight sets the UpperRight field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *ProjectedFrustum) SetUpperRight(upperRight *Position) { + p.UpperRight = upperRight + p.require(projectedFrustumFieldUpperRight) +} + +// SetBottomRight sets the BottomRight field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *ProjectedFrustum) SetBottomRight(bottomRight *Position) { + p.BottomRight = bottomRight + p.require(projectedFrustumFieldBottomRight) +} + +// SetBottomLeft sets the BottomLeft field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *ProjectedFrustum) SetBottomLeft(bottomLeft *Position) { + p.BottomLeft = bottomLeft + p.require(projectedFrustumFieldBottomLeft) +} + func (p *ProjectedFrustum) UnmarshalJSON(data []byte) error { type unmarshaler ProjectedFrustum var value unmarshaler @@ -7156,6 +11066,17 @@ func (p *ProjectedFrustum) UnmarshalJSON(data []byte) error { return nil } +func (p *ProjectedFrustum) MarshalJSON() ([]byte, error) { + type embed ProjectedFrustum + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *ProjectedFrustum) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -7169,6 +11090,14 @@ func (p *ProjectedFrustum) String() string { } // Data provenance. +var ( + provenanceFieldIntegrationName = big.NewInt(1 << 0) + provenanceFieldDataType = big.NewInt(1 << 1) + provenanceFieldSourceID = big.NewInt(1 << 2) + provenanceFieldSourceUpdateTime = big.NewInt(1 << 3) + provenanceFieldSourceDescription = big.NewInt(1 << 4) +) + type Provenance struct { // Name of the integration that produced this entity IntegrationName *string `json:"integrationName,omitempty" url:"integrationName,omitempty"` @@ -7184,6 +11113,9 @@ type Provenance struct { // Description of the modification source. In the case of a user this is the email address. SourceDescription *string `json:"sourceDescription,omitempty" url:"sourceDescription,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7227,6 +11159,48 @@ func (p *Provenance) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *Provenance) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetIntegrationName sets the IntegrationName field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Provenance) SetIntegrationName(integrationName *string) { + p.IntegrationName = integrationName + p.require(provenanceFieldIntegrationName) +} + +// SetDataType sets the DataType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Provenance) SetDataType(dataType *string) { + p.DataType = dataType + p.require(provenanceFieldDataType) +} + +// SetSourceID sets the SourceID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Provenance) SetSourceID(sourceID *string) { + p.SourceID = sourceID + p.require(provenanceFieldSourceID) +} + +// SetSourceUpdateTime sets the SourceUpdateTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Provenance) SetSourceUpdateTime(sourceUpdateTime *time.Time) { + p.SourceUpdateTime = sourceUpdateTime + p.require(provenanceFieldSourceUpdateTime) +} + +// SetSourceDescription sets the SourceDescription field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *Provenance) SetSourceDescription(sourceDescription *string) { + p.SourceDescription = sourceDescription + p.require(provenanceFieldSourceDescription) +} + func (p *Provenance) UnmarshalJSON(data []byte) error { type embed Provenance var unmarshaler = struct { @@ -7258,7 +11232,8 @@ func (p *Provenance) MarshalJSON() ([]byte, error) { embed: embed(*p), SourceUpdateTime: internal.NewOptionalDateTime(p.SourceUpdateTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) } func (p *Provenance) String() string { @@ -7274,9 +11249,16 @@ func (p *Provenance) String() string { } // A component that describe the length in time between two pulses +var ( + pulseRepetitionIntervalFieldPulseRepetitionIntervalS = big.NewInt(1 << 0) +) + type PulseRepetitionInterval struct { PulseRepetitionIntervalS *Measurement `json:"pulseRepetitionIntervalS,omitempty" url:"pulseRepetitionIntervalS,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7292,6 +11274,20 @@ func (p *PulseRepetitionInterval) GetExtraProperties() map[string]interface{} { return p.extraProperties } +func (p *PulseRepetitionInterval) require(field *big.Int) { + if p.explicitFields == nil { + p.explicitFields = big.NewInt(0) + } + p.explicitFields.Or(p.explicitFields, field) +} + +// SetPulseRepetitionIntervalS sets the PulseRepetitionIntervalS field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (p *PulseRepetitionInterval) SetPulseRepetitionIntervalS(pulseRepetitionIntervalS *Measurement) { + p.PulseRepetitionIntervalS = pulseRepetitionIntervalS + p.require(pulseRepetitionIntervalFieldPulseRepetitionIntervalS) +} + func (p *PulseRepetitionInterval) UnmarshalJSON(data []byte) error { type unmarshaler PulseRepetitionInterval var value unmarshaler @@ -7308,6 +11304,17 @@ func (p *PulseRepetitionInterval) UnmarshalJSON(data []byte) error { return nil } +func (p *PulseRepetitionInterval) MarshalJSON() ([]byte, error) { + type embed PulseRepetitionInterval + var marshaler = struct { + embed + }{ + embed: embed(*p), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (p *PulseRepetitionInterval) String() string { if len(p.rawJSON) > 0 { if value, err := internal.StringifyJSON(p.rawJSON); err == nil { @@ -7320,6 +11327,13 @@ func (p *PulseRepetitionInterval) String() string { return fmt.Sprintf("%#v", p) } +var ( + quaternionFieldX = big.NewInt(1 << 0) + quaternionFieldY = big.NewInt(1 << 1) + quaternionFieldZ = big.NewInt(1 << 2) + quaternionFieldW = big.NewInt(1 << 3) +) + type Quaternion struct { // x, y, z are vector portion, w is scalar X *float64 `json:"x,omitempty" url:"x,omitempty"` @@ -7327,6 +11341,9 @@ type Quaternion struct { Z *float64 `json:"z,omitempty" url:"z,omitempty"` W *float64 `json:"w,omitempty" url:"w,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7363,6 +11380,41 @@ func (q *Quaternion) GetExtraProperties() map[string]interface{} { return q.extraProperties } +func (q *Quaternion) require(field *big.Int) { + if q.explicitFields == nil { + q.explicitFields = big.NewInt(0) + } + q.explicitFields.Or(q.explicitFields, field) +} + +// SetX sets the X field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (q *Quaternion) SetX(x *float64) { + q.X = x + q.require(quaternionFieldX) +} + +// SetY sets the Y field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (q *Quaternion) SetY(y *float64) { + q.Y = y + q.require(quaternionFieldY) +} + +// SetZ sets the Z field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (q *Quaternion) SetZ(z *float64) { + q.Z = z + q.require(quaternionFieldZ) +} + +// SetW sets the W field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (q *Quaternion) SetW(w *float64) { + q.W = w + q.require(quaternionFieldW) +} + func (q *Quaternion) UnmarshalJSON(data []byte) error { type unmarshaler Quaternion var value unmarshaler @@ -7379,6 +11431,17 @@ func (q *Quaternion) UnmarshalJSON(data []byte) error { return nil } +func (q *Quaternion) MarshalJSON() ([]byte, error) { + type embed Quaternion + var marshaler = struct { + embed + }{ + embed: embed(*q), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, q.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (q *Quaternion) String() string { if len(q.rawJSON) > 0 { if value, err := internal.StringifyJSON(q.rawJSON); err == nil { @@ -7392,6 +11455,13 @@ func (q *Quaternion) String() string { } // Range rings allow visual assessment of map distance at varying zoom levels. +var ( + rangeRingsFieldMinDistanceM = big.NewInt(1 << 0) + rangeRingsFieldMaxDistanceM = big.NewInt(1 << 1) + rangeRingsFieldRingCount = big.NewInt(1 << 2) + rangeRingsFieldRingLineColor = big.NewInt(1 << 3) +) + type RangeRings struct { // The minimum range ring distance, specified in meters. MinDistanceM *float64 `json:"minDistanceM,omitempty" url:"minDistanceM,omitempty"` @@ -7402,6 +11472,9 @@ type RangeRings struct { // The color of range rings, specified in hex string. RingLineColor *Color `json:"ringLineColor,omitempty" url:"ringLineColor,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7438,6 +11511,41 @@ func (r *RangeRings) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *RangeRings) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetMinDistanceM sets the MinDistanceM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RangeRings) SetMinDistanceM(minDistanceM *float64) { + r.MinDistanceM = minDistanceM + r.require(rangeRingsFieldMinDistanceM) +} + +// SetMaxDistanceM sets the MaxDistanceM field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RangeRings) SetMaxDistanceM(maxDistanceM *float64) { + r.MaxDistanceM = maxDistanceM + r.require(rangeRingsFieldMaxDistanceM) +} + +// SetRingCount sets the RingCount field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RangeRings) SetRingCount(ringCount *int) { + r.RingCount = ringCount + r.require(rangeRingsFieldRingCount) +} + +// SetRingLineColor sets the RingLineColor field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RangeRings) SetRingLineColor(ringLineColor *Color) { + r.RingLineColor = ringLineColor + r.require(rangeRingsFieldRingLineColor) +} + func (r *RangeRings) UnmarshalJSON(data []byte) error { type unmarshaler RangeRings var value unmarshaler @@ -7454,6 +11562,17 @@ func (r *RangeRings) UnmarshalJSON(data []byte) error { return nil } +func (r *RangeRings) MarshalJSON() ([]byte, error) { + type embed RangeRings + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *RangeRings) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -7467,6 +11586,12 @@ func (r *RangeRings) String() string { } // The relationship component indicates a relationship to another entity. +var ( + relationshipFieldRelatedEntityID = big.NewInt(1 << 0) + relationshipFieldRelationshipID = big.NewInt(1 << 1) + relationshipFieldRelationshipType = big.NewInt(1 << 2) +) + type Relationship struct { // The entity ID to which this entity is related. RelatedEntityID *string `json:"relatedEntityId,omitempty" url:"relatedEntityId,omitempty"` @@ -7475,6 +11600,9 @@ type Relationship struct { // The relationship type RelationshipType *RelationshipType `json:"relationshipType,omitempty" url:"relationshipType,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7504,6 +11632,34 @@ func (r *Relationship) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *Relationship) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetRelatedEntityID sets the RelatedEntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relationship) SetRelatedEntityID(relatedEntityID *string) { + r.RelatedEntityID = relatedEntityID + r.require(relationshipFieldRelatedEntityID) +} + +// SetRelationshipID sets the RelationshipID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relationship) SetRelationshipID(relationshipID *string) { + r.RelationshipID = relationshipID + r.require(relationshipFieldRelationshipID) +} + +// SetRelationshipType sets the RelationshipType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relationship) SetRelationshipType(relationshipType *RelationshipType) { + r.RelationshipType = relationshipType + r.require(relationshipFieldRelationshipType) +} + func (r *Relationship) UnmarshalJSON(data []byte) error { type unmarshaler Relationship var value unmarshaler @@ -7520,6 +11676,17 @@ func (r *Relationship) UnmarshalJSON(data []byte) error { return nil } +func (r *Relationship) MarshalJSON() ([]byte, error) { + type embed Relationship + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *Relationship) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -7533,6 +11700,14 @@ func (r *Relationship) String() string { } // Determines the type of relationship between this entity and another. +var ( + relationshipTypeFieldTrackedBy = big.NewInt(1 << 0) + relationshipTypeFieldGroupChild = big.NewInt(1 << 1) + relationshipTypeFieldGroupParent = big.NewInt(1 << 2) + relationshipTypeFieldMergedFrom = big.NewInt(1 << 3) + relationshipTypeFieldActiveTarget = big.NewInt(1 << 4) +) + type RelationshipType struct { TrackedBy *TrackedBy `json:"trackedBy,omitempty" url:"trackedBy,omitempty"` GroupChild *GroupChild `json:"groupChild,omitempty" url:"groupChild,omitempty"` @@ -7540,6 +11715,9 @@ type RelationshipType struct { MergedFrom *MergedFrom `json:"mergedFrom,omitempty" url:"mergedFrom,omitempty"` ActiveTarget *ActiveTarget `json:"activeTarget,omitempty" url:"activeTarget,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7583,6 +11761,48 @@ func (r *RelationshipType) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *RelationshipType) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetTrackedBy sets the TrackedBy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RelationshipType) SetTrackedBy(trackedBy *TrackedBy) { + r.TrackedBy = trackedBy + r.require(relationshipTypeFieldTrackedBy) +} + +// SetGroupChild sets the GroupChild field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RelationshipType) SetGroupChild(groupChild *GroupChild) { + r.GroupChild = groupChild + r.require(relationshipTypeFieldGroupChild) +} + +// SetGroupParent sets the GroupParent field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RelationshipType) SetGroupParent(groupParent *GroupParent) { + r.GroupParent = groupParent + r.require(relationshipTypeFieldGroupParent) +} + +// SetMergedFrom sets the MergedFrom field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RelationshipType) SetMergedFrom(mergedFrom *MergedFrom) { + r.MergedFrom = mergedFrom + r.require(relationshipTypeFieldMergedFrom) +} + +// SetActiveTarget sets the ActiveTarget field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RelationshipType) SetActiveTarget(activeTarget *ActiveTarget) { + r.ActiveTarget = activeTarget + r.require(relationshipTypeFieldActiveTarget) +} + func (r *RelationshipType) UnmarshalJSON(data []byte) error { type unmarshaler RelationshipType var value unmarshaler @@ -7599,6 +11819,17 @@ func (r *RelationshipType) UnmarshalJSON(data []byte) error { return nil } +func (r *RelationshipType) MarshalJSON() ([]byte, error) { + type embed RelationshipType + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *RelationshipType) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -7612,9 +11843,16 @@ func (r *RelationshipType) String() string { } // The relationships between this entity and other entities in the common operational picture. +var ( + relationshipsFieldRelationships = big.NewInt(1 << 0) +) + type Relationships struct { Relationships []*Relationship `json:"relationships,omitempty" url:"relationships,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7630,6 +11868,20 @@ func (r *Relationships) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *Relationships) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetRelationships sets the Relationships field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *Relationships) SetRelationships(relationships []*Relationship) { + r.Relationships = relationships + r.require(relationshipsFieldRelationships) +} + func (r *Relationships) UnmarshalJSON(data []byte) error { type unmarshaler Relationships var value unmarshaler @@ -7646,6 +11898,17 @@ func (r *Relationships) UnmarshalJSON(data []byte) error { return nil } +func (r *Relationships) MarshalJSON() ([]byte, error) { + type embed Relationships + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *Relationships) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -7659,12 +11922,20 @@ func (r *Relationships) String() string { } // Represents RF configurations supported on this sensor. +var ( + rfConfigurationFieldFrequencyRangeHz = big.NewInt(1 << 0) + rfConfigurationFieldBandwidthRangeHz = big.NewInt(1 << 1) +) + type RfConfiguration struct { // Frequency ranges that are available for this sensor. FrequencyRangeHz []*FrequencyRange `json:"frequencyRangeHz,omitempty" url:"frequencyRangeHz,omitempty"` // Bandwidth ranges that are available for this sensor. BandwidthRangeHz []*BandwidthRange `json:"bandwidthRangeHz,omitempty" url:"bandwidthRangeHz,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7687,6 +11958,27 @@ func (r *RfConfiguration) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *RfConfiguration) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetFrequencyRangeHz sets the FrequencyRangeHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RfConfiguration) SetFrequencyRangeHz(frequencyRangeHz []*FrequencyRange) { + r.FrequencyRangeHz = frequencyRangeHz + r.require(rfConfigurationFieldFrequencyRangeHz) +} + +// SetBandwidthRangeHz sets the BandwidthRangeHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RfConfiguration) SetBandwidthRangeHz(bandwidthRangeHz []*BandwidthRange) { + r.BandwidthRangeHz = bandwidthRangeHz + r.require(rfConfigurationFieldBandwidthRangeHz) +} + func (r *RfConfiguration) UnmarshalJSON(data []byte) error { type unmarshaler RfConfiguration var value unmarshaler @@ -7703,6 +11995,17 @@ func (r *RfConfiguration) UnmarshalJSON(data []byte) error { return nil } +func (r *RfConfiguration) MarshalJSON() ([]byte, error) { + type embed RfConfiguration + var marshaler = struct { + embed + }{ + embed: embed(*r), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (r *RfConfiguration) String() string { if len(r.rawJSON) > 0 { if value, err := internal.StringifyJSON(r.rawJSON); err == nil { @@ -7715,12 +12018,20 @@ func (r *RfConfiguration) String() string { return fmt.Sprintf("%#v", r) } +var ( + routeDetailsFieldDestinationName = big.NewInt(1 << 0) + routeDetailsFieldEstimatedArrivalTime = big.NewInt(1 << 1) +) + type RouteDetails struct { // Free form text giving the name of the entity's destination DestinationName *string `json:"destinationName,omitempty" url:"destinationName,omitempty"` // Estimated time of arrival at destination EstimatedArrivalTime *time.Time `json:"estimatedArrivalTime,omitempty" url:"estimatedArrivalTime,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7743,6 +12054,27 @@ func (r *RouteDetails) GetExtraProperties() map[string]interface{} { return r.extraProperties } +func (r *RouteDetails) require(field *big.Int) { + if r.explicitFields == nil { + r.explicitFields = big.NewInt(0) + } + r.explicitFields.Or(r.explicitFields, field) +} + +// SetDestinationName sets the DestinationName field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RouteDetails) SetDestinationName(destinationName *string) { + r.DestinationName = destinationName + r.require(routeDetailsFieldDestinationName) +} + +// SetEstimatedArrivalTime sets the EstimatedArrivalTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (r *RouteDetails) SetEstimatedArrivalTime(estimatedArrivalTime *time.Time) { + r.EstimatedArrivalTime = estimatedArrivalTime + r.require(routeDetailsFieldEstimatedArrivalTime) +} + func (r *RouteDetails) UnmarshalJSON(data []byte) error { type embed RouteDetails var unmarshaler = struct { @@ -7774,7 +12106,8 @@ func (r *RouteDetails) MarshalJSON() ([]byte, error) { embed: embed(*r), EstimatedArrivalTime: internal.NewOptionalDateTime(r.EstimatedArrivalTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, r.explicitFields) + return json.Marshal(explicitMarshaler) } func (r *RouteDetails) String() string { @@ -7790,10 +12123,18 @@ func (r *RouteDetails) String() string { } // A component that describes the scanning characteristics of a signal +var ( + scanCharacteristicsFieldScanType = big.NewInt(1 << 0) + scanCharacteristicsFieldScanPeriodS = big.NewInt(1 << 1) +) + type ScanCharacteristics struct { ScanType *ScanCharacteristicsScanType `json:"scanType,omitempty" url:"scanType,omitempty"` ScanPeriodS *float64 `json:"scanPeriodS,omitempty" url:"scanPeriodS,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7816,6 +12157,27 @@ func (s *ScanCharacteristics) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *ScanCharacteristics) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetScanType sets the ScanType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *ScanCharacteristics) SetScanType(scanType *ScanCharacteristicsScanType) { + s.ScanType = scanType + s.require(scanCharacteristicsFieldScanType) +} + +// SetScanPeriodS sets the ScanPeriodS field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *ScanCharacteristics) SetScanPeriodS(scanPeriodS *float64) { + s.ScanPeriodS = scanPeriodS + s.require(scanCharacteristicsFieldScanPeriodS) +} + func (s *ScanCharacteristics) UnmarshalJSON(data []byte) error { type unmarshaler ScanCharacteristics var value unmarshaler @@ -7832,6 +12194,17 @@ func (s *ScanCharacteristics) UnmarshalJSON(data []byte) error { return nil } +func (s *ScanCharacteristics) MarshalJSON() ([]byte, error) { + type embed ScanCharacteristics + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *ScanCharacteristics) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -7912,6 +12285,12 @@ func (s ScanCharacteristicsScanType) Ptr() *ScanCharacteristicsScanType { } // A Schedule associated with this entity +var ( + scheduleFieldWindows = big.NewInt(1 << 0) + scheduleFieldScheduleID = big.NewInt(1 << 1) + scheduleFieldScheduleType = big.NewInt(1 << 2) +) + type Schedule struct { // expression that represents this schedule's "ON" state Windows []*CronWindow `json:"windows,omitempty" url:"windows,omitempty"` @@ -7920,6 +12299,9 @@ type Schedule struct { // The schedule type ScheduleType *ScheduleScheduleType `json:"scheduleType,omitempty" url:"scheduleType,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -7949,6 +12331,34 @@ func (s *Schedule) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Schedule) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetWindows sets the Windows field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Schedule) SetWindows(windows []*CronWindow) { + s.Windows = windows + s.require(scheduleFieldWindows) +} + +// SetScheduleID sets the ScheduleID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Schedule) SetScheduleID(scheduleID *string) { + s.ScheduleID = scheduleID + s.require(scheduleFieldScheduleID) +} + +// SetScheduleType sets the ScheduleType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Schedule) SetScheduleType(scheduleType *ScheduleScheduleType) { + s.ScheduleType = scheduleType + s.require(scheduleFieldScheduleType) +} + func (s *Schedule) UnmarshalJSON(data []byte) error { type unmarshaler Schedule var value unmarshaler @@ -7965,6 +12375,17 @@ func (s *Schedule) UnmarshalJSON(data []byte) error { return nil } +func (s *Schedule) MarshalJSON() ([]byte, error) { + type embed Schedule + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Schedule) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8004,9 +12425,16 @@ func (s ScheduleScheduleType) Ptr() *ScheduleScheduleType { } // Schedules associated with this entity +var ( + schedulesFieldSchedules = big.NewInt(1 << 0) +) + type Schedules struct { Schedules []*Schedule `json:"schedules,omitempty" url:"schedules,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8022,6 +12450,20 @@ func (s *Schedules) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Schedules) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetSchedules sets the Schedules field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Schedules) SetSchedules(schedules []*Schedule) { + s.Schedules = schedules + s.require(schedulesFieldSchedules) +} + func (s *Schedules) UnmarshalJSON(data []byte) error { type unmarshaler Schedules var value unmarshaler @@ -8038,6 +12480,17 @@ func (s *Schedules) UnmarshalJSON(data []byte) error { return nil } +func (s *Schedules) MarshalJSON() ([]byte, error) { + type embed Schedules + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Schedules) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8050,12 +12503,20 @@ func (s *Schedules) String() string { return fmt.Sprintf("%#v", s) } +var ( + secondaryCorrelationFieldPrimaryEntityID = big.NewInt(1 << 0) + secondaryCorrelationFieldMetadata = big.NewInt(1 << 1) +) + type SecondaryCorrelation struct { // The primary of this correlation. PrimaryEntityID *string `json:"primaryEntityId,omitempty" url:"primaryEntityId,omitempty"` // Metadata about the correlation. Metadata *CorrelationMetadata `json:"metadata,omitempty" url:"metadata,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8078,6 +12539,27 @@ func (s *SecondaryCorrelation) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *SecondaryCorrelation) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetPrimaryEntityID sets the PrimaryEntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *SecondaryCorrelation) SetPrimaryEntityID(primaryEntityID *string) { + s.PrimaryEntityID = primaryEntityID + s.require(secondaryCorrelationFieldPrimaryEntityID) +} + +// SetMetadata sets the Metadata field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *SecondaryCorrelation) SetMetadata(metadata *CorrelationMetadata) { + s.Metadata = metadata + s.require(secondaryCorrelationFieldMetadata) +} + func (s *SecondaryCorrelation) UnmarshalJSON(data []byte) error { type unmarshaler SecondaryCorrelation var value unmarshaler @@ -8094,6 +12576,17 @@ func (s *SecondaryCorrelation) UnmarshalJSON(data []byte) error { return nil } +func (s *SecondaryCorrelation) MarshalJSON() ([]byte, error) { + type embed SecondaryCorrelation + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *SecondaryCorrelation) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8107,6 +12600,16 @@ func (s *SecondaryCorrelation) String() string { } // Individual sensor configuration. +var ( + sensorFieldSensorID = big.NewInt(1 << 0) + sensorFieldOperationalState = big.NewInt(1 << 1) + sensorFieldSensorType = big.NewInt(1 << 2) + sensorFieldSensorDescription = big.NewInt(1 << 3) + sensorFieldRfConfiguraton = big.NewInt(1 << 4) + sensorFieldLastDetectionTimestamp = big.NewInt(1 << 5) + sensorFieldFieldsOfView = big.NewInt(1 << 6) +) + type Sensor struct { // This generally is used to indicate a specific type at a more detailed granularity. E.g. COMInt or LWIR SensorID *string `json:"sensorId,omitempty" url:"sensorId,omitempty"` @@ -8122,6 +12625,9 @@ type Sensor struct { // Multiple fields of view for a single sensor component FieldsOfView []*FieldOfView `json:"fieldsOfView,omitempty" url:"fieldsOfView,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8179,6 +12685,62 @@ func (s *Sensor) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Sensor) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetSensorID sets the SensorID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetSensorID(sensorID *string) { + s.SensorID = sensorID + s.require(sensorFieldSensorID) +} + +// SetOperationalState sets the OperationalState field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetOperationalState(operationalState *SensorOperationalState) { + s.OperationalState = operationalState + s.require(sensorFieldOperationalState) +} + +// SetSensorType sets the SensorType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetSensorType(sensorType *SensorSensorType) { + s.SensorType = sensorType + s.require(sensorFieldSensorType) +} + +// SetSensorDescription sets the SensorDescription field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetSensorDescription(sensorDescription *string) { + s.SensorDescription = sensorDescription + s.require(sensorFieldSensorDescription) +} + +// SetRfConfiguraton sets the RfConfiguraton field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetRfConfiguraton(rfConfiguraton *RfConfiguration) { + s.RfConfiguraton = rfConfiguraton + s.require(sensorFieldRfConfiguraton) +} + +// SetLastDetectionTimestamp sets the LastDetectionTimestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetLastDetectionTimestamp(lastDetectionTimestamp *time.Time) { + s.LastDetectionTimestamp = lastDetectionTimestamp + s.require(sensorFieldLastDetectionTimestamp) +} + +// SetFieldsOfView sets the FieldsOfView field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensor) SetFieldsOfView(fieldsOfView []*FieldOfView) { + s.FieldsOfView = fieldsOfView + s.require(sensorFieldFieldsOfView) +} + func (s *Sensor) UnmarshalJSON(data []byte) error { type embed Sensor var unmarshaler = struct { @@ -8210,7 +12772,8 @@ func (s *Sensor) MarshalJSON() ([]byte, error) { embed: embed(*s), LastDetectionTimestamp: internal.NewOptionalDateTime(s.LastDetectionTimestamp), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) } func (s *Sensor) String() string { @@ -8304,9 +12867,16 @@ func (s SensorSensorType) Ptr() *SensorSensorType { } // List of sensors available for an entity. +var ( + sensorsFieldSensors = big.NewInt(1 << 0) +) + type Sensors struct { Sensors []*Sensor `json:"sensors,omitempty" url:"sensors,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8322,6 +12892,20 @@ func (s *Sensors) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Sensors) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetSensors sets the Sensors field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Sensors) SetSensors(sensors []*Sensor) { + s.Sensors = sensors + s.require(sensorsFieldSensors) +} + func (s *Sensors) UnmarshalJSON(data []byte) error { type unmarshaler Sensors var value unmarshaler @@ -8338,6 +12922,17 @@ func (s *Sensors) UnmarshalJSON(data []byte) error { return nil } +func (s *Sensors) MarshalJSON() ([]byte, error) { + type embed Sensors + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Sensors) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8351,6 +12946,19 @@ func (s *Sensors) String() string { } // A component that describes an entity's signal characteristics. +var ( + signalFieldFrequencyCenter = big.NewInt(1 << 0) + signalFieldFrequencyRange = big.NewInt(1 << 1) + signalFieldBandwidthHz = big.NewInt(1 << 2) + signalFieldSignalToNoiseRatio = big.NewInt(1 << 3) + signalFieldLineOfBearing = big.NewInt(1 << 4) + signalFieldFixed = big.NewInt(1 << 5) + signalFieldEmitterNotations = big.NewInt(1 << 6) + signalFieldPulseWidthS = big.NewInt(1 << 7) + signalFieldPulseRepetitionInterval = big.NewInt(1 << 8) + signalFieldScanCharacteristics = big.NewInt(1 << 9) +) + type Signal struct { FrequencyCenter *Frequency `json:"frequencyCenter,omitempty" url:"frequencyCenter,omitempty"` FrequencyRange *FrequencyRange `json:"frequencyRange,omitempty" url:"frequencyRange,omitempty"` @@ -8369,6 +12977,9 @@ type Signal struct { // describes how a signal is observing the environment ScanCharacteristics *ScanCharacteristics `json:"scanCharacteristics,omitempty" url:"scanCharacteristics,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8447,6 +13058,83 @@ func (s *Signal) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Signal) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetFrequencyCenter sets the FrequencyCenter field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetFrequencyCenter(frequencyCenter *Frequency) { + s.FrequencyCenter = frequencyCenter + s.require(signalFieldFrequencyCenter) +} + +// SetFrequencyRange sets the FrequencyRange field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetFrequencyRange(frequencyRange *FrequencyRange) { + s.FrequencyRange = frequencyRange + s.require(signalFieldFrequencyRange) +} + +// SetBandwidthHz sets the BandwidthHz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetBandwidthHz(bandwidthHz *float64) { + s.BandwidthHz = bandwidthHz + s.require(signalFieldBandwidthHz) +} + +// SetSignalToNoiseRatio sets the SignalToNoiseRatio field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetSignalToNoiseRatio(signalToNoiseRatio *float64) { + s.SignalToNoiseRatio = signalToNoiseRatio + s.require(signalFieldSignalToNoiseRatio) +} + +// SetLineOfBearing sets the LineOfBearing field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetLineOfBearing(lineOfBearing *LineOfBearing) { + s.LineOfBearing = lineOfBearing + s.require(signalFieldLineOfBearing) +} + +// SetFixed sets the Fixed field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetFixed(fixed *Fixed) { + s.Fixed = fixed + s.require(signalFieldFixed) +} + +// SetEmitterNotations sets the EmitterNotations field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetEmitterNotations(emitterNotations []*EmitterNotation) { + s.EmitterNotations = emitterNotations + s.require(signalFieldEmitterNotations) +} + +// SetPulseWidthS sets the PulseWidthS field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetPulseWidthS(pulseWidthS *float64) { + s.PulseWidthS = pulseWidthS + s.require(signalFieldPulseWidthS) +} + +// SetPulseRepetitionInterval sets the PulseRepetitionInterval field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetPulseRepetitionInterval(pulseRepetitionInterval *PulseRepetitionInterval) { + s.PulseRepetitionInterval = pulseRepetitionInterval + s.require(signalFieldPulseRepetitionInterval) +} + +// SetScanCharacteristics sets the ScanCharacteristics field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Signal) SetScanCharacteristics(scanCharacteristics *ScanCharacteristics) { + s.ScanCharacteristics = scanCharacteristics + s.require(signalFieldScanCharacteristics) +} + func (s *Signal) UnmarshalJSON(data []byte) error { type unmarshaler Signal var value unmarshaler @@ -8463,6 +13151,17 @@ func (s *Signal) UnmarshalJSON(data []byte) error { return nil } +func (s *Signal) MarshalJSON() ([]byte, error) { + type embed Signal + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Signal) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8476,6 +13175,12 @@ func (s *Signal) String() string { } // The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). +var ( + statusFieldCode = big.NewInt(1 << 0) + statusFieldMessage = big.NewInt(1 << 1) + statusFieldDetails = big.NewInt(1 << 2) +) + type Status struct { // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. Code *int `json:"code,omitempty" url:"code,omitempty"` @@ -8484,6 +13189,9 @@ type Status struct { // A list of messages that carry the error details. There is a common set of message types for APIs to use. Details []*GoogleProtobufAny `json:"details,omitempty" url:"details,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8513,6 +13221,34 @@ func (s *Status) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Status) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetCode sets the Code field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Status) SetCode(code *int) { + s.Code = code + s.require(statusFieldCode) +} + +// SetMessage sets the Message field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Status) SetMessage(message *string) { + s.Message = message + s.require(statusFieldMessage) +} + +// SetDetails sets the Details field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Status) SetDetails(details []*GoogleProtobufAny) { + s.Details = details + s.require(statusFieldDetails) +} + func (s *Status) UnmarshalJSON(data []byte) error { type unmarshaler Status var value unmarshaler @@ -8529,6 +13265,17 @@ func (s *Status) UnmarshalJSON(data []byte) error { return nil } +func (s *Status) MarshalJSON() ([]byte, error) { + type embed Status + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Status) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8542,9 +13289,16 @@ func (s *Status) String() string { } // Represents the state of supplies associated with an entity (available but not in condition to use immediately) +var ( + suppliesFieldFuel = big.NewInt(1 << 0) +) + type Supplies struct { Fuel []*Fuel `json:"fuel,omitempty" url:"fuel,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8560,6 +13314,20 @@ func (s *Supplies) GetExtraProperties() map[string]interface{} { return s.extraProperties } +func (s *Supplies) require(field *big.Int) { + if s.explicitFields == nil { + s.explicitFields = big.NewInt(0) + } + s.explicitFields.Or(s.explicitFields, field) +} + +// SetFuel sets the Fuel field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (s *Supplies) SetFuel(fuel []*Fuel) { + s.Fuel = fuel + s.require(suppliesFieldFuel) +} + func (s *Supplies) UnmarshalJSON(data []byte) error { type unmarshaler Supplies var value unmarshaler @@ -8576,6 +13344,17 @@ func (s *Supplies) UnmarshalJSON(data []byte) error { return nil } +func (s *Supplies) MarshalJSON() ([]byte, error) { + type embed Supplies + var marshaler = struct { + embed + }{ + embed: embed(*s), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (s *Supplies) String() string { if len(s.rawJSON) > 0 { if value, err := internal.StringifyJSON(s.rawJSON); err == nil { @@ -8591,11 +13370,20 @@ func (s *Supplies) String() string { // symmetric 2d matrix only representing the upper right triangle, useful for // // covariance matrices +var ( + tMat2FieldMxx = big.NewInt(1 << 0) + tMat2FieldMxy = big.NewInt(1 << 1) + tMat2FieldMyy = big.NewInt(1 << 2) +) + type TMat2 struct { Mxx *float64 `json:"mxx,omitempty" url:"mxx,omitempty"` Mxy *float64 `json:"mxy,omitempty" url:"mxy,omitempty"` Myy *float64 `json:"myy,omitempty" url:"myy,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8625,6 +13413,34 @@ func (t *TMat2) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TMat2) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetMxx sets the Mxx field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat2) SetMxx(mxx *float64) { + t.Mxx = mxx + t.require(tMat2FieldMxx) +} + +// SetMxy sets the Mxy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat2) SetMxy(mxy *float64) { + t.Mxy = mxy + t.require(tMat2FieldMxy) +} + +// SetMyy sets the Myy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat2) SetMyy(myy *float64) { + t.Myy = myy + t.require(tMat2FieldMyy) +} + func (t *TMat2) UnmarshalJSON(data []byte) error { type unmarshaler TMat2 var value unmarshaler @@ -8641,6 +13457,17 @@ func (t *TMat2) UnmarshalJSON(data []byte) error { return nil } +func (t *TMat2) MarshalJSON() ([]byte, error) { + type embed TMat2 + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TMat2) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8654,6 +13481,15 @@ func (t *TMat2) String() string { } // Symmetric 3d matrix only representing the upper right triangle. +var ( + tMat3FieldMxx = big.NewInt(1 << 0) + tMat3FieldMxy = big.NewInt(1 << 1) + tMat3FieldMxz = big.NewInt(1 << 2) + tMat3FieldMyy = big.NewInt(1 << 3) + tMat3FieldMyz = big.NewInt(1 << 4) + tMat3FieldMzz = big.NewInt(1 << 5) +) + type TMat3 struct { Mxx *float64 `json:"mxx,omitempty" url:"mxx,omitempty"` Mxy *float64 `json:"mxy,omitempty" url:"mxy,omitempty"` @@ -8662,6 +13498,9 @@ type TMat3 struct { Myz *float64 `json:"myz,omitempty" url:"myz,omitempty"` Mzz *float64 `json:"mzz,omitempty" url:"mzz,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8712,6 +13551,55 @@ func (t *TMat3) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TMat3) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetMxx sets the Mxx field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMxx(mxx *float64) { + t.Mxx = mxx + t.require(tMat3FieldMxx) +} + +// SetMxy sets the Mxy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMxy(mxy *float64) { + t.Mxy = mxy + t.require(tMat3FieldMxy) +} + +// SetMxz sets the Mxz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMxz(mxz *float64) { + t.Mxz = mxz + t.require(tMat3FieldMxz) +} + +// SetMyy sets the Myy field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMyy(myy *float64) { + t.Myy = myy + t.require(tMat3FieldMyy) +} + +// SetMyz sets the Myz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMyz(myz *float64) { + t.Myz = myz + t.require(tMat3FieldMyz) +} + +// SetMzz sets the Mzz field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TMat3) SetMzz(mzz *float64) { + t.Mzz = mzz + t.require(tMat3FieldMzz) +} + func (t *TMat3) UnmarshalJSON(data []byte) error { type unmarshaler TMat3 var value unmarshaler @@ -8728,6 +13616,17 @@ func (t *TMat3) UnmarshalJSON(data []byte) error { return nil } +func (t *TMat3) MarshalJSON() ([]byte, error) { + type embed TMat3 + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TMat3) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8741,12 +13640,20 @@ func (t *TMat3) String() string { } // The target prioritization associated with an entity. +var ( + targetPriorityFieldHighValueTarget = big.NewInt(1 << 0) + targetPriorityFieldThreat = big.NewInt(1 << 1) +) + type TargetPriority struct { // Describes the target priority in relation to high value target lists. HighValueTarget *HighValueTarget `json:"highValueTarget,omitempty" url:"highValueTarget,omitempty"` // Describes whether the entity should be treated as a threat Threat *Threat `json:"threat,omitempty" url:"threat,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8769,6 +13676,27 @@ func (t *TargetPriority) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TargetPriority) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetHighValueTarget sets the HighValueTarget field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TargetPriority) SetHighValueTarget(highValueTarget *HighValueTarget) { + t.HighValueTarget = highValueTarget + t.require(targetPriorityFieldHighValueTarget) +} + +// SetThreat sets the Threat field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TargetPriority) SetThreat(threat *Threat) { + t.Threat = threat + t.require(targetPriorityFieldThreat) +} + func (t *TargetPriority) UnmarshalJSON(data []byte) error { type unmarshaler TargetPriority var value unmarshaler @@ -8785,6 +13713,17 @@ func (t *TargetPriority) UnmarshalJSON(data []byte) error { return nil } +func (t *TargetPriority) MarshalJSON() ([]byte, error) { + type embed TargetPriority + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TargetPriority) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8798,9 +13737,16 @@ func (t *TargetPriority) String() string { } // Catalog of supported tasks. +var ( + taskCatalogFieldTaskDefinitions = big.NewInt(1 << 0) +) + type TaskCatalog struct { TaskDefinitions []*TaskDefinition `json:"taskDefinitions,omitempty" url:"taskDefinitions,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8816,6 +13762,20 @@ func (t *TaskCatalog) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskCatalog) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTaskDefinitions sets the TaskDefinitions field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskCatalog) SetTaskDefinitions(taskDefinitions []*TaskDefinition) { + t.TaskDefinitions = taskDefinitions + t.require(taskCatalogFieldTaskDefinitions) +} + func (t *TaskCatalog) UnmarshalJSON(data []byte) error { type unmarshaler TaskCatalog var value unmarshaler @@ -8832,6 +13792,17 @@ func (t *TaskCatalog) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskCatalog) MarshalJSON() ([]byte, error) { + type embed TaskCatalog + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskCatalog) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8845,10 +13816,17 @@ func (t *TaskCatalog) String() string { } // Defines a supported task by the task specification URL of its "Any" type. +var ( + taskDefinitionFieldTaskSpecificationURL = big.NewInt(1 << 0) +) + type TaskDefinition struct { // Url path must be prefixed with `type.googleapis.com/`. TaskSpecificationURL *string `json:"taskSpecificationUrl,omitempty" url:"taskSpecificationUrl,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8864,6 +13842,20 @@ func (t *TaskDefinition) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TaskDefinition) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTaskSpecificationURL sets the TaskSpecificationURL field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TaskDefinition) SetTaskSpecificationURL(taskSpecificationURL *string) { + t.TaskSpecificationURL = taskSpecificationURL + t.require(taskDefinitionFieldTaskSpecificationURL) +} + func (t *TaskDefinition) UnmarshalJSON(data []byte) error { type unmarshaler TaskDefinition var value unmarshaler @@ -8880,6 +13872,17 @@ func (t *TaskDefinition) UnmarshalJSON(data []byte) error { return nil } +func (t *TaskDefinition) MarshalJSON() ([]byte, error) { + type embed TaskDefinition + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TaskDefinition) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8893,11 +13896,19 @@ func (t *TaskDefinition) String() string { } // Represents a team of agents +var ( + teamFieldEntityID = big.NewInt(1 << 0) + teamFieldMembers = big.NewInt(1 << 1) +) + type Team struct { // Entity ID of the team EntityID *string `json:"entityId,omitempty" url:"entityId,omitempty"` Members []*Agent `json:"members,omitempty" url:"members,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8920,6 +13931,27 @@ func (t *Team) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *Team) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetEntityID sets the EntityID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Team) SetEntityID(entityID *string) { + t.EntityID = entityID + t.require(teamFieldEntityID) +} + +// SetMembers sets the Members field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Team) SetMembers(members []*Agent) { + t.Members = members + t.require(teamFieldMembers) +} + func (t *Team) UnmarshalJSON(data []byte) error { type unmarshaler Team var value unmarshaler @@ -8936,6 +13968,17 @@ func (t *Team) UnmarshalJSON(data []byte) error { return nil } +func (t *Team) MarshalJSON() ([]byte, error) { + type embed Team + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *Team) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8949,10 +13992,17 @@ func (t *Team) String() string { } // Describes whether an entity is a threat or not. +var ( + threatFieldIsThreat = big.NewInt(1 << 0) +) + type Threat struct { // Indicates that the entity has been determined to be a threat. IsThreat *bool `json:"isThreat,omitempty" url:"isThreat,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -8968,6 +14018,20 @@ func (t *Threat) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *Threat) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetIsThreat sets the IsThreat field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Threat) SetIsThreat(isThreat *bool) { + t.IsThreat = isThreat + t.require(threatFieldIsThreat) +} + func (t *Threat) UnmarshalJSON(data []byte) error { type unmarshaler Threat var value unmarshaler @@ -8984,6 +14048,17 @@ func (t *Threat) UnmarshalJSON(data []byte) error { return nil } +func (t *Threat) MarshalJSON() ([]byte, error) { + type embed Threat + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *Threat) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -8999,6 +14074,19 @@ func (t *Threat) String() string { // The datetime string in ISO 8601 format. type Timestamp = string +var ( + tleParametersFieldEphemerisType = big.NewInt(1 << 0) + tleParametersFieldClassificationType = big.NewInt(1 << 1) + tleParametersFieldNoradCatID = big.NewInt(1 << 2) + tleParametersFieldElementSetNo = big.NewInt(1 << 3) + tleParametersFieldRevAtEpoch = big.NewInt(1 << 4) + tleParametersFieldBstar = big.NewInt(1 << 5) + tleParametersFieldBterm = big.NewInt(1 << 6) + tleParametersFieldMeanMotionDot = big.NewInt(1 << 7) + tleParametersFieldMeanMotionDdot = big.NewInt(1 << 8) + tleParametersFieldAgom = big.NewInt(1 << 9) +) + type TleParameters struct { // Integer specifying TLE ephemeris type EphemerisType *int `json:"ephemerisType,omitempty" url:"ephemerisType,omitempty"` @@ -9020,6 +14108,9 @@ type TleParameters struct { // Solar radiation pressure coefficient A_gamma / m in m^2 / kg. For use with SGP4-XP. Agom *float64 `json:"agom,omitempty" url:"agom,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9098,6 +14189,83 @@ func (t *TleParameters) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TleParameters) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetEphemerisType sets the EphemerisType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetEphemerisType(ephemerisType *int) { + t.EphemerisType = ephemerisType + t.require(tleParametersFieldEphemerisType) +} + +// SetClassificationType sets the ClassificationType field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetClassificationType(classificationType *string) { + t.ClassificationType = classificationType + t.require(tleParametersFieldClassificationType) +} + +// SetNoradCatID sets the NoradCatID field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetNoradCatID(noradCatID *int) { + t.NoradCatID = noradCatID + t.require(tleParametersFieldNoradCatID) +} + +// SetElementSetNo sets the ElementSetNo field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetElementSetNo(elementSetNo *int) { + t.ElementSetNo = elementSetNo + t.require(tleParametersFieldElementSetNo) +} + +// SetRevAtEpoch sets the RevAtEpoch field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetRevAtEpoch(revAtEpoch *int) { + t.RevAtEpoch = revAtEpoch + t.require(tleParametersFieldRevAtEpoch) +} + +// SetBstar sets the Bstar field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetBstar(bstar *float64) { + t.Bstar = bstar + t.require(tleParametersFieldBstar) +} + +// SetBterm sets the Bterm field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetBterm(bterm *float64) { + t.Bterm = bterm + t.require(tleParametersFieldBterm) +} + +// SetMeanMotionDot sets the MeanMotionDot field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetMeanMotionDot(meanMotionDot *float64) { + t.MeanMotionDot = meanMotionDot + t.require(tleParametersFieldMeanMotionDot) +} + +// SetMeanMotionDdot sets the MeanMotionDdot field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetMeanMotionDdot(meanMotionDdot *float64) { + t.MeanMotionDdot = meanMotionDdot + t.require(tleParametersFieldMeanMotionDdot) +} + +// SetAgom sets the Agom field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TleParameters) SetAgom(agom *float64) { + t.Agom = agom + t.require(tleParametersFieldAgom) +} + func (t *TleParameters) UnmarshalJSON(data []byte) error { type unmarshaler TleParameters var value unmarshaler @@ -9114,6 +14282,17 @@ func (t *TleParameters) UnmarshalJSON(data []byte) error { return nil } +func (t *TleParameters) MarshalJSON() ([]byte, error) { + type embed TleParameters + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TleParameters) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -9127,6 +14306,15 @@ func (t *TleParameters) String() string { } // Available for Entities that are tracked. +var ( + trackedFieldTrackQualityWrapper = big.NewInt(1 << 0) + trackedFieldSensorHits = big.NewInt(1 << 1) + trackedFieldNumberOfObjects = big.NewInt(1 << 2) + trackedFieldRadarCrossSection = big.NewInt(1 << 3) + trackedFieldLastMeasurementTime = big.NewInt(1 << 4) + trackedFieldLineOfBearing = big.NewInt(1 << 5) +) + type Tracked struct { // Quality score, 0-15, nil if none TrackQualityWrapper *int `json:"trackQualityWrapper,omitempty" url:"trackQualityWrapper,omitempty"` @@ -9151,6 +14339,9 @@ type Tracked struct { // For this entity (A), being tracked by some entity (B), this LineOfBearing would express a ray from B to A. LineOfBearing *LineOfBearing `json:"lineOfBearing,omitempty" url:"lineOfBearing,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9201,6 +14392,55 @@ func (t *Tracked) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *Tracked) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetTrackQualityWrapper sets the TrackQualityWrapper field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetTrackQualityWrapper(trackQualityWrapper *int) { + t.TrackQualityWrapper = trackQualityWrapper + t.require(trackedFieldTrackQualityWrapper) +} + +// SetSensorHits sets the SensorHits field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetSensorHits(sensorHits *int) { + t.SensorHits = sensorHits + t.require(trackedFieldSensorHits) +} + +// SetNumberOfObjects sets the NumberOfObjects field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetNumberOfObjects(numberOfObjects *UInt32Range) { + t.NumberOfObjects = numberOfObjects + t.require(trackedFieldNumberOfObjects) +} + +// SetRadarCrossSection sets the RadarCrossSection field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetRadarCrossSection(radarCrossSection *float64) { + t.RadarCrossSection = radarCrossSection + t.require(trackedFieldRadarCrossSection) +} + +// SetLastMeasurementTime sets the LastMeasurementTime field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetLastMeasurementTime(lastMeasurementTime *time.Time) { + t.LastMeasurementTime = lastMeasurementTime + t.require(trackedFieldLastMeasurementTime) +} + +// SetLineOfBearing sets the LineOfBearing field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *Tracked) SetLineOfBearing(lineOfBearing *LineOfBearing) { + t.LineOfBearing = lineOfBearing + t.require(trackedFieldLineOfBearing) +} + func (t *Tracked) UnmarshalJSON(data []byte) error { type embed Tracked var unmarshaler = struct { @@ -9232,7 +14472,8 @@ func (t *Tracked) MarshalJSON() ([]byte, error) { embed: embed(*t), LastMeasurementTime: internal.NewOptionalDateTime(t.LastMeasurementTime), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) } func (t *Tracked) String() string { @@ -9250,6 +14491,11 @@ func (t *Tracked) String() string { // Describes the relationship between the entity being tracked ("tracked entity") and the entity that is // // performing the tracking ("tracking entity"). +var ( + trackedByFieldActivelyTrackingSensors = big.NewInt(1 << 0) + trackedByFieldLastMeasurementTimestamp = big.NewInt(1 << 1) +) + type TrackedBy struct { // Sensor details of the tracking entity's sensors that were active and tracking the tracked entity. This may be // @@ -9258,6 +14504,9 @@ type TrackedBy struct { // Latest time that any sensor in actively_tracking_sensors detected the tracked entity. LastMeasurementTimestamp *time.Time `json:"lastMeasurementTimestamp,omitempty" url:"lastMeasurementTimestamp,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9280,6 +14529,27 @@ func (t *TrackedBy) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TrackedBy) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetActivelyTrackingSensors sets the ActivelyTrackingSensors field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TrackedBy) SetActivelyTrackingSensors(activelyTrackingSensors *Sensors) { + t.ActivelyTrackingSensors = activelyTrackingSensors + t.require(trackedByFieldActivelyTrackingSensors) +} + +// SetLastMeasurementTimestamp sets the LastMeasurementTimestamp field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TrackedBy) SetLastMeasurementTimestamp(lastMeasurementTimestamp *time.Time) { + t.LastMeasurementTimestamp = lastMeasurementTimestamp + t.require(trackedByFieldLastMeasurementTimestamp) +} + func (t *TrackedBy) UnmarshalJSON(data []byte) error { type embed TrackedBy var unmarshaler = struct { @@ -9311,7 +14581,8 @@ func (t *TrackedBy) MarshalJSON() ([]byte, error) { embed: embed(*t), LastMeasurementTimestamp: internal.NewOptionalDateTime(t.LastMeasurementTimestamp), } - return json.Marshal(marshaler) + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) } func (t *TrackedBy) String() string { @@ -9327,6 +14598,15 @@ func (t *TrackedBy) String() string { } // A message describing any transponder codes associated with Mode 1, 2, 3, 4, 5, S interrogations. +var ( + transponderCodesFieldMode1 = big.NewInt(1 << 0) + transponderCodesFieldMode2 = big.NewInt(1 << 1) + transponderCodesFieldMode3 = big.NewInt(1 << 2) + transponderCodesFieldMode4InterrogationResponse = big.NewInt(1 << 3) + transponderCodesFieldMode5 = big.NewInt(1 << 4) + transponderCodesFieldModeS = big.NewInt(1 << 5) +) + type TransponderCodes struct { // The mode 1 code assigned to military assets. Mode1 *int `json:"mode1,omitempty" url:"mode1,omitempty"` @@ -9341,6 +14621,9 @@ type TransponderCodes struct { // The Mode S transponder codes. ModeS *ModeS `json:"modeS,omitempty" url:"modeS,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9391,6 +14674,55 @@ func (t *TransponderCodes) GetExtraProperties() map[string]interface{} { return t.extraProperties } +func (t *TransponderCodes) require(field *big.Int) { + if t.explicitFields == nil { + t.explicitFields = big.NewInt(0) + } + t.explicitFields.Or(t.explicitFields, field) +} + +// SetMode1 sets the Mode1 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetMode1(mode1 *int) { + t.Mode1 = mode1 + t.require(transponderCodesFieldMode1) +} + +// SetMode2 sets the Mode2 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetMode2(mode2 *int) { + t.Mode2 = mode2 + t.require(transponderCodesFieldMode2) +} + +// SetMode3 sets the Mode3 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetMode3(mode3 *int) { + t.Mode3 = mode3 + t.require(transponderCodesFieldMode3) +} + +// SetMode4InterrogationResponse sets the Mode4InterrogationResponse field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetMode4InterrogationResponse(mode4InterrogationResponse *TransponderCodesMode4InterrogationResponse) { + t.Mode4InterrogationResponse = mode4InterrogationResponse + t.require(transponderCodesFieldMode4InterrogationResponse) +} + +// SetMode5 sets the Mode5 field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetMode5(mode5 *Mode5) { + t.Mode5 = mode5 + t.require(transponderCodesFieldMode5) +} + +// SetModeS sets the ModeS field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (t *TransponderCodes) SetModeS(modeS *ModeS) { + t.ModeS = modeS + t.require(transponderCodesFieldModeS) +} + func (t *TransponderCodes) UnmarshalJSON(data []byte) error { type unmarshaler TransponderCodes var value unmarshaler @@ -9407,6 +14739,17 @@ func (t *TransponderCodes) UnmarshalJSON(data []byte) error { return nil } +func (t *TransponderCodes) MarshalJSON() ([]byte, error) { + type embed TransponderCodes + var marshaler = struct { + embed + }{ + embed: embed(*t), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, t.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (t *TransponderCodes) String() string { if len(t.rawJSON) > 0 { if value, err := internal.StringifyJSON(t.rawJSON); err == nil { @@ -9448,10 +14791,18 @@ func (t TransponderCodesMode4InterrogationResponse) Ptr() *TransponderCodesMode4 return &t } +var ( + uInt32RangeFieldLowerBound = big.NewInt(1 << 0) + uInt32RangeFieldUpperBound = big.NewInt(1 << 1) +) + type UInt32Range struct { LowerBound *int `json:"lowerBound,omitempty" url:"lowerBound,omitempty"` UpperBound *int `json:"upperBound,omitempty" url:"upperBound,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9474,6 +14825,27 @@ func (u *UInt32Range) GetExtraProperties() map[string]interface{} { return u.extraProperties } +func (u *UInt32Range) require(field *big.Int) { + if u.explicitFields == nil { + u.explicitFields = big.NewInt(0) + } + u.explicitFields.Or(u.explicitFields, field) +} + +// SetLowerBound sets the LowerBound field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (u *UInt32Range) SetLowerBound(lowerBound *int) { + u.LowerBound = lowerBound + u.require(uInt32RangeFieldLowerBound) +} + +// SetUpperBound sets the UpperBound field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (u *UInt32Range) SetUpperBound(upperBound *int) { + u.UpperBound = upperBound + u.require(uInt32RangeFieldUpperBound) +} + func (u *UInt32Range) UnmarshalJSON(data []byte) error { type unmarshaler UInt32Range var value unmarshaler @@ -9490,6 +14862,17 @@ func (u *UInt32Range) UnmarshalJSON(data []byte) error { return nil } +func (u *UInt32Range) MarshalJSON() ([]byte, error) { + type embed UInt32Range + var marshaler = struct { + embed + }{ + embed: embed(*u), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, u.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (u *UInt32Range) String() string { if len(u.rawJSON) > 0 { if value, err := internal.StringifyJSON(u.rawJSON); err == nil { @@ -9503,10 +14886,17 @@ func (u *UInt32Range) String() string { } // Visual details associated with the display of an entity in the client. +var ( + visualDetailsFieldRangeRings = big.NewInt(1 << 0) +) + type VisualDetails struct { // The range rings to display around an entity. RangeRings *RangeRings `json:"rangeRings,omitempty" url:"rangeRings,omitempty"` + // Private bitmask of fields set to an explicit value and therefore not to be omitted + explicitFields *big.Int `json:"-" url:"-"` + extraProperties map[string]interface{} rawJSON json.RawMessage } @@ -9522,6 +14912,20 @@ func (v *VisualDetails) GetExtraProperties() map[string]interface{} { return v.extraProperties } +func (v *VisualDetails) require(field *big.Int) { + if v.explicitFields == nil { + v.explicitFields = big.NewInt(0) + } + v.explicitFields.Or(v.explicitFields, field) +} + +// SetRangeRings sets the RangeRings field and marks it as non-optional; +// this prevents an empty or null value for this field from being omitted during serialization. +func (v *VisualDetails) SetRangeRings(rangeRings *RangeRings) { + v.RangeRings = rangeRings + v.require(visualDetailsFieldRangeRings) +} + func (v *VisualDetails) UnmarshalJSON(data []byte) error { type unmarshaler VisualDetails var value unmarshaler @@ -9538,6 +14942,17 @@ func (v *VisualDetails) UnmarshalJSON(data []byte) error { return nil } +func (v *VisualDetails) MarshalJSON() ([]byte, error) { + type embed VisualDetails + var marshaler = struct { + embed + }{ + embed: embed(*v), + } + explicitMarshaler := internal.HandleExplicitFields(marshaler, v.explicitFields) + return json.Marshal(explicitMarshaler) +} + func (v *VisualDetails) String() string { if len(v.rawJSON) > 0 { if value, err := internal.StringifyJSON(v.rawJSON); err == nil {