api

package
v1.24.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

Data API

openapi-original.json is the original file downloaded from https://www.mongodb.com/docs/atlas/app-services/data-api/openapi/.

openapi.json is a slightly modified file for Open API 3.0 support. See https://github.com/oapi-codegen/oapi-codegen/issues/373.

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT.

Index

Constants

View Source
const (
	HttpAuthScopes = "HttpAuth.Scopes"
)

Variables

View Source
var Spec []byte

Spec is the embedded OpenAPI specification.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type AggregateJSONBody

type AggregateJSONBody = AggregateRequestBody

AggregateJSONBody defines parameters for Aggregate.

type AggregateJSONRequestBody

type AggregateJSONRequestBody = AggregateJSONBody

AggregateJSONRequestBody defines body for Aggregate for application/json ContentType.

type AggregateRequestBody

type AggregateRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Pipeline An array of aggregation stages.
	Pipeline *json.RawMessage `json:"pipeline,omitempty"`
}

AggregateRequestBody defines model for AggregateRequestBody.

type AggregateResponseBody

type AggregateResponseBody struct {
	// Documents An array that contains the result set of the aggregation.
	Documents json.RawMessage `json:"documents"`
}

AggregateResponseBody defines model for AggregateResponseBody.

type BadRequestError

type BadRequestError struct {
	// contains filtered or unexported fields
}

BadRequestError defines model for BadRequestError.

func (BadRequestError) AsErrorMissingAuthenticationParameter

func (t BadRequestError) AsErrorMissingAuthenticationParameter() (ErrorMissingAuthenticationParameter, error)

AsErrorMissingAuthenticationParameter returns the union data inside the BadRequestError as a ErrorMissingAuthenticationParameter

func (BadRequestError) AsErrorNoAuthenticationSpecified

func (t BadRequestError) AsErrorNoAuthenticationSpecified() (ErrorNoAuthenticationSpecified, error)

AsErrorNoAuthenticationSpecified returns the union data inside the BadRequestError as a ErrorNoAuthenticationSpecified

func (*BadRequestError) FromErrorMissingAuthenticationParameter

func (t *BadRequestError) FromErrorMissingAuthenticationParameter(v ErrorMissingAuthenticationParameter) error

FromErrorMissingAuthenticationParameter overwrites any union data inside the BadRequestError as the provided ErrorMissingAuthenticationParameter

func (*BadRequestError) FromErrorNoAuthenticationSpecified

func (t *BadRequestError) FromErrorNoAuthenticationSpecified(v ErrorNoAuthenticationSpecified) error

FromErrorNoAuthenticationSpecified overwrites any union data inside the BadRequestError as the provided ErrorNoAuthenticationSpecified

func (BadRequestError) MarshalJSON

func (t BadRequestError) MarshalJSON() ([]byte, error)

func (*BadRequestError) MergeErrorMissingAuthenticationParameter

func (t *BadRequestError) MergeErrorMissingAuthenticationParameter(v ErrorMissingAuthenticationParameter) error

MergeErrorMissingAuthenticationParameter performs a merge with any union data inside the BadRequestError, using the provided ErrorMissingAuthenticationParameter

func (*BadRequestError) MergeErrorNoAuthenticationSpecified

func (t *BadRequestError) MergeErrorNoAuthenticationSpecified(v ErrorNoAuthenticationSpecified) error

MergeErrorNoAuthenticationSpecified performs a merge with any union data inside the BadRequestError, using the provided ErrorNoAuthenticationSpecified

func (*BadRequestError) UnmarshalJSON

func (t *BadRequestError) UnmarshalJSON(b []byte) error

type DeleteManyJSONBody

type DeleteManyJSONBody = DeleteRequestBody

DeleteManyJSONBody defines parameters for DeleteMany.

type DeleteManyJSONRequestBody

type DeleteManyJSONRequestBody = DeleteManyJSONBody

DeleteManyJSONRequestBody defines body for DeleteMany for application/json ContentType.

type DeleteOneJSONBody

type DeleteOneJSONBody = DeleteRequestBody

