diff --git a/packages/grafana-alerting/scripts/README.md b/packages/grafana-alerting/scripts/README.md index c27d22246a8..32730a22a13 100644 --- a/packages/grafana-alerting/scripts/README.md +++ b/packages/grafana-alerting/scripts/README.md @@ -1,4 +1,23 @@ -These files are built using the `yarn run codegen` command. +# Re-generate the clients + +⚠️ This guide assumes the Backend definitions have been updated in `apps/alerting`. + +## Re-create OpenAPI specification + +Start with re-generating the OpenAPI snapshots by running the test in `pkg/tests/apis/openapi_test.go`. + +This will output the OpenAPI JSON spec file(s) in `pkg/tests/apis/openapi_snapshots`. + +## Process OpenAPI specifications + +Next up run the post-processing of the snapshots with `yarn run process-specs`, this will copy processed specifications to `./data/openapi/`. + +## Generate RTKQ files + +These files are built using the `yarn run codegen` command, make sure to run that in the Grafana Alerting package working directory. + +`yarn --cwd ./packages/grafana-alerting run codegen`. + API clients will be written to `src/grafana/api//api.gen.ts`. Make sure to create a versioned API client for each API version – see `src/grafana/api/v0alpha1/api.ts` as an example. diff --git a/packages/grafana-alerting/scripts/codegen.ts b/packages/grafana-alerting/scripts/codegen.ts index 53ec8976a85..59c9a7e5cb8 100644 --- a/packages/grafana-alerting/scripts/codegen.ts +++ b/packages/grafana-alerting/scripts/codegen.ts @@ -7,35 +7,42 @@ */ import type { ConfigFile } from '@rtk-query/codegen-openapi'; -// ℹ️ append versions here to generate additional API clients -const VERSIONS = ['v0alpha1'] as const; -const GROUP = 'notifications.alerting.grafana.app' as const; +// ℹ️ append API groups and versions here to generate additional API clients +const SPECS = [ + ['notifications.alerting.grafana.app', ['v0alpha1']], + ['rules.alerting.grafana.app', ['v0alpha1']], + // keep this in Grafana Enterprise + // ['alertenrichment.grafana.app', ['v1beta1']], +] as const; type OutputFile = Omit; type OutputFiles = Record; -const outputFiles = VERSIONS.reduce((acc, version) => { - // we append the version here so we export versioned API clients from this package without having to re-export with an alias - const exportName = 'alertingAPI'; +const outputFiles = SPECS.reduce((groupAcc, [group, versions]) => { + return versions.reduce((versionAcc, version) => { + // Create a unique export name based on the group + const groupName = group.split('.')[0]; // e.g., 'notifications', 'rules', 'alertenrichment' + const exportName = `${groupName}API`; - // ℹ️ these snapshots are generated by running "go test pkg/tests/apis/openapi_test.go" and "scripts/process-specs.ts", - // see the README in the "openapi_snapshots" directory - const schemaFile = `../../../data/openapi/${GROUP}-${version}.json`; + // ℹ️ these snapshots are generated by running "go test pkg/tests/apis/openapi_test.go" and "scripts/process-specs.ts", + // see the README in the "openapi_snapshots" directory + const schemaFile = `../../../data/openapi/${group}-${version}.json`; - // ℹ️ make sure there is a API file in each versioned directory - const apiFile = `../src/grafana/api/${version}/api.ts`; + // ℹ️ make sure there is a API file in each versioned directory + const apiFile = `../src/grafana/api/${groupName}/${version}/api.ts`; - // output each api client into a versioned directory - const outputPath = `../src/grafana/api/${version}/api.gen.ts`; + // output each api client into a versioned directory with group-specific naming + const outputPath = `../src/grafana/api/${groupName}/${version}/${groupName}.api.gen.ts`; - acc[outputPath] = { - exportName, - schemaFile, - apiFile, - tag: true, // generate tags for cache invalidation - } satisfies OutputFile; + versionAcc[outputPath] = { + exportName, + schemaFile, + apiFile, + tag: true, // generate tags for cache invalidation + } satisfies OutputFile; - return acc; + return versionAcc; + }, groupAcc); }, {}); export default { diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/api.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/api.ts similarity index 89% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/api.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/api.ts index 6d22d1df2c2..5b45157954f 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/api.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/api.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { getAPIBaseURL, getAPIReducerPath } from '../util'; +import { getAPIBaseURL, getAPIReducerPath } from '../../util'; import { GROUP, VERSION } from './const'; diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/const.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/const.ts similarity index 100% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/const.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/const.ts diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Receivers.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Receivers.ts similarity index 93% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Receivers.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Receivers.ts index 9bc5189e964..fbd88a5972d 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Receivers.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Receivers.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; import { Factory } from 'fishery'; -import { DEFAULT_NAMESPACE, generateResourceVersion, generateTitle, generateUID } from '../../../../mocks/util'; +import { DEFAULT_NAMESPACE, generateResourceVersion, generateTitle, generateUID } from '../../../../../mocks/util'; import { GROUP, VERSION } from '../../const'; import { ContactPoint, @@ -47,16 +47,17 @@ export const ContactPointSpecFactory = Factory.define(() = export const GenericIntegrationFactory = Factory.define(() => ({ type: 'generic', + version: '1', disableResolveMessage: false, settings: { foo: 'bar', }, - version: 'v1', })); export const EmailIntegrationFactory = Factory.define(() => ({ type: 'email', - version: 'v1', + version: '1', + secureFields: {}, settings: { addresses: faker.internet.email(), }, @@ -64,7 +65,8 @@ export const EmailIntegrationFactory = Factory.define(() => ({ export const SlackIntegrationFactory = Factory.define(() => ({ type: 'slack', - version: 'v1', + version: '1', + secureFields: { token: true }, settings: { mentionChannel: '#alerts', }, diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Routes.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Routes.ts similarity index 91% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Routes.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Routes.ts index ba9a1b4b8f0..66a6ea1ffce 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/Routes.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/Routes.ts @@ -1,8 +1,8 @@ import { faker } from '@faker-js/faker'; import { Factory } from 'fishery'; -import { LabelMatcher } from '../../../../matchers/types'; -import { Route } from '../../../../notificationPolicies/types'; +import { LabelMatcher } from '../../../../../matchers/types'; +import { Route } from '../../../../../notificationPolicies/types'; export const LabelMatcherFactory = Factory.define(() => { const operators: Array = ['=', '!=', '=~', '!~']; diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/common.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/common.ts similarity index 100% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/fakes/common.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/fakes/common.ts diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts similarity index 74% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts index 6ca0ba803c4..2c21893b6d3 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/createReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { CreateReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { CreateReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function createReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts similarity index 74% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts index 13d47dda277..d3ff5c660f8 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deleteReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { DeleteReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { DeleteReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function deleteReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts similarity index 73% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts index 8d1141df76f..f3871112e66 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/deletecollectionReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { DeletecollectionReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { DeletecollectionReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function deletecollectionReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts similarity index 74% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts index bc82c667dd0..d90d1fbecba 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/getReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { GetReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { GetReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function getReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/index.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/index.ts similarity index 100% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/index.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/index.ts diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts similarity index 88% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts index 6040ffe4d8a..fde49565388 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler.ts @@ -1,6 +1,6 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; import { GROUP, VERSION } from '../../../const'; import { EnhancedListReceiverApiResponse } from '../../../types'; diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts similarity index 74% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts index 85ab132925e..c054de71882 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/replaceReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { ReplaceReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { ReplaceReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function replaceReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts similarity index 74% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts index 645a8774364..ce8498331cd 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/updateReceiverHandler.ts @@ -1,7 +1,7 @@ import { HttpResponse, http } from 'msw'; -import { getAPIBaseURLForMocks } from '../../../../../mocks/util'; -import { UpdateReceiverApiResponse } from '../../../api.gen'; +import { getAPIBaseURLForMocks } from '../../../../../../mocks/util'; +import { UpdateReceiverApiResponse } from '../../../../v0alpha1/notifications.api.gen'; import { GROUP, VERSION } from '../../../const'; export function updateReceiverHandler( diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/index.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/index.ts similarity index 100% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/mocks/handlers/index.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/mocks/handlers/index.ts diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/api.gen.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/notifications.api.gen.ts similarity index 99% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/api.gen.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/notifications.api.gen.ts index d36b068dccb..66b145753a6 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/api.gen.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/notifications.api.gen.ts @@ -613,7 +613,7 @@ const injectedRtkApi = api }), overrideExisting: false, }); -export { injectedRtkApi as alertingAPI }; +export { injectedRtkApi as notificationsAPI }; export type GetApiResourcesApiResponse = /** status 200 OK */ ApiResourceList; export type GetApiResourcesApiArg = void; export type ListReceiverApiResponse = /** status 200 OK */ ReceiverList; @@ -623,7 +623,7 @@ export type ListReceiverApiArg = { /** allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. */ allowWatchBookmarks?: boolean; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** A selector to restrict the list of returned objects by their fields. Defaults to everything. */ @@ -631,19 +631,19 @@ export type ListReceiverApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -653,7 +653,7 @@ export type ListReceiverApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -681,7 +681,7 @@ export type DeletecollectionReceiverApiArg = { /** If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget). */ pretty?: string; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed */ @@ -695,7 +695,7 @@ export type DeletecollectionReceiverApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. */ @@ -703,15 +703,15 @@ export type DeletecollectionReceiverApiArg = { /** Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. */ propagationPolicy?: string; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -721,7 +721,7 @@ export type DeletecollectionReceiverApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -825,7 +825,7 @@ export type ListRoutingTreeApiArg = { /** allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. */ allowWatchBookmarks?: boolean; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** A selector to restrict the list of returned objects by their fields. Defaults to everything. */ @@ -833,19 +833,19 @@ export type ListRoutingTreeApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -855,7 +855,7 @@ export type ListRoutingTreeApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -883,7 +883,7 @@ export type DeletecollectionRoutingTreeApiArg = { /** If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget). */ pretty?: string; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed */ @@ -897,7 +897,7 @@ export type DeletecollectionRoutingTreeApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. */ @@ -905,15 +905,15 @@ export type DeletecollectionRoutingTreeApiArg = { /** Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. */ propagationPolicy?: string; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -923,7 +923,7 @@ export type DeletecollectionRoutingTreeApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -1031,7 +1031,7 @@ export type ListTemplateGroupApiArg = { /** allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. */ allowWatchBookmarks?: boolean; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** A selector to restrict the list of returned objects by their fields. Defaults to everything. */ @@ -1039,19 +1039,19 @@ export type ListTemplateGroupApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -1061,7 +1061,7 @@ export type ListTemplateGroupApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -1089,7 +1089,7 @@ export type DeletecollectionTemplateGroupApiArg = { /** If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget). */ pretty?: string; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed */ @@ -1103,7 +1103,7 @@ export type DeletecollectionTemplateGroupApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. */ @@ -1111,15 +1111,15 @@ export type DeletecollectionTemplateGroupApiArg = { /** Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. */ propagationPolicy?: string; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -1129,7 +1129,7 @@ export type DeletecollectionTemplateGroupApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -1241,7 +1241,7 @@ export type ListTimeIntervalApiArg = { /** allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. */ allowWatchBookmarks?: boolean; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** A selector to restrict the list of returned objects by their fields. Defaults to everything. */ @@ -1249,19 +1249,19 @@ export type ListTimeIntervalApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -1271,7 +1271,7 @@ export type ListTimeIntervalApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -1299,7 +1299,7 @@ export type DeletecollectionTimeIntervalApiArg = { /** If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget). */ pretty?: string; /** The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". - + This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. */ continue?: string; /** When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed */ @@ -1313,7 +1313,7 @@ export type DeletecollectionTimeIntervalApiArg = { /** A selector to restrict the list of returned objects by their labels. Defaults to everything. */ labelSelector?: string; /** limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. - + The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. */ limit?: number; /** Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. */ @@ -1321,15 +1321,15 @@ export type DeletecollectionTimeIntervalApiArg = { /** Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. */ propagationPolicy?: string; /** resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersion?: string; /** resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. - + Defaults to unset */ resourceVersionMatch?: string; /** `sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic "Bookmark" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `"k8s.io/initial-events-end": "true"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched. - + When `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan is interpreted as "data at least as new as the provided `resourceVersion`" and the bookmark event is send when the state is synced @@ -1339,7 +1339,7 @@ export type DeletecollectionTimeIntervalApiArg = { when request started being processed. - `resourceVersionMatch` set to any other value or unset Invalid error is returned. - + Defaults to true if `resourceVersion=""` or `resourceVersion="0"` (for backward compatibility reasons) and to false otherwise. */ sendInitialEvents?: boolean; /** Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. */ @@ -1510,21 +1510,21 @@ export type ObjectMeta = { [key: string]: string; }; /** CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. - + Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */ creationTimestamp?: Time; /** Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only. */ deletionGracePeriodSeconds?: number; /** DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested. - + Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */ deletionTimestamp?: Time; /** Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list. */ finalizers?: string[]; /** GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server. - + If this field is specified and the generated name exists, the server will return a 409. - + Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency */ generateName?: string; /** A sequence number representing a specific generation of the desired state. Populated by the system. Read-only. */ @@ -1538,19 +1538,19 @@ export type ObjectMeta = { /** Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names */ name?: string; /** Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. - + Must be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces */ namespace?: string; /** List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller. */ ownerReferences?: OwnerReference[]; /** An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. - + Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency */ resourceVersion?: string; /** Deprecated: selfLink is a legacy read-only field that is no longer populated by the system. */ selfLink?: string; /** UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. - + Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids */ uid?: string; }; @@ -1602,7 +1602,7 @@ export type ReceiverStatus = { }; export type Receiver = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ - apiVersion?: string; + apiVersion: string; /** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ kind: string; metadata: ObjectMeta; @@ -1629,7 +1629,7 @@ export type ReceiverList = { }; export type StatusCause = { /** The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional. - + Examples: "name" - the field "name" on the current resource "items[0].name" - the field "name" on the first array entry in "items" */ @@ -1730,7 +1730,7 @@ export type RoutingTreeStatus = { }; export type RoutingTree = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ - apiVersion?: string; + apiVersion: string; /** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ kind: string; metadata: ObjectMeta; @@ -1779,7 +1779,7 @@ export type TemplateGroupStatus = { }; export type TemplateGroup = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ - apiVersion?: string; + apiVersion: string; /** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ kind: string; metadata: ObjectMeta; @@ -1840,7 +1840,7 @@ export type TimeIntervalStatus = { }; export type TimeInterval = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ - apiVersion?: string; + apiVersion: string; /** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ kind: string; metadata: ObjectMeta; diff --git a/packages/grafana-alerting/src/grafana/api/v0alpha1/types.ts b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/types.ts similarity index 98% rename from packages/grafana-alerting/src/grafana/api/v0alpha1/types.ts rename to packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/types.ts index f31b2d442ba..1212fc74b92 100644 --- a/packages/grafana-alerting/src/grafana/api/v0alpha1/types.ts +++ b/packages/grafana-alerting/src/grafana/api/notifications/v0alpha1/types.ts @@ -3,7 +3,7 @@ */ import { MergeDeep, MergeExclusive, OverrideProperties } from 'type-fest'; -import type { ListReceiverApiResponse, Receiver, ReceiverIntegration } from './api.gen'; +import type { ListReceiverApiResponse, Receiver, ReceiverIntegration } from './notifications.api.gen'; type GenericIntegration = OverrideProperties< ReceiverIntegration, diff --git a/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/api.ts b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/api.ts new file mode 100644 index 00000000000..5b45157954f --- /dev/null +++ b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/api.ts @@ -0,0 +1,18 @@ +import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; + +import { getAPIBaseURL, getAPIReducerPath } from '../../util'; + +import { GROUP, VERSION } from './const'; + +const baseUrl = getAPIBaseURL(GROUP, VERSION); +const reducerPath = getAPIReducerPath(GROUP, VERSION); + +export const api = createApi({ + reducerPath, + baseQuery: fetchBaseQuery({ + // Set URL correctly so MSW can intercept requests + // https://mswjs.io/docs/runbook#rtk-query-requests-are-not-intercepted + baseUrl: new URL(baseUrl, globalThis.location.origin).href, + }), + endpoints: () => ({}), +}); diff --git a/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/const.ts b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/const.ts new file mode 100644 index 00000000000..823560db3fb --- /dev/null +++ b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/const.ts @@ -0,0 +1,2 @@ +export const VERSION = 'v0alpha1' as const; +export const GROUP = 'rules.alerting.grafana.app' as const; diff --git a/public/app/api/clients/rules/v0alpha1/endpoints.gen.ts b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/rules.api.gen.ts similarity index 99% rename from public/app/api/clients/rules/v0alpha1/endpoints.gen.ts rename to packages/grafana-alerting/src/grafana/api/rules/v0alpha1/rules.api.gen.ts index 6537a5061fc..361362d5699 100644 --- a/public/app/api/clients/rules/v0alpha1/endpoints.gen.ts +++ b/packages/grafana-alerting/src/grafana/api/rules/v0alpha1/rules.api.gen.ts @@ -1,4 +1,4 @@ -import { api } from './baseAPI'; +import { api } from './api'; export const addTagTypes = ['API Discovery', 'AlertRule', 'RecordingRule'] as const; const injectedRtkApi = api .enhanceEndpoints({ @@ -313,7 +313,7 @@ const injectedRtkApi = api }), overrideExisting: false, }); -export { injectedRtkApi as generatedAPI }; +export { injectedRtkApi as rulesAPI }; export type GetApiResourcesApiResponse = /** status 200 OK */ ApiResourceList; export type GetApiResourcesApiArg = void; export type ListAlertRuleApiResponse = /** status 200 OK */ AlertRuleList; diff --git a/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario.ts b/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario.ts index 026a0cf7221..9812d5c5d28 100644 --- a/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario.ts +++ b/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario.ts @@ -5,8 +5,8 @@ import { EmailIntegrationFactory, ListReceiverApiResponseFactory, SlackIntegrationFactory, -} from '../../../api/v0alpha1/mocks/fakes/Receivers'; -import { listReceiverHandler } from '../../../api/v0alpha1/mocks/handlers/ReceiverHandlers'; +} from '../../../api/notifications/v0alpha1/mocks/fakes/Receivers'; +import { listReceiverHandler } from '../../../api/notifications/v0alpha1/mocks/handlers/ReceiverHandlers/listReceiverHandler'; export const simpleContactPointsList = ListReceiverApiResponseFactory.build({ items: [ diff --git a/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.tsx b/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.tsx index 674dbc76dd3..e6e8702b57e 100644 --- a/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.tsx +++ b/packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.tsx @@ -2,7 +2,7 @@ import { chain } from 'lodash'; import { Combobox, ComboboxOption } from '@grafana/ui'; -import type { ContactPoint } from '../../../api/v0alpha1/types'; +import type { ContactPoint } from '../../../api/notifications/v0alpha1/types'; import { useListContactPoints } from '../../hooks/v0alpha1/useContactPoints'; import { getContactPointDescription } from '../../utils'; diff --git a/packages/grafana-alerting/src/grafana/contactPoints/hooks/v0alpha1/useContactPoints.tsx b/packages/grafana-alerting/src/grafana/contactPoints/hooks/v0alpha1/useContactPoints.tsx index e72577e91d0..7b6ec11f2b2 100644 --- a/packages/grafana-alerting/src/grafana/contactPoints/hooks/v0alpha1/useContactPoints.tsx +++ b/packages/grafana-alerting/src/grafana/contactPoints/hooks/v0alpha1/useContactPoints.tsx @@ -5,8 +5,12 @@ import { } from '@reduxjs/toolkit/query/react'; import { OverrideProperties } from 'type-fest'; -import { CreateReceiverApiArg, type ListReceiverApiArg, alertingAPI } from '../../../api/v0alpha1/api.gen'; -import type { ContactPoint, EnhancedListReceiverApiResponse } from '../../../api/v0alpha1/types'; +import { + CreateReceiverApiArg, + type ListReceiverApiArg, + notificationsAPI, +} from '../../../api/notifications/v0alpha1/notifications.api.gen'; +import type { ContactPoint, EnhancedListReceiverApiResponse } from '../../../api/notifications/v0alpha1/types'; // this is a workaround for the fact that the generated types are not narrow enough type ListContactPointsHookResult = TypedUseQueryHookResult< @@ -18,17 +22,17 @@ type ListContactPointsHookResult = TypedUseQueryHookResult< // Type for the options that can be passed to the hook // Based on the pattern used for mutation options in this file type ListContactPointsQueryArgs = Parameters< - typeof alertingAPI.endpoints.listReceiver.useQuery + typeof notificationsAPI.endpoints.listReceiver.useQuery >[0]; type ListContactPointsQueryOptions = Parameters< - typeof alertingAPI.endpoints.listReceiver.useQuery + typeof notificationsAPI.endpoints.listReceiver.useQuery >[1]; /** * useListContactPoints is a hook that fetches a list of contact points * - * This function wraps the alertingAPI.useListReceiverQuery with proper typing + * This function wraps the notificationsAPI.useListReceiverQuery with proper typing * to ensure that the returned ContactPoints are correctly typed in the data.items array. * * It automatically uses the configured namespace for the query. @@ -40,7 +44,7 @@ export function useListContactPoints( queryArgs: ListContactPointsQueryArgs = {}, queryOptions: ListContactPointsQueryOptions = {} ) { - return alertingAPI.useListReceiverQuery(queryArgs, queryOptions); + return notificationsAPI.useListReceiverQuery(queryArgs, queryOptions); } // type narrowing mutations requires us to define a few helper types @@ -56,17 +60,17 @@ type CreateContactPointMutation = TypedUseMutationResult< >; type UseCreateContactPointOptions = Parameters< - typeof alertingAPI.endpoints.createReceiver.useMutation + typeof notificationsAPI.endpoints.createReceiver.useMutation >[0]; /** * useCreateContactPoint is a hook that creates a new contact point with one or more integrations * - * This function wraps the alertingAPI.useCreateReceiverMutation with proper typing + * This function wraps the notificationsAPI.useCreateReceiverMutation with proper typing * to ensure that the payload supports type narrowing. */ export function useCreateContactPoint(options?: UseCreateContactPointOptions) { - const [updateFn, result] = alertingAPI.endpoints.createReceiver.useMutation(options); + const [updateFn, result] = notificationsAPI.endpoints.createReceiver.useMutation(options); const typedUpdateFn = (args: CreateContactPointArgs) => { // @ts-expect-error this one is just impossible for me to figure out diff --git a/packages/grafana-alerting/src/grafana/contactPoints/utils.test.ts b/packages/grafana-alerting/src/grafana/contactPoints/utils.test.ts index 1aa816c1ab1..547c63398f7 100644 --- a/packages/grafana-alerting/src/grafana/contactPoints/utils.test.ts +++ b/packages/grafana-alerting/src/grafana/contactPoints/utils.test.ts @@ -3,7 +3,7 @@ import { EmailIntegrationFactory, GenericIntegrationFactory, SlackIntegrationFactory, -} from '../api/v0alpha1/mocks/fakes/Receivers'; +} from '../api/notifications/v0alpha1/mocks/fakes/Receivers'; import { getContactPointDescription } from './utils'; diff --git a/packages/grafana-alerting/src/grafana/contactPoints/utils.ts b/packages/grafana-alerting/src/grafana/contactPoints/utils.ts index 390c09d3887..ac4242bd1b1 100644 --- a/packages/grafana-alerting/src/grafana/contactPoints/utils.ts +++ b/packages/grafana-alerting/src/grafana/contactPoints/utils.ts @@ -1,7 +1,7 @@ import { countBy, isEmpty } from 'lodash'; -import { Receiver } from '../api/v0alpha1/api.gen'; -import { ContactPoint } from '../api/v0alpha1/types'; +import { Receiver } from '../api/notifications/v0alpha1/notifications.api.gen'; +import { ContactPoint } from '../api/notifications/v0alpha1/types'; /** * Generates a human-readable description of a ContactPoint by summarizing its integrations. diff --git a/packages/grafana-alerting/src/grafana/matchers/types.ts b/packages/grafana-alerting/src/grafana/matchers/types.ts index 8b6da9530c4..3cf3103fd1c 100644 --- a/packages/grafana-alerting/src/grafana/matchers/types.ts +++ b/packages/grafana-alerting/src/grafana/matchers/types.ts @@ -1,4 +1,4 @@ -import { RoutingTreeMatcher } from '../api/v0alpha1/api.gen'; +import { RoutingTreeMatcher } from '../api/notifications/v0alpha1/notifications.api.gen'; export type Label = [string, string]; diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.test.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.test.ts index 9bf6cd1c7b1..dc650db546b 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.test.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.test.ts @@ -1,5 +1,6 @@ -import { RoutingTree } from '../../api/v0alpha1/api.gen'; -import { LabelMatcherFactory, RouteFactory } from '../../api/v0alpha1/mocks/fakes/Routes'; +import { VERSION } from '../../api/notifications/v0alpha1/const'; +import { LabelMatcherFactory, RouteFactory } from '../../api/notifications/v0alpha1/mocks/fakes/Routes'; +import { RoutingTree } from '../../api/notifications/v0alpha1/notifications.api.gen'; import { Label } from '../../matchers/types'; import { matchInstancesToRouteTrees } from './useMatchPolicies'; @@ -15,6 +16,7 @@ describe('matchInstancesToRouteTrees', () => { const trees: RoutingTree[] = [ { kind: 'RoutingTree', + apiVersion: VERSION, metadata: { name: treeName }, spec: { defaults: { @@ -49,6 +51,7 @@ describe('matchInstancesToRouteTrees', () => { const trees: RoutingTree[] = [ { kind: 'RoutingTree', + apiVersion: VERSION, metadata: { name: treeName }, spec: { defaults: { diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.ts index 1e830830701..d23efaae967 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/hooks/useMatchPolicies.ts @@ -1,6 +1,6 @@ import { useCallback } from 'react'; -import { RoutingTree, alertingAPI } from '../../api/v0alpha1/api.gen'; +import { RoutingTree, notificationsAPI } from '../../api/notifications/v0alpha1/notifications.api.gen'; import { Label } from '../../matchers/types'; import { USER_DEFINED_TREE_NAME } from '../consts'; import { Route, RouteWithID } from '../types'; @@ -36,7 +36,7 @@ export type InstanceMatchResult = { * and returns an array of InstanceMatchResult objects, each containing the matched routes and matching details */ export function useMatchInstancesToRouteTrees() { - const { data, ...rest } = alertingAPI.endpoints.listRoutingTree.useQuery( + const { data, ...rest } = notificationsAPI.endpoints.listRoutingTree.useQuery( {}, { refetchOnFocus: true, diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/types.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/types.ts index 04bdc4f96c5..56465daf613 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/types.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/types.ts @@ -1,6 +1,6 @@ import { OverrideProperties } from 'type-fest'; -import { RoutingTreeRoute } from '../api/v0alpha1/api.gen'; +import { RoutingTreeRoute } from '../api/notifications/v0alpha1/notifications.api.gen'; import { LabelMatcher } from '../matchers/types'; // type-narrow the route tree diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.old.test.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.old.test.ts index 0107ac4878f..e18bd6f0038 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.old.test.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.old.test.ts @@ -1,7 +1,7 @@ /** * These tests were moved from Grafana core, we're keepign them around to prevent uncaught regressions */ -import { LabelMatcherFactory, RouteFactory } from '../api/v0alpha1/mocks/fakes/Routes'; +import { LabelMatcherFactory, RouteFactory } from '../api/notifications/v0alpha1/mocks/fakes/Routes'; import { Route } from './types'; import { findMatchingRoutes } from './utils'; diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.test.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.test.ts index 2c23b899a64..e3432f26f56 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.test.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.test.ts @@ -1,6 +1,6 @@ import { omit } from 'lodash'; -import { LabelMatcherFactory, RouteFactory } from '../api/v0alpha1/mocks/fakes/Routes'; +import { LabelMatcherFactory, RouteFactory } from '../api/notifications/v0alpha1/mocks/fakes/Routes'; import { Label } from '../matchers/types'; import { LabelMatchDetails, matchLabels } from '../matchers/utils'; diff --git a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.ts b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.ts index 444244fe5fe..1fc7608a76f 100644 --- a/packages/grafana-alerting/src/grafana/notificationPolicies/utils.ts +++ b/packages/grafana-alerting/src/grafana/notificationPolicies/utils.ts @@ -1,6 +1,6 @@ import { groupBy, isArray, pick, reduce, uniqueId } from 'lodash'; -import { RoutingTree, RoutingTreeRoute } from '../api/v0alpha1/api.gen'; +import { RoutingTree, RoutingTreeRoute } from '../api/notifications/v0alpha1/notifications.api.gen'; import { Label } from '../matchers/types'; import { LabelMatchDetails, matchLabels } from '../matchers/utils'; diff --git a/packages/grafana-alerting/src/testing.ts b/packages/grafana-alerting/src/testing.ts index f9c6426fe9c..e8743403c3e 100644 --- a/packages/grafana-alerting/src/testing.ts +++ b/packages/grafana-alerting/src/testing.ts @@ -1,10 +1,10 @@ // export MSW handlers for testing -export * from './grafana/api/v0alpha1/mocks/handlers'; +export * from './grafana/api/notifications/v0alpha1/mocks/handlers'; // export mocks and factories -export * from './grafana/api/v0alpha1/mocks/fakes/common'; -export * from './grafana/api/v0alpha1/mocks/fakes/Receivers'; -export * from './grafana/api/v0alpha1/mocks/fakes/Routes'; +export * from './grafana/api/notifications/v0alpha1/mocks/fakes/common'; +export * from './grafana/api/notifications/v0alpha1/mocks/fakes/Receivers'; +export * from './grafana/api/notifications/v0alpha1/mocks/fakes/Routes'; // scenarios export * from './grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario'; diff --git a/packages/grafana-alerting/src/unstable.ts b/packages/grafana-alerting/src/unstable.ts index 1b5fd591ee4..1aa47bae5d5 100644 --- a/packages/grafana-alerting/src/unstable.ts +++ b/packages/grafana-alerting/src/unstable.ts @@ -3,7 +3,7 @@ */ // Contact Points -export * from './grafana/api/v0alpha1/types'; +export * from './grafana/api/notifications/v0alpha1/types'; export { useListContactPoints } from './grafana/contactPoints/hooks/v0alpha1/useContactPoints'; export { ContactPointSelector } from './grafana/contactPoints/components/ContactPointSelector/ContactPointSelector'; export { getContactPointDescription } from './grafana/contactPoints/utils'; @@ -36,5 +36,6 @@ export { AlertLabels, type AlertLabelsProps } from './grafana/rules/components/l export { type LabelMatcher, type Label } from './grafana/matchers/types'; export { matchLabelsSet, matchLabels, isLabelMatch, type LabelMatchDetails } from './grafana/matchers/utils'; -// Low-level API hooks -export { alertingAPI } from './grafana/api/v0alpha1/api.gen'; +// API endpoints +export { notificationsAPI as notificationsAPIv0alpha1 } from './grafana/api/notifications/v0alpha1/notifications.api.gen'; +export { rulesAPI as rulesAPIv0alpha1 } from './grafana/api/rules/v0alpha1/rules.api.gen'; diff --git a/packages/grafana-alerting/tests/provider.tsx b/packages/grafana-alerting/tests/provider.tsx index 4331f7e6b8a..b3caa8679b2 100644 --- a/packages/grafana-alerting/tests/provider.tsx +++ b/packages/grafana-alerting/tests/provider.tsx @@ -2,13 +2,13 @@ import { configureStore } from '@reduxjs/toolkit'; import { useEffect } from 'react'; import { Provider } from 'react-redux'; -import { alertingAPI } from '../src/unstable'; +import { notificationsAPIv0alpha1 } from '../src/unstable'; // create an empty store export const store = configureStore({ - middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(alertingAPI.middleware), + middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(notificationsAPIv0alpha1.middleware), reducer: { - [alertingAPI.reducerPath]: alertingAPI.reducer, + [notificationsAPIv0alpha1.reducerPath]: notificationsAPIv0alpha1.reducer, }, }); @@ -35,7 +35,7 @@ export const getDefaultWrapper = () => { function useResetQueryCacheAfterUnmount() { useEffect(() => { return () => { - store.dispatch(alertingAPI.util.resetApiState()); + store.dispatch(notificationsAPIv0alpha1.util.resetApiState()); }; }, []); } diff --git a/public/app/api/clients/rules/v0alpha1/baseAPI.ts b/public/app/api/clients/rules/v0alpha1/baseAPI.ts deleted file mode 100644 index 2803f3de304..00000000000 --- a/public/app/api/clients/rules/v0alpha1/baseAPI.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react'; - -import { createBaseQuery } from 'app/api/createBaseQuery'; -import { getAPIBaseURL } from 'app/api/utils'; - -export const BASE_URL = getAPIBaseURL('rules.alerting.grafana.app', 'v0alpha1'); - -export const api = createApi({ - reducerPath: 'rulesAPIv0alpha1', - baseQuery: createBaseQuery({ - baseURL: BASE_URL, - }), - endpoints: () => ({}), -}); diff --git a/public/app/api/clients/rules/v0alpha1/index.ts b/public/app/api/clients/rules/v0alpha1/index.ts deleted file mode 100644 index 918d2f5c8d2..00000000000 --- a/public/app/api/clients/rules/v0alpha1/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generatedAPI } from './endpoints.gen'; - -export const rulesAPIv0alpha1 = generatedAPI.enhanceEndpoints({}); diff --git a/public/app/core/reducers/root.ts b/public/app/core/reducers/root.ts index 1e0d2791f31..82182101493 100644 --- a/public/app/core/reducers/root.ts +++ b/public/app/core/reducers/root.ts @@ -1,10 +1,9 @@ import { ReducersMapObject } from '@reduxjs/toolkit'; import { AnyAction, combineReducers } from 'redux'; -import { alertingAPI as alertingPackageAPI } from '@grafana/alerting/unstable'; +import { notificationsAPIv0alpha1, rulesAPIv0alpha1 } from '@grafana/alerting/unstable'; import { dashboardAPIv0alpha1 } from 'app/api/clients/dashboard/v0alpha1'; import { preferencesAPIv1alpha1 } from 'app/api/clients/preferences/v1alpha1'; -import { rulesAPIv0alpha1 } from 'app/api/clients/rules/v0alpha1'; import { shortURLAPIv1alpha1 } from 'app/api/clients/shorturl/v1alpha1'; import sharedReducers from 'app/core/reducers'; import ldapReducers from 'app/features/admin/state/reducers'; @@ -65,7 +64,8 @@ const rootReducers = { ...authConfigReducers, plugins: pluginsReducer, [alertingApi.reducerPath]: alertingApi.reducer, - [alertingPackageAPI.reducerPath]: alertingPackageAPI.reducer, + [notificationsAPIv0alpha1.reducerPath]: notificationsAPIv0alpha1.reducer, + [rulesAPIv0alpha1.reducerPath]: rulesAPIv0alpha1.reducer, [publicDashboardApi.reducerPath]: publicDashboardApi.reducer, [browseDashboardsAPI.reducerPath]: browseDashboardsAPI.reducer, [cloudMigrationAPI.reducerPath]: cloudMigrationAPI.reducer, @@ -76,7 +76,6 @@ const rootReducers = { [folderAPIv1beta1.reducerPath]: folderAPIv1beta1.reducer, [advisorAPIv0alpha1.reducerPath]: advisorAPIv0alpha1.reducer, [dashboardAPIv0alpha1.reducerPath]: dashboardAPIv0alpha1.reducer, - [rulesAPIv0alpha1.reducerPath]: rulesAPIv0alpha1.reducer, [shortURLAPIv1alpha1.reducerPath]: shortURLAPIv1alpha1.reducer, [preferencesAPIv1alpha1.reducerPath]: preferencesAPIv1alpha1.reducer, // PLOP_INJECT_REDUCER diff --git a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/contactPoint/ContactPointSelector.tsx b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/contactPoint/ContactPointSelector.tsx index a71930c8b88..9cfe5cf7dbd 100644 --- a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/contactPoint/ContactPointSelector.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/contactPoint/ContactPointSelector.tsx @@ -4,7 +4,10 @@ import { useEffect } from 'react'; import { Controller, useFormContext } from 'react-hook-form'; import { base64UrlEncode } from '@grafana/alerting'; -import { ContactPointSelector as GrafanaManagedContactPointSelector, alertingAPI } from '@grafana/alerting/unstable'; +import { + ContactPointSelector as GrafanaManagedContactPointSelector, + notificationsAPIv0alpha1, +} from '@grafana/alerting/unstable'; import { Trans, t } from '@grafana/i18n'; import { Field, FieldValidationMessage, Stack, TextLink } from '@grafana/ui'; import { RuleFormValues } from 'app/features/alerting/unified/types/rule-form'; @@ -24,7 +27,7 @@ export function ContactPointSelector({ alertManager }: ContactPointSelectorProps // check if the contact point still exists, we'll use listReceiver to check if the contact point exists because getReceiver doesn't work with // contact point titles but with UUIDs (which is not what we store on the alert rule definition) const encodedContactPoint = contactPointInForm ? base64UrlEncode(contactPointInForm) : ''; - const { currentData, status } = alertingAPI.endpoints.listReceiver.useQuery( + const { currentData, status } = notificationsAPIv0alpha1.endpoints.listReceiver.useQuery( { fieldSelector: stringifyFieldSelector([['metadata.name', encodedContactPoint]]), }, diff --git a/public/app/features/alerting/unified/components/rule-editor/notificaton-preview/ContactPointGroup.tsx b/public/app/features/alerting/unified/components/rule-editor/notificaton-preview/ContactPointGroup.tsx index 9d4510a2ac1..645c6f7d2e8 100644 --- a/public/app/features/alerting/unified/components/rule-editor/notificaton-preview/ContactPointGroup.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/notificaton-preview/ContactPointGroup.tsx @@ -4,7 +4,7 @@ import Skeleton from 'react-loading-skeleton'; import { useToggle } from 'react-use'; import { base64UrlEncode } from '@grafana/alerting'; -import { alertingAPI, getContactPointDescription } from '@grafana/alerting/unstable'; +import { getContactPointDescription, notificationsAPIv0alpha1 } from '@grafana/alerting/unstable'; import { GrafanaTheme2 } from '@grafana/data'; import { Trans, t } from '@grafana/i18n'; import { Stack, Text, TextLink, useStyles2 } from '@grafana/ui'; @@ -26,7 +26,7 @@ export function GrafanaContactPointGroup({ name, matchedInstancesCount, children // find receiver by name – since this is what we store in the alert rule definition const encodedName = base64UrlEncode(name); - const { data, isLoading } = alertingAPI.endpoints.listReceiver.useQuery({ + const { data, isLoading } = notificationsAPIv0alpha1.endpoints.listReceiver.useQuery({ fieldSelector: stringifyFieldSelector([['metadata.name', encodedName]]), }); diff --git a/public/app/features/alerting/unified/components/rule-viewer/ContactPointLink.tsx b/public/app/features/alerting/unified/components/rule-viewer/ContactPointLink.tsx index 741708860e0..6e504f7ee39 100644 --- a/public/app/features/alerting/unified/components/rule-viewer/ContactPointLink.tsx +++ b/public/app/features/alerting/unified/components/rule-viewer/ContactPointLink.tsx @@ -2,7 +2,7 @@ import { ComponentProps } from 'react'; import Skeleton from 'react-loading-skeleton'; import { base64UrlEncode } from '@grafana/alerting'; -import { alertingAPI } from '@grafana/alerting/unstable'; +import { notificationsAPIv0alpha1 } from '@grafana/alerting/unstable'; import { TextLink } from '@grafana/ui'; import { stringifyFieldSelector } from '../../utils/k8s/utils'; @@ -16,7 +16,7 @@ export const ContactPointLink = ({ name, ...props }: ContactPointLinkProps) => { const encodedName = base64UrlEncode(name); // find receiver by name using metadata.name field selector - const { currentData, isLoading, isSuccess } = alertingAPI.endpoints.listReceiver.useQuery({ + const { currentData, isLoading, isSuccess } = notificationsAPIv0alpha1.endpoints.listReceiver.useQuery({ fieldSelector: stringifyFieldSelector([['metadata.name', encodedName]]), }); diff --git a/public/app/store/configureStore.ts b/public/app/store/configureStore.ts index f1573a7a361..b05dc7c7b67 100644 --- a/public/app/store/configureStore.ts +++ b/public/app/store/configureStore.ts @@ -2,10 +2,9 @@ import { configureStore as reduxConfigureStore, createListenerMiddleware } from import { setupListeners } from '@reduxjs/toolkit/query'; import { Middleware } from 'redux'; -import { alertingAPI as alertingPackageAPI } from '@grafana/alerting/unstable'; +import { notificationsAPIv0alpha1, rulesAPIv0alpha1 } from '@grafana/alerting/unstable'; import { dashboardAPIv0alpha1 } from 'app/api/clients/dashboard/v0alpha1'; import { preferencesAPIv1alpha1 } from 'app/api/clients/preferences/v1alpha1'; -import { rulesAPIv0alpha1 } from 'app/api/clients/rules/v0alpha1'; import { shortURLAPIv1alpha1 } from 'app/api/clients/shorturl/v1alpha1'; import { browseDashboardsAPI } from 'app/features/browse-dashboards/api/browseDashboardsAPI'; import { publicDashboardApi } from 'app/features/dashboard/api/publicDashboardApi'; @@ -46,8 +45,12 @@ export function configureStore(initialState?: Partial) { middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: true, serializableCheck: false, immutableCheck: false }).concat( listenerMiddleware.middleware, + // older internal alerting API client alertingApi.middleware, - alertingPackageAPI.middleware, + // @grafana/alerting clients for managing (Alertmanager) notification entities and rules + notificationsAPIv0alpha1.middleware, + rulesAPIv0alpha1.middleware, + // other Grafana core APIs publicDashboardApi.middleware, browseDashboardsAPI.middleware, cloudMigrationAPI.middleware, @@ -58,7 +61,6 @@ export function configureStore(initialState?: Partial) { folderAPIv1beta1.middleware, advisorAPIv0alpha1.middleware, dashboardAPIv0alpha1.middleware, - rulesAPIv0alpha1.middleware, shortURLAPIv1alpha1.middleware, preferencesAPIv1alpha1.middleware, // PLOP_INJECT_MIDDLEWARE diff --git a/scripts/generate-rtk-apis.ts b/scripts/generate-rtk-apis.ts index 98123a26f03..10abef0394e 100644 --- a/scripts/generate-rtk-apis.ts +++ b/scripts/generate-rtk-apis.ts @@ -95,11 +95,6 @@ const config: ConfigFile = { schemaFile: '../data/openapi/shorturl.grafana.app-v1alpha1.json', tag: true, }, - '../public/app/api/clients/rules/v0alpha1/endpoints.gen.ts': { - apiFile: '../public/app/api/clients/rules/v0alpha1/baseAPI.ts', - schemaFile: '../data/openapi/rules.alerting.grafana.app-v0alpha1.json', - tag: true, - }, '../public/app/api/clients/preferences/v1alpha1/endpoints.gen.ts': { apiFile: '../public/app/api/clients/preferences/v1alpha1/baseAPI.ts', schemaFile: '../data/openapi/preferences.grafana.app-v1alpha1.json',