Skip to content
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
31 changes: 31 additions & 0 deletions packages_generated/cockpit/src/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
unmarshalListGrafanaProductDashboardsResponse,
unmarshalListGrafanaUsersResponse,
unmarshalListPlansResponse,
unmarshalListProductsResponse,
unmarshalListTokensResponse,
unmarshalPlan,
unmarshalToken,
Expand Down Expand Up @@ -73,6 +74,7 @@ import type {
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
ListPlansResponse,
ListProductsResponse,
ListTokensResponse,
Plan,
RegionalApiCreateContactPointRequest,
Expand All @@ -94,6 +96,7 @@ import type {
RegionalApiListAlertsRequest,
RegionalApiListContactPointsRequest,
RegionalApiListDataSourcesRequest,
RegionalApiListProductsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
Expand Down Expand Up @@ -627,6 +630,34 @@ You can filter tokens by Project ID and token scopes.
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam('tokenId', request.tokenId)}`,
})

protected pageOfListProducts = (
request: Readonly<RegionalApiListProductsRequest> = {},
) =>
this.client.fetch<ListProductsResponse>(
{
method: 'GET',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/products`,
urlParams: urlParams(
['order_by', request.orderBy],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListProductsResponse,
)

/**
* List all Scaleway products that send metrics and/or logs to Cockpit.. List all Scaleway products that send metrics and/or logs to Cockpit.
*
* @param request - The request {@link RegionalApiListProductsRequest}
* @returns A Promise of ListProductsResponse
*/
listProducts = (request: Readonly<RegionalApiListProductsRequest> = {}) =>
enrichForPagination('productsList', this.pageOfListProducts, request)

/**
* Get the Alert manager. Retrieve information about the Alert manager which is unique per Project and region. By default the Alert manager is disabled.
The output returned displays a URL to access the Alert manager, and whether the Alert manager and managed alerts are enabled.
Expand Down
4 changes: 4 additions & 0 deletions packages_generated/cockpit/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export type {
ListGrafanaUsersResponse,
ListPlansRequestOrderBy,
ListPlansResponse,
ListProductsRequestOrderBy,
ListProductsResponse,
ListTokensRequestOrderBy,
ListTokensResponse,
Plan,
PlanName,
PreconfiguredAlertData,
Product,
RegionalApiCreateContactPointRequest,
RegionalApiCreateDataSourceRequest,
RegionalApiCreateTokenRequest,
Expand All @@ -68,6 +71,7 @@ export type {
RegionalApiListAlertsRequest,
RegionalApiListContactPointsRequest,
RegionalApiListDataSourcesRequest,
RegionalApiListProductsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
Expand Down
32 changes: 32 additions & 0 deletions packages_generated/cockpit/src/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import type {
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
ListPlansResponse,
ListProductsResponse,
ListTokensResponse,
Plan,
PreconfiguredAlertData,
Product,
RegionalApiCreateContactPointRequest,
RegionalApiCreateDataSourceRequest,
RegionalApiCreateTokenRequest,
Expand Down Expand Up @@ -444,6 +446,36 @@ export const unmarshalListPlansResponse = (
} as ListPlansResponse
}

const unmarshalProduct = (data: unknown): Product => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Product' failed as data isn't a dictionary.`,
)
}

return {
displayName: data.display_name,
familyName: data.family_name,
name: data.name,
resourceTypes: data.resource_types,
} as Product
}

export const unmarshalListProductsResponse = (
data: unknown,
): ListProductsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListProductsResponse' failed as data isn't a dictionary.`,
)
}

return {
productsList: unmarshalArrayOfObject(data.products_list, unmarshalProduct),
totalCount: data.total_count,
} as ListProductsResponse
}

export const unmarshalListTokensResponse = (
data: unknown,
): ListTokensResponse => {
Expand Down
42 changes: 42 additions & 0 deletions packages_generated/cockpit/src/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export type ListGrafanaUsersRequestOrderBy = 'login_asc' | 'login_desc'

export type ListPlansRequestOrderBy = 'name_asc' | 'name_desc'

export type ListProductsRequestOrderBy =
| 'created_at_asc'
| 'created_at_desc'
| 'display_name_asc'
| 'display_name_desc'
| 'family_name_asc'
| 'family_name_desc'

export type ListTokensRequestOrderBy =
| 'created_at_asc'
| 'created_at_desc'
Expand Down Expand Up @@ -308,6 +316,13 @@ export interface Plan {
monthlyPrice: number
}

export interface Product {
name: string
displayName: string
familyName: string
resourceTypes: string[]
}

/**
* Token.
*/
Expand Down Expand Up @@ -732,6 +747,11 @@ export interface ListPlansResponse {
plans: Plan[]
}

export interface ListProductsResponse {
productsList: Product[]
totalCount: number
}

/**
* Response returned when listing tokens.
*/
Expand Down Expand Up @@ -1082,6 +1102,28 @@ export type RegionalApiListDataSourcesRequest = {
types?: DataSourceType[]
}

/**
* List all Scaleway products that send metrics and/or logs to Cockpit.
*/
export type RegionalApiListProductsRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* Page number to return from the paginated results.
*/
page?: number
/**
* Number of products to return per page.
*/
pageSize?: number
/**
* Sort order for products in the response.
*/
orderBy?: ListProductsRequestOrderBy
}

/**
* List tokens.
*/
Expand Down
11 changes: 11 additions & 0 deletions packages_generated/cockpit/src/v1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export const RegionalApiListDataSourcesRequest = {
},
}

export const RegionalApiListProductsRequest = {
page: {
greaterThanOrEqual: 1,
lessThanOrEqual: 10000,
},
pageSize: {
greaterThanOrEqual: 1,
lessThanOrEqual: 100,
},
}

export const RegionalApiListTokensRequest = {
page: {
greaterThanOrEqual: 1,
Expand Down
Loading