github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/x/mongo/driver/serverapioptions.go (about) 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 driver 8 9 // TestServerAPIVersion is the most recent, stable variant of options.ServerAPIVersion. 10 // Only to be used in testing. 11 const TestServerAPIVersion = "1" 12 13 // ServerAPIOptions represents options used to configure the API version sent to the server 14 // when running commands. 15 type ServerAPIOptions struct { 16 ServerAPIVersion string 17 Strict *bool 18 DeprecationErrors *bool 19 } 20 21 // NewServerAPIOptions creates a new ServerAPIOptions configured with the provided serverAPIVersion. 22 func NewServerAPIOptions(serverAPIVersion string) *ServerAPIOptions { 23 return &ServerAPIOptions{ServerAPIVersion: serverAPIVersion} 24 } 25 26 // SetStrict specifies whether the server should return errors for features that are not part of the API version. 27 func (s *ServerAPIOptions) SetStrict(strict bool) *ServerAPIOptions { 28 s.Strict = &strict 29 return s 30 } 31 32 // SetDeprecationErrors specifies whether the server should return errors for deprecated features. 33 func (s *ServerAPIOptions) SetDeprecationErrors(deprecationErrors bool) *ServerAPIOptions { 34 s.DeprecationErrors = &deprecationErrors 35 return s 36 }