|
34 | 34 | // APIClient manages communication with the MongoDB Atlas Administration API API
|
35 | 35 | // In most cases there should be only one, shared, APIClient.
|
36 | 36 | type APIClient struct {
|
37 |
| - cfg *Configuration |
38 |
| - common service // Reuse a single struct instead of allocating one for each service on the heap. |
| 37 | + cfg *Configuration |
| 38 | + common service // Reuse a single struct instead of allocating one for each service on the heap. |
| 39 | + UntypedClient UntypedClient // Make API calls without using a typed model. |
39 | 40 |
|
40 | 41 | // API Services
|
41 | 42 |
|
@@ -154,6 +155,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
|
154 | 155 | c := &APIClient{}
|
155 | 156 | c.cfg = cfg
|
156 | 157 | c.common.client = c
|
| 158 | + c.UntypedClient.client = c |
157 | 159 |
|
158 | 160 | // API Services
|
159 | 161 | c.AWSClustersDNSApi = (*AWSClustersDNSApiService)(&c.common)
|
@@ -356,7 +358,8 @@ type formFile struct {
|
356 | 358 | // prepareRequest build the request
|
357 | 359 | func (c *APIClient) prepareRequest(
|
358 | 360 | ctx context.Context,
|
359 |
| - path string, method string, |
| 361 | + path string, |
| 362 | + method string, |
360 | 363 | postBody any,
|
361 | 364 | headerParams map[string]string,
|
362 | 365 | queryParams url.Values,
|
@@ -689,3 +692,27 @@ func FormatErrorMessageWithDetails(status, path, method string, v ApiError) stri
|
689 | 692 | method, path, status, v.GetErrorCode(),
|
690 | 693 | v.GetDetail(), v.GetReason(), v.GetParameters(), badRequestDetailString)
|
691 | 694 | }
|
| 695 | + |
| 696 | +type UntypedClient struct { |
| 697 | + client *APIClient |
| 698 | +} |
| 699 | + |
| 700 | +func (u *UntypedClient) PrepareRequest( |
| 701 | + ctx context.Context, |
| 702 | + path string, |
| 703 | + method string, |
| 704 | + postBody any, |
| 705 | + headerParams map[string]string, |
| 706 | + queryParams url.Values, |
| 707 | + formParams url.Values, |
| 708 | + formFiles []formFile) (localVarRequest *http.Request, err error) { |
| 709 | + return u.client.prepareRequest(ctx, path, method, postBody, headerParams, queryParams, formParams, formFiles) |
| 710 | +} |
| 711 | + |
| 712 | +func (u *UntypedClient) CallAPI(request *http.Request) (*http.Response, error) { |
| 713 | + return u.client.callAPI(request) |
| 714 | +} |
| 715 | + |
| 716 | +func (u *UntypedClient) MakeApiError(res *http.Response, httpMethod, httpPath string) error { |
| 717 | + return u.client.makeApiError(res, httpMethod, httpPath) |
| 718 | +} |
0 commit comments