@@ -21,7 +21,8 @@ import (
2121)
2222
2323const (
24- dataFederationBasePath = "api/atlas/v1.0/groups/%s/dataFederation"
24+ dataFederationBasePath = "api/atlas/v1.0/groups/%s/dataFederation"
25+ dataFederationQueryLimitBasePath = "api/atlas/v1.0/groups/%s/dataFederation/%s/limits"
2526)
2627
2728// DataFederationService is an interface for interfacing with the Data Federation endpoints of the MongoDB Atlas API.
@@ -33,6 +34,10 @@ type DataFederationService interface {
3334 Create (context.Context , string , * DataFederationInstance ) (* DataFederationInstance , * Response , error )
3435 Update (context.Context , string , string , * DataFederationInstance , * DataFederationUpdateOptions ) (* DataFederationInstance , * Response , error )
3536 Delete (context.Context , string , string ) (* Response , error )
37+ ListQueryLimits (context.Context , string , string ) ([]* DataFederationQueryLimit , * Response , error )
38+ GetQueryLimit (context.Context , string , string , string ) (* DataFederationQueryLimit , * Response , error )
39+ ConfigureQueryLimit (context.Context , string , string , string , * DataFederationQueryLimit ) (* DataFederationQueryLimit , * Response , error )
40+ DeleteQueryLimit (context.Context , string , string , string ) (* Response , error )
3641}
3742
3843// DataFederationServiceOp handles communication with the DataFederationService related methods of the
@@ -133,6 +138,18 @@ type DataFederationUpdateOptions struct {
133138 SkipRoleValidation bool `url:"skipRoleValidation"`
134139}
135140
141+ // DataFederationQueryLimit Details of a tenant-level query limit for Data Federation.
142+ type DataFederationQueryLimit struct {
143+ CurrentUsage int64 `json:"currentUsage,omitempty"`
144+ DefaultLimit int64 `json:"defaultLimit,omitempty"`
145+ LastModifiedDate string `json:"lastModifiedDate,omitempty"`
146+ MaximumLimit int64 `json:"maximumLimit,omitempty"`
147+ Name string `json:"name,omitempty"`
148+ OverrunPolicy string `json:"overrunPolicy,omitempty"`
149+ TenantName string `json:"tenantName,omitempty"`
150+ Value int64 `json:"value,omitempty"`
151+ }
152+
136153// List gets the details of all federated database instances in the specified project.
137154//
138155// See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Data-Federation/operation/listFederatedDatabases
@@ -276,3 +293,112 @@ func (s *DataFederationServiceOp) Delete(ctx context.Context, groupID, name stri
276293
277294 return resp , err
278295}
296+
297+ // ConfigureQueryLimit Creates or updates one query limit for one federated database instance.
298+ //
299+ // See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Data-Federation/operation/createOneDataFederationQueryLimit
300+ func (s * DataFederationServiceOp ) ConfigureQueryLimit (ctx context.Context , groupID , name , limitName string , queryLimit * DataFederationQueryLimit ) (* DataFederationQueryLimit , * Response , error ) {
301+ if groupID == "" {
302+ return nil , nil , NewArgError ("groupID" , "must be set" )
303+ }
304+ if name == "" {
305+ return nil , nil , NewArgError ("name" , "must be set" )
306+ }
307+ if limitName == "" {
308+ return nil , nil , NewArgError ("limitName" , "must be set" )
309+ }
310+ if queryLimit == nil {
311+ return nil , nil , NewArgError ("queryLimit" , "must be set" )
312+ }
313+
314+ basePath := fmt .Sprintf (dataFederationQueryLimitBasePath , groupID , name )
315+ path := fmt .Sprintf ("%s/%s" , basePath , limitName )
316+ req , err := s .Client .NewRequest (ctx , http .MethodPatch , path , queryLimit )
317+ if err != nil {
318+ return nil , nil , err
319+ }
320+
321+ root := new (DataFederationQueryLimit )
322+ resp , err := s .Client .Do (ctx , req , & root )
323+ if err != nil {
324+ return nil , resp , err
325+ }
326+
327+ return root , resp , err
328+ }
329+
330+ func (s * DataFederationServiceOp ) DeleteQueryLimit (ctx context.Context , groupID , name , limitName string ) (* Response , error ) {
331+ if groupID == "" {
332+ return nil , NewArgError ("groupId" , "must be set" )
333+ }
334+ if name == "" {
335+ return nil , NewArgError ("name" , "must be set" )
336+ }
337+ if limitName == "" {
338+ return nil , NewArgError ("limitName" , "must be set" )
339+ }
340+
341+ basePath := fmt .Sprintf (dataFederationQueryLimitBasePath , groupID , name )
342+ path := fmt .Sprintf ("%s/%s" , basePath , limitName )
343+
344+ req , err := s .Client .NewRequest (ctx , http .MethodDelete , path , nil )
345+ if err != nil {
346+ return nil , err
347+ }
348+
349+ resp , err := s .Client .Do (ctx , req , nil )
350+
351+ return resp , err
352+ }
353+
354+ func (s * DataFederationServiceOp ) GetQueryLimit (ctx context.Context , groupID , name , limitName string ) (* DataFederationQueryLimit , * Response , error ) {
355+ if groupID == "" {
356+ return nil , nil , NewArgError ("groupID" , "must be set" )
357+ }
358+ if name == "" {
359+ return nil , nil , NewArgError ("name" , "must be set" )
360+ }
361+ if limitName == "" {
362+ return nil , nil , NewArgError ("limitName" , "must be set" )
363+ }
364+
365+ basePath := fmt .Sprintf (dataFederationQueryLimitBasePath , groupID , name )
366+ path := fmt .Sprintf ("%s/%s" , basePath , limitName )
367+
368+ req , err := s .Client .NewRequest (ctx , http .MethodGet , path , nil )
369+ if err != nil {
370+ return nil , nil , err
371+ }
372+
373+ root := new (DataFederationQueryLimit )
374+ resp , err := s .Client .Do (ctx , req , & root )
375+ if err != nil {
376+ return nil , resp , err
377+ }
378+
379+ return root , resp , err
380+ }
381+
382+ func (s * DataFederationServiceOp ) ListQueryLimits (ctx context.Context , groupID , name string ) ([]* DataFederationQueryLimit , * Response , error ) {
383+ if groupID == "" {
384+ return nil , nil , NewArgError ("groupID" , "must be set" )
385+ }
386+ if name == "" {
387+ return nil , nil , NewArgError ("name" , "must be set" )
388+ }
389+
390+ path := fmt .Sprintf (dataFederationQueryLimitBasePath , groupID , name )
391+
392+ req , err := s .Client .NewRequest (ctx , http .MethodGet , path , nil )
393+ if err != nil {
394+ return nil , nil , err
395+ }
396+
397+ var root []* DataFederationQueryLimit
398+ resp , err := s .Client .Do (ctx , req , & root )
399+ if err != nil {
400+ return nil , resp , err
401+ }
402+
403+ return root , resp , err
404+ }
0 commit comments