DeleteOneJSONBody defines parameters for DeleteOne.

type DeleteOneJSONRequestBody

type DeleteOneJSONRequestBody = DeleteOneJSONBody

DeleteOneJSONRequestBody defines body for DeleteOne for application/json ContentType.

type DeleteRequestBody

type DeleteRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Filter A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
	Filter *json.RawMessage `json:"filter,omitempty"`
}

DeleteRequestBody defines model for DeleteRequestBody.

type DeleteResponseBody

type DeleteResponseBody struct {
	// DeletedCount The number of documents that were deleted.
	DeletedCount interface{} `json:"deletedCount"`
}

DeleteResponseBody defines model for DeleteResponseBody.

type Error

type Error struct {
	// Error A message that describes the error.
	Error string `json:"error,omitempty"`

	// ErrorCode The error type.
	ErrorCode string `json:"error_code,omitempty"`

	// Link A link to a [log entry](https://www.mongodb.com/docs/atlas/app-services/logs/endpoint/) for the failed operation.
	Link string `json:"link,omitempty"`
}

Error defines model for Error.

type ErrorMissingAuthenticationParameter

type ErrorMissingAuthenticationParameter struct {
	Error     interface{} `json:"error,omitempty"`
	ErrorCode interface{} `json:"error_code,omitempty"`

	// Link A link to a [log entry](https://www.mongodb.com/docs/atlas/app-services/logs/endpoint/) for the failed operation.
	Link string `json:"link,omitempty"`
}

ErrorMissingAuthenticationParameter defines model for ErrorMissingAuthenticationParameter.

type ErrorNoAuthenticationSpecified

type ErrorNoAuthenticationSpecified struct {
	Error     interface{} `json:"error,omitempty"`
	ErrorCode interface{} `json:"error_code,omitempty"`

	// Link A link to a [log entry](https://www.mongodb.com/docs/atlas/app-services/logs/endpoint/) for the failed operation.
	Link string `json:"link,omitempty"`
}

ErrorNoAuthenticationSpecified defines model for ErrorNoAuthenticationSpecified.

type ErrorUserNotFound

type ErrorUserNotFound struct {
	Error     interface{} `json:"error,omitempty"`
	ErrorCode interface{} `json:"error_code,omitempty"`

	// Link A link to a [log entry](https://www.mongodb.com/docs/atlas/app-services/logs/endpoint/) for the failed operation.
	Link string `json:"link,omitempty"`
}

ErrorUserNotFound defines model for ErrorUserNotFound.

type Filter

type Filter struct {
	// Filter A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
	Filter *json.RawMessage `json:"filter,omitempty"`
}

Filter defines model for Filter.

type FindJSONBody

type FindJSONBody = FindManyRequestBody

FindJSONBody defines parameters for Find.

type FindJSONRequestBody

type FindJSONRequestBody = FindJSONBody

FindJSONRequestBody defines body for Find for application/json ContentType.

type FindManyRequestBody

type FindManyRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Filter A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
	Filter *json.RawMessage `json:"filter,omitempty"`

	// Limit The maximum number of matching documents to include the in the response.
	Limit *float32 `json:"limit,omitempty"`

	// Projection A [MongoDB projection](https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/) for matched documents returned by the operation.
	Projection *json.RawMessage `json:"projection,omitempty"`

	// Skip The number of matching documents to omit from the response.
	Skip *float32 `json:"skip,omitempty"`

	// Sort A [MongoDB sort expression](https://www.mongodb.com/docs/manual/reference/method/cursor.sort/) that indicates sorted field names and directions.
	Sort *json.RawMessage `json:"sort,omitempty"`
}

FindManyRequestBody defines model for FindManyRequestBody.

type FindManyResponseBody

type FindManyResponseBody struct {
	// Documents A list of documents that match the specified filter.
	Documents *json.RawMessage `json:"documents,omitempty"`
}

FindManyResponseBody The result of a find operation.

type FindOneJSONBody

type FindOneJSONBody = FindOneRequestBody

FindOneJSONBody defines parameters for FindOne.

type FindOneJSONRequestBody

