From 735ee447d6ba236d160091a4fc556b0b6a81f0c8 Mon Sep 17 00:00:00 2001 From: Antoni Ivanov Date: Fri, 19 Aug 2022 16:35:05 +0300 Subject: [PATCH] control-service: fix the examples in swagger The examples for the query jobs endpoing (graphql) were not working (syntax was wrong/broken) so this is fixing them. I am also using markdown (which is supported by swagger) to visualize them instead of html tags (which is hard to maintain) Testing Done: started locally the service and inspected the swagger ui Signed-off-by: Antoni Ivanov --- .../model/apidefs/datajob-api/api.yaml | 290 +++++++++--------- 1 file changed, 148 insertions(+), 142 deletions(-) diff --git a/projects/control-service/projects/model/apidefs/datajob-api/api.yaml b/projects/control-service/projects/model/apidefs/datajob-api/api.yaml index 3b7c2f67d1..202057d119 100644 --- a/projects/control-service/projects/model/apidefs/datajob-api/api.yaml +++ b/projects/control-service/projects/model/apidefs/datajob-api/api.yaml @@ -142,15 +142,15 @@ paths: Check the latest example for the full list of supported query fields.

Simplest query that you could make is to fetch the job names -
-        {
- jobs(pageNumber: 1, pageSize: 25) {
- content {
- jobName
- }
- }
- }
-

+ ``` + { + jobs(pageNumber: 1, pageSize: 25) { + content { + jobName + } + } + } + ``` You could also use filtering and sorting function. Filter object has property, pattern and sort fields.
* property points out which field you want to filter, if you point out some other field that is not supported, @@ -160,155 +160,161 @@ paths: If a pattern string is not provided, then you must atleast provide the property field
* sort should be an enum value - ASC (ascending) or DESC (descending) option [not required, default is ASC] Multiple filters could be applied, but maximum one should contain sorting! -
-        {
- jobs(
- pageNumber: 1,
- pageSize: 25,
- filter: [{
- property: "jobName",
- pattern: "starshot",
- sort: "DESC"
- }],
- ) {
- content {
- jobName
- }
- }
- }
-

+ ``` + { + jobs( + pageNumber: 1, + pageSize: 25, + filter: [{ + property: "jobName", + pattern: "starshot", + sort: DESC + }], + ) { + content { + jobName + } + } + } + ``` You could also search for a string into the properties that you are requesting, for instance: This query will search for job names, team names and descriptions which contains the provided "starshot" string -
-        {
- jobs(
- pageNumber: 1,
- pageSize: 25,
- search: "starshot"
- ) {
- content {
- jobName,
- config {
- team
- description
- }
- }
- }
- }
-

+ ``` + { + jobs( + pageNumber: 1, + pageSize: 25, + search: "starshot" + ) { + content { + jobName, + config { + team + description + } + } + } + } + ``` Data jobs execution could also be searched by providing arguments to the execution field. Same as parent query arguments, the pageNumber and pageSize arguments are required! Page number should be a number greater than 1, and pageSize should be between 1 and 100 results (per page). You can also filter using the similar object structure as the parent query, but currently filtering is not supported, you can only provide field for sorting. This query will search -
-        {
- jobs(
- pageNumber: 1,
- pageSize: 25,
- ) {
- content {
- jobName,
- deployments {
- id
- executions(
- pageNumber: 1,
- pageSize: 5
- filter: [{
- property: "deployments.executions.startTime",
- sort: "DESC",
- }],
- ) {
+ ``` + { + jobs( + pageNumber: 1, + pageSize: 25, + ) { + content { + jobName, + deployments { + id + executions( + pageNumber: 1, + pageSize: 5, + filter: [{ + teamNameIn: ["starshot"] + }], + order: { + property: "startTime", + direction: DESC + } + ) { id status startTime endTime - {
- }
- }
- }
- }
-

+ { + } + } + } + } + ``` Full example of currently available for fetching fields. Note that if you combine searching and filtering, first it will apply filters and then within filtered jobs it will apply the search, vice versa is currently not supported: -
-        {
- jobs(
- pageNumber: 1,
- pageSize: 25,
- search: "daily",
- filter: [{
- property: "jobName",
- pattern: "import-sql",
- },{
- property: "team",
- pattern: "starshot",
- sort: "DESC"
- },{
- property: "deployments.enabled",
- pattern: "enabled",
- }],
- ) {
- content {
- jobName
- config {
- team
- description
- sourceUrl
- schedule {
- scheduleCron
- nextRunEpochSeconds
- }
- contacts {
- notifiedOnJobFailureUserError
- notifiedOnJobFailurePlatformError
- notifiedOnJobSuccess
- notifiedOnJobDeploy
- }
- }
- deployments {
- id
- enabled
- jobVersion
- mode
- executions(
- pageNumber: 1,
- pageSize: 25
- filter: [{
- property: "deployments.executions.status",
- sort: "ASC",
- }],
- ) {
- id
- type
- status
- message
- startTime
- endTime
- opId
- vkdVersion
- jobVersion
- jobSchedule
- resourcesCpuRequest
- resourcesCpuLimit
- resourcesMemoryRequest
- resourcesMemoryLimit
- deployedDate
- deployedBy
- startedBy
- logsUrl
- }
- }
- }
- totalPages
- totalItems
- }
- }
- }
-

+ ``` + { + jobs( + pageNumber: 1, + pageSize: 25, + search: "daily", + filter: [{ + property: "jobName", + pattern: "import-sql", + },{ + property: "team", + pattern: "starshot", + sort: DESC + },{ + property: "deployments.enabled", + pattern: "enabled", + }], + ) { + content { + jobName + config { + team + description + sourceUrl + schedule { + scheduleCron + nextRunEpochSeconds + } + contacts { + notifiedOnJobFailureUserError + notifiedOnJobFailurePlatformError + notifiedOnJobSuccess + notifiedOnJobDeploy + } + } + deployments { + id + enabled + jobVersion + mode + executions( + pageNumber: 1, + pageSize: 25, + filter: [{ + teamNameIn: ["starshot"] + }], + order: { + property: "startTime", + direction: DESC + } + ) { + id + type + status + message + startTime + endTime + opId + vkdVersion + jobVersion + jobSchedule + resourcesCpuRequest + resourcesCpuLimit + resourcesMemoryRequest + resourcesMemoryLimit + deployedDate + deployedBy + startedBy + logsUrl + } + } + } + totalPages + totalItems + } + } + } + ``` parameters: - name: team_name