Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for API management ListAPIs #2521

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:14.704458",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:46.979190",
"spec_repo_commit": "71f2f0da"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:14.722159",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:46.996318",
"spec_repo_commit": "71f2f0da"
}
}
}
103 changes: 103 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10554,6 +10554,52 @@ components:
description: Jira project key
type: string
type: object
ListAPIsResponse:
description: Response for `ListAPIs`.
properties:
data:
description: List of API items.
items:
$ref: '#/components/schemas/ListAPIsResponseData'
type: array
meta:
$ref: '#/components/schemas/ListAPIsResponseMeta'
type: object
ListAPIsResponseData:
description: Data envelope for `ListAPIsResponse`.
properties:
id:
$ref: '#/components/schemas/ApiID'
name:
description: API name.
example: Payments API
type: string
type: object
ListAPIsResponseMeta:
description: Metadata for `ListAPIsResponse`.
properties:
pagination:
$ref: '#/components/schemas/ListAPIsResponseMetaPagination'
type: object
ListAPIsResponseMetaPagination:
description: Pagination metadata information for `ListAPIsResponse`.
properties:
limit:
description: Number of items in the current page.
example: 20
format: int64
type: integer
offset:
description: Offset for pagination.
example: 0
format: int64
type: integer
total_count:
description: Total number of items.
example: 35
format: int64
type: integer
type: object
ListApplicationKeysResponse:
description: Response for a list of application keys.
properties:
Expand Down Expand Up @@ -23350,6 +23396,63 @@ paths:
tags:
- Key Management
x-codegen-request-body-name: body
/api/v2/apicatalog/api:
get:
description: List APIs and their IDs.
operationId: ListAPIs
parameters:
- description: Filter APIs by name
in: query
name: query
required: false
schema:
example: payments
type: string
- description: Number of items per page.
in: query
name: page[limit]
required: false
schema:
default: 20
format: int64
minimum: 1
type: integer
- description: Offset for pagination.
in: query
name: page[offset]
required: false
schema:
default: 0
format: int64
minimum: 0
type: integer
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ListAPIsResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Forbidden
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: List APIs
tags:
- API Management
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/apicatalog/api/{id}:
delete:
description: Delete a specific API by ID.
Expand Down
1 change: 1 addition & 0 deletions api/datadog/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func NewConfiguration() *Configuration {
"v2.CreateOpenAPI": false,
"v2.DeleteOpenAPI": false,
"v2.GetOpenAPI": false,
"v2.ListAPIs": false,
"v2.UpdateOpenAPI": false,
"v2.GetActiveBillingDimensions": false,
"v2.GetMonthlyCostAttribution": false,
Expand Down
134 changes: 134 additions & 0 deletions api/datadogV2/api_api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,140 @@ func (a *APIManagementApi) GetOpenAPI(ctx _context.Context, id uuid.UUID) (_io.R
return localVarReturnValue, localVarHTTPResponse, nil
}

// ListAPIsOptionalParameters holds optional parameters for ListAPIs.
type ListAPIsOptionalParameters struct {
Query *string
PageLimit *int64
PageOffset *int64
}

// NewListAPIsOptionalParameters creates an empty struct for parameters.
func NewListAPIsOptionalParameters() *ListAPIsOptionalParameters {
this := ListAPIsOptionalParameters{}
return &this
}

// WithQuery sets the corresponding parameter name and returns the struct.
func (r *ListAPIsOptionalParameters) WithQuery(query string) *ListAPIsOptionalParameters {
r.Query = &query
return r
}

// WithPageLimit sets the corresponding parameter name and returns the struct.
func (r *ListAPIsOptionalParameters) WithPageLimit(pageLimit int64) *ListAPIsOptionalParameters {
r.PageLimit = &pageLimit
return r
}

// WithPageOffset sets the corresponding parameter name and returns the struct.
func (r *ListAPIsOptionalParameters) WithPageOffset(pageOffset int64) *ListAPIsOptionalParameters {
r.PageOffset = &pageOffset
return r
}

// ListAPIs List APIs.
// List APIs and their IDs.
func (a *APIManagementApi) ListAPIs(ctx _context.Context, o ...ListAPIsOptionalParameters) (ListAPIsResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarReturnValue ListAPIsResponse
optionalParams ListAPIsOptionalParameters
)

if len(o) > 1 {
return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListAPIsOptionalParameters is allowed")
}
if len(o) == 1 {
optionalParams = o[0]
}

operationId := "v2.ListAPIs"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.ListAPIs")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/apicatalog/api"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if optionalParams.Query != nil {
localVarQueryParams.Add("query", datadog.ParameterToString(*optionalParams.Query, ""))
}
if optionalParams.PageLimit != nil {
localVarQueryParams.Add("page[limit]", datadog.ParameterToString(*optionalParams.PageLimit, ""))
}
if optionalParams.PageOffset != nil {
localVarQueryParams.Add("page[offset]", datadog.ParameterToString(*optionalParams.PageOffset, ""))
}
localVarHeaderParams["Accept"] = "application/json"

datadog.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"apiKeyAuth", "DD-API-KEY"},
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 {
var v JSONAPIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 429 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

// UpdateOpenAPIOptionalParameters holds optional parameters for UpdateOpenAPI.
type UpdateOpenAPIOptionalParameters struct {
OpenapiSpecFile *_io.Reader
Expand Down
1 change: 1 addition & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// - [APIManagementApi.CreateOpenAPI]
// - [APIManagementApi.DeleteOpenAPI]
// - [APIManagementApi.GetOpenAPI]
// - [APIManagementApi.ListAPIs]
// - [APIManagementApi.UpdateOpenAPI]
// - [APMRetentionFiltersApi.CreateApmRetentionFilter]
// - [APMRetentionFiltersApi.DeleteApmRetentionFilter]
Expand Down
Loading
Loading