type FindOneJSONRequestBody = FindOneJSONBody

FindOneJSONRequestBody defines body for FindOne for application/json ContentType.

type FindOneRequestBody

type FindOneRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Filter A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
	Filter *json.RawMessage `json:"filter,omitempty"`

	// Projection A [MongoDB projection](https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/) for matched documents returned by the operation.
	Projection *json.RawMessage `json:"projection,omitempty"`
}

FindOneRequestBody defines model for FindOneRequestBody.

type FindOneResponseBody

type FindOneResponseBody struct {
	// Document A document that matches the specified filter. If no documents match, this is `null`.
	Document *json.RawMessage `json:"document"`
}

FindOneResponseBody The result of a findOne operation.

type InsertManyJSONBody

type InsertManyJSONBody = InsertManyRequestBody

InsertManyJSONBody defines parameters for InsertMany.

type InsertManyJSONRequestBody

type InsertManyJSONRequestBody = InsertManyJSONBody

InsertManyJSONRequestBody defines body for InsertMany for application/json ContentType.

type InsertManyRequestBody

type InsertManyRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Documents A list of documents to insert into the collection.
	Documents json.RawMessage `json:"documents"`
}

InsertManyRequestBody defines model for InsertManyRequestBody.

type InsertManyResponseBody

type InsertManyResponseBody struct {
	// InsertedIds A list of the `_id` values of the inserted documents.
	InsertedIds *[]any `json:"insertedIds,omitempty"`
}

InsertManyResponseBody The result of an insertMany operation.

type InsertOneJSONBody

type InsertOneJSONBody = InsertOneRequestBody

InsertOneJSONBody defines parameters for InsertOne.

type InsertOneJSONRequestBody

type InsertOneJSONRequestBody = InsertOneJSONBody

InsertOneJSONRequestBody defines body for InsertOne for application/json ContentType.

type InsertOneRequestBody

type InsertOneRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Document A document to insert into the collection.
	Document json.RawMessage `json:"document"`
}

InsertOneRequestBody defines model for InsertOneRequestBody.

type InsertOneResponseBody

type InsertOneResponseBody struct {
	// InsertedId The `_id` value of the inserted document.
	InsertedId *any `json:"insertedId,omitempty"`
}

InsertOneResponseBody The result of an insertOne operation.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type Limit

type Limit struct {
	// Limit The maximum number of matching documents to include the in the response.
	Limit *float32 `json:"limit,omitempty"`
}

Limit defines model for Limit.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Namespace

