diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index 9a77688f..873b2838 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -1434,6 +1434,44 @@ ] } }, + "/api/v1/namespaces/{namespace}/schedule-count": { + "get": { + "summary": "CountSchedules is a visibility API to count schedules in a specific namespace.", + "operationId": "CountSchedules2", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1CountSchedulesResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "namespace", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "query", + "description": "Visibility query, see https://docs.temporal.io/list-filter for the syntax.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "WorkflowService" + ] + } + }, "/api/v1/namespaces/{namespace}/schedules": { "get": { "summary": "List all schedules in a namespace.", @@ -5668,6 +5706,44 @@ ] } }, + "/namespaces/{namespace}/schedule-count": { + "get": { + "summary": "CountSchedules is a visibility API to count schedules in a specific namespace.", + "operationId": "CountSchedules", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1CountSchedulesResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "namespace", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "query", + "description": "Visibility query, see https://docs.temporal.io/list-filter for the syntax.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "WorkflowService" + ] + } + }, "/namespaces/{namespace}/schedules": { "get": { "summary": "List all schedules in a namespace.", @@ -11478,6 +11554,40 @@ } } }, + "v1CountSchedulesResponse": { + "type": "object", + "properties": { + "count": { + "type": "string", + "format": "int64", + "description": "If `query` is not grouping by any field, the count is an approximate number\nof schedules that match the query.\nIf `query` is grouping by a field, the count is simply the sum of the counts\nof the groups returned in the response. This number can be smaller than the\ntotal number of schedules matching the query." + }, + "groups": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1CountSchedulesResponseAggregationGroup" + }, + "description": "Contains the groups if the request is grouping by a field.\nThe list might not be complete, and the counts of each group is approximate." + } + } + }, + "v1CountSchedulesResponseAggregationGroup": { + "type": "object", + "properties": { + "groupValues": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Payload" + } + }, + "count": { + "type": "string", + "format": "int64" + } + } + }, "v1CountWorkflowExecutionsResponse": { "type": "object", "properties": { diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index f2625c12..ac446721 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -1319,6 +1319,36 @@ paths: application/json: schema: $ref: '#/components/schemas/Status' + /api/v1/namespaces/{namespace}/schedule-count: + get: + tags: + - WorkflowService + description: CountSchedules is a visibility API to count schedules in a specific namespace. + operationId: CountSchedules + parameters: + - name: namespace + in: path + required: true + schema: + type: string + - name: query + in: query + description: Visibility query, see https://docs.temporal.io/list-filter for the syntax. + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/CountSchedulesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' /api/v1/namespaces/{namespace}/schedules: get: tags: @@ -5113,6 +5143,36 @@ paths: application/json: schema: $ref: '#/components/schemas/Status' + /namespaces/{namespace}/schedule-count: + get: + tags: + - WorkflowService + description: CountSchedules is a visibility API to count schedules in a specific namespace. + operationId: CountSchedules + parameters: + - name: namespace + in: path + required: true + schema: + type: string + - name: query + in: query + description: Visibility query, see https://docs.temporal.io/list-filter for the syntax. + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/CountSchedulesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' /namespaces/{namespace}/schedules: get: tags: @@ -8568,6 +8628,33 @@ components: $ref: '#/components/schemas/Payload' count: type: string + CountSchedulesResponse: + type: object + properties: + count: + type: string + description: |- + If `query` is not grouping by any field, the count is an approximate number + of schedules that match the query. + If `query` is grouping by a field, the count is simply the sum of the counts + of the groups returned in the response. This number can be smaller than the + total number of schedules matching the query. + groups: + type: array + items: + $ref: '#/components/schemas/CountSchedulesResponse_AggregationGroup' + description: |- + Contains the groups if the request is grouping by a field. + The list might not be complete, and the counts of each group is approximate. + CountSchedulesResponse_AggregationGroup: + type: object + properties: + groupValues: + type: array + items: + $ref: '#/components/schemas/Payload' + count: + type: string CountWorkflowExecutionsResponse: type: object properties: diff --git a/temporal/api/workflowservice/v1/request_response.proto b/temporal/api/workflowservice/v1/request_response.proto index ab1a691a..a2a6cfd0 100644 --- a/temporal/api/workflowservice/v1/request_response.proto +++ b/temporal/api/workflowservice/v1/request_response.proto @@ -1368,6 +1368,30 @@ message ListSchedulesResponse { bytes next_page_token = 2; } +message CountSchedulesRequest { + string namespace = 1; + // Visibility query, see https://docs.temporal.io/list-filter for the syntax. + string query = 2; +} + +message CountSchedulesResponse { + // If `query` is not grouping by any field, the count is an approximate number + // of schedules that match the query. + // If `query` is grouping by a field, the count is simply the sum of the counts + // of the groups returned in the response. This number can be smaller than the + // total number of schedules matching the query. + int64 count = 1; + + // Contains the groups if the request is grouping by a field. + // The list might not be complete, and the counts of each group is approximate. + repeated AggregationGroup groups = 2; + + message AggregationGroup { + repeated temporal.api.common.v1.Payload group_values = 1; + int64 count = 2; + } +} + // [cleanup-wv-pre-release] message UpdateWorkerBuildIdCompatibilityRequest { message AddNewCompatibleVersion { diff --git a/temporal/api/workflowservice/v1/service.proto b/temporal/api/workflowservice/v1/service.proto index 119b7115..085eba30 100644 --- a/temporal/api/workflowservice/v1/service.proto +++ b/temporal/api/workflowservice/v1/service.proto @@ -670,6 +670,16 @@ service WorkflowService { }; } + // CountSchedules is a visibility API to count schedules in a specific namespace. + rpc CountSchedules (CountSchedulesRequest) returns (CountSchedulesResponse) { + option (google.api.http) = { + get: "/namespaces/{namespace}/schedule-count" + additional_bindings { + get: "/api/v1/namespaces/{namespace}/schedule-count" + } + }; + } + // Deprecated. Use `UpdateWorkerVersioningRules`. // // Allows users to specify sets of worker build id versions on a per task queue basis. Versions