| 1 | // Copyright (C) MongoDB, Inc. 2017-present. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package unifiedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/ |
| 8 | |
| 9 | import ( |
| 10 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 11 | |
| 12 | "go.mongodb.org/mongo-driver/bsonscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson`/" |
| 13 | "go.mongodb.org/mongo-driver/mongo/optionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/" |
| 14 | ) |
| 15 | |
| 16 | // serverAPIOptions is a wrapper for *options.ServerAPIOptions. This type implements the bson.Unmarshaler interface |
| 17 | // to convert BSON documents to a serverAPIOptions instance. |
| 18 | type serverAPIOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions# struct { |
| 19 | *optionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/.ServerAPIOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions#ServerAPIOptions. |
| 20 | } |
| 21 | |
| 22 | type serverAPIVersionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIVersion# = optionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/.ServerAPIVersionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/ServerAPIVersion# |
| 23 | |
| 24 | var _ bsonscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson`/.Unmarshalerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson`/Unmarshaler# = (*serverAPIOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions#)(nil) |
| 25 | |
| 26 | func (s *serverAPIOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions#) UnmarshalBSONscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions#UnmarshalBSON().(data []byte) error { |
| 27 | var temp struct { |
| 28 | ServerAPIVersion serverAPIVersionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIVersion# `bson:"version"` |
| 29 | DeprecationErrors *bool `bson:"deprecationErrors"` |
| 30 | Strict *bool `bson:"strict"` |
| 31 | Extra map[string]interface{} `bson:",inline"` |
| 32 | } |
| 33 | if err := bsonscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson`/.Unmarshalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson`/Unmarshal().(data, &temp); err != nil { |
| 34 | return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("error unmarshalling to temporary serverAPIOptions object: %v", err) |
| 35 | } |
| 36 | if len(temp.Extra) > 0 { |
| 37 | return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("unrecognized fields for serverAPIOptions: %v", mapKeysscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/mapKeys().(temp.Extra)) |
| 38 | } |
| 39 | |
| 40 | s.ServerAPIOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/integration/unified`/serverAPIOptions#ServerAPIOptions. = optionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/.ServerAPIscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/ServerAPI().(temp.ServerAPIVersion) |
| 41 | if temp.DeprecationErrors != nil { |
| 42 | s.SetDeprecationErrorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/ServerAPIOptions#SetDeprecationErrors().(*temp.DeprecationErrors) |
| 43 | } |
| 44 | if temp.Strict != nil { |
| 45 | s.SetStrictscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/options`/ServerAPIOptions#SetStrict().(*temp.Strict) |
| 46 | } |
| 47 | |
| 48 | return nil |
| 49 | } |