type Namespace struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`
}

Namespace defines model for Namespace.

type Projection

type Projection struct {
	// Projection A [MongoDB projection](https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/) for matched documents returned by the operation.
	Projection *json.RawMessage `json:"projection,omitempty"`
}

Projection defines model for Projection.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type Response

type Response interface {
	// contains filtered or unexported methods
}

Response types are used to represent the responses from the API.

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface

type ServerInterface interface {
	// Aggregate Documents
	// (POST /action/aggregate)
	Aggregate(w http.ResponseWriter, r *http.Request)
	// Delete Documents
	// (POST /action/deleteMany)
	DeleteMany(w http.ResponseWriter, r *http.Request)
	// Delete One Document
	// (POST /action/deleteOne)
	DeleteOne(w http.ResponseWriter, r *http.Request)
	// Find Documents
	// (POST /action/find)
	Find(w http.ResponseWriter, r *http.Request)
	// Find One Document
	// (POST /action/findOne)
	FindOne(w http.ResponseWriter, r *http.Request)
	// Insert Documents
	// (POST /action/insertMany)
	InsertMany(w http.ResponseWriter, r *http.Request)
	// Insert One Document
	// (POST /action/insertOne)
	InsertOne(w http.ResponseWriter, r *http.Request)
	// Update Documents
	// (POST /action/updateMany)
	UpdateMany(w http.ResponseWriter, r *http.Request)
	// Update One Document
	// (POST /action/updateOne)
	UpdateOne(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Aggregate

func (siw *ServerInterfaceWrapper) Aggregate(w http.ResponseWriter, r *http.Request)

Aggregate operation middleware

func (*ServerInterfaceWrapper) DeleteMany

func (siw *ServerInterfaceWrapper) DeleteMany(w http.ResponseWriter, r *http.Request)

DeleteMany operation middleware

func (*ServerInterfaceWrapper) DeleteOne

func (siw *ServerInterfaceWrapper) DeleteOne(w http.ResponseWriter, r *http.Request)

DeleteOne operation middleware

func (*ServerInterfaceWrapper) Find

Find operation middleware

func (*ServerInterfaceWrapper) FindOne

FindOne operation middleware

func (*ServerInterfaceWrapper) InsertMany

func (siw *ServerInterfaceWrapper) InsertMany(w http.ResponseWriter, r *http.Request)

InsertMany operation middleware

func (*ServerInterfaceWrapper) InsertOne

func (siw *ServerInterfaceWrapper) InsertOne(w http.ResponseWriter, r *http.Request)

InsertOne operation middleware

func (*ServerInterfaceWrapper) UpdateMany

func (siw *ServerInterfaceWrapper) UpdateMany(w http.ResponseWriter, r *http.Request)

UpdateMany operation middleware

func (*ServerInterfaceWrapper) UpdateOne

func (siw *ServerInterfaceWrapper) UpdateOne(w http.ResponseWriter, r *http.Request)

UpdateOne operation middleware

type Skip

type Skip struct {
	// Skip The number of matching documents to omit from the response.
	Skip *float32 `json:"skip,omitempty"`
}

Skip defines model for Skip.

type Sort

type Sort struct {
	// Sort A [MongoDB sort expression](https://www.mongodb.com/docs/manual/reference/method/cursor.sort/) that indicates sorted field names and directions.
	Sort *json.RawMessage `json:"sort,omitempty"`
}

Sort defines model for Sort.

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnauthorizedRequestError

type UnauthorizedRequestError = ErrorUserNotFound

UnauthorizedRequestError Indicates that no user matched the provided authentication credentials.

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateManyJSONBody

type UpdateManyJSONBody = UpdateRequestBody

UpdateManyJSONBody defines parameters for UpdateMany.

type UpdateManyJSONRequestBody

type UpdateManyJSONRequestBody = UpdateManyJSONBody

UpdateManyJSONRequestBody defines body for UpdateMany for application/json ContentType.

type UpdateOneJSONBody

type UpdateOneJSONBody = UpdateRequestBody

UpdateOneJSONBody defines parameters for UpdateOne.

type UpdateOneJSONRequestBody

type UpdateOneJSONRequestBody = UpdateOneJSONBody

UpdateOneJSONRequestBody defines body for UpdateOne for application/json ContentType.

type UpdateRequestBody

type UpdateRequestBody struct {
	// Collection The name of a collection in the specified database.
	Collection string `json:"collection"`

	// DataSource The name of a linked MongoDB Atlas data source. This is
	// commonly `"mongodb-atlas"` though it may be different in
	// your App if you chose a different name when you created the
	// data source.
	DataSource string `json:"dataSource"`

	// Database The name of a database in the specified data source.
	Database string `json:"database"`

	// Filter A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
	Filter json.RawMessage `json:"filter"`

	// Update A MongoDB update expression to apply to matching documents. For a list of all update operators that the Data API supports, see [Update Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#update-operators).
	Update json.RawMessage `json:"update"`

	// Upsert When `true`, if the update filter does not match any
	// existing documents, then insert a new document based on
	// the filter and the specified update operation.
	Upsert *bool `json:"upsert,omitempty"`
}

UpdateRequestBody defines model for UpdateRequestBody.

type UpdateResponseBody

type UpdateResponseBody struct {
	// MatchedCount The number of documents matched by the query filter.
	MatchedCount interface{} `json:"matchedCount"`

	// ModifiedCount The number of matched documents that were modified.
	ModifiedCount interface{} `json:"modifiedCount"`

	// UpsertedId The `_id` value of the upserted document.
	UpsertedId *string `json:"upsertedId,omitempty"`
}

UpdateResponseBody defines model for UpdateResponseBody.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL