From f9020ce48c21b8508dcaec7a73af2aa67d122b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Weisbarth?= Date: Wed, 12 Jul 2023 14:35:18 +0200 Subject: [PATCH] Fixes in the specification checked by swagger-cli; --- api/application-metric-api.yaml | 88 ++++++------------ api/custom-metrics-api.yaml | 38 +++----- api/policy-api.yaml | 155 +++++++++++++------------------- api/scaling-history-api.yaml | 37 +++----- api/shared_definitions.yaml | 13 +-- 5 files changed, 113 insertions(+), 218 deletions(-) diff --git a/api/application-metric-api.yaml b/api/application-metric-api.yaml index 78d253b697..406f5da926 100644 --- a/api/application-metric-api.yaml +++ b/api/application-metric-api.yaml @@ -1,17 +1,18 @@ -openapi: 3.1.0 +openapi: 3.0.0 info: title: Application Metric API description: | - List aggregated metrics of an application. AutoScaler collects the instances' metrics of an application, - and aggregate the raw data into an accumulated value for evaluation. + List aggregated metrics of an application. AutoScaler collects the instances' metrics of an + application, and aggregate the raw data into an accumulated value for evaluation. + This API is used to return the aggregated metric result of an application. version: 1.0.0 security: # Do we need that? -#- mtls: [] -- basicAuthentication: [] +# - mtls: [] +- basicAuthentication: [] tags: - name: Application Metric API V1 - description: List instance metrics of an application. + description: List aggregated metrics of an application. paths: /v1/apps/{guid}/aggregated_metric_histories/{metric_type}: @@ -25,20 +26,12 @@ paths: It can be found in the `application_id` property of the JSON object stored in the `VCAP_APPLICATION` environment variable. schema: - # type: string - # pattern: (\d|[a-f]){8}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){12} - # example: 8d0cee08-23ad-4813-a779-ad8118ea0b91 - $ref: "./shared_definitions.yaml#/schemas/GUID" + $ref: "./shared_definitions.yaml#/schemas/GUID" - name: metric_type in: path required: true description: The metric type schema: - # description: | - # One user-defined custom metric type or one of the system-default metric types, which are: - # "memoryused", "memoryutil", "responsetime", "throughput" and "cpu" - # type: string - # example: memoryused $ref: "./shared_definitions.yaml#/schemas/metric_type" - name: start-time in: query @@ -67,7 +60,7 @@ paths: example: order-direction=desc - name: page in: query - description: The page number to query + description: The page number to query. schema: type: integer minimum: 1 # Or Should it be "1"? @@ -81,16 +74,16 @@ paths: minimum: 0 # Or Should it be "1"? default: 50 example: results-per-page=10 - #- name: Authorization - #in: header - #schema: - #type: string - #example: | - #bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o + # - name: Authorization + # in: header + # schema: + # type: string + # example: | + # bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o get: - summary: Retrieves the instance metrics of an application + summary: Retrieves the instance metrics of an application. description: | - Use to retrieve instance metrics of an application + Use to retrieve instance metrics of an application. tags: - Application Metric API V1 responses: @@ -101,35 +94,20 @@ paths: schema: $ref: "#/components/schemas/Application_Metrics" default: - # description: | - # Error, the response body may contain further information. - # content: - # application/json: - # schema: - # $ref: "#/components/schemas/ErrorResponse" - $ref: "./shared_definitions.yaml#/responses/Error" + $ref: "./shared_definitions.yaml#/responses/Error" security: - basicAuthentication: [] x-codegen-request-body-name: body components: schemas: - ErrorResponse: - type: object - properties: - code: - type: string - description: The textual error code. - message: - type: string - description: The message describing the cause of the error. Application_Metrics: - description: Object containing Application Metrics. + description: Object containing Application Metrics type: object properties: total_results: type: integer format: int64 - description: Number of history entries found for the given query. + description: Number of history entries found for the given query example: 2 total_pages: type: integer @@ -139,7 +117,7 @@ components: page: type: integer format: int64 - description: Number of the current page. + description: Number of the current page example: 1 prev_url: type: string @@ -152,19 +130,12 @@ components: items: $ref: '#/components/schemas/ApplicationMetric' ApplicationMetric: - description: Object containing metric history + description: Object containing metric history type: object properties: app_guid: - description: | - Identificator used by Cloud Foundry for entities. - Anything is an entity. Apps, services, service-bindings, … - schema: - # type: string - # pattern: (\d|[a-f]){8}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){12} - # example: 8d0cee08-23ad-4813-a779-ad8118ea0b91 - $ref: "./shared_definitions.yaml#/schemas/GUID" + $ref: "./shared_definitions.yaml#/schemas/GUID" instanceIndex: type: integer description: Application Metric #TODO @@ -179,21 +150,16 @@ components: description: | The time at which the metrics were collected in the number of nanoseconds example: 1494989539138350000 - metric_type: - # description: | - # One user-defined custom metric type or one of the system-default metric types, which are: - # "memoryused", "memoryutil", "responsetime", "throughput" and "cpu" - # type: string - # example: memoryused - schema: - $ref: "./shared_definitions.yaml#/schemas/metric_type" + metric_type: + + $ref: "./shared_definitions.yaml#/schemas/metric_type" value: type: integer description: | The value of metric type to be returned as the aggregated metric result of an application example: 400 unit: - type: string + type: string example: megabytes securitySchemes: basicAuthentication: diff --git a/api/custom-metrics-api.yaml b/api/custom-metrics-api.yaml index a2dca68aa8..1abc8be3d1 100644 --- a/api/custom-metrics-api.yaml +++ b/api/custom-metrics-api.yaml @@ -1,11 +1,11 @@ -openapi: 3.1.0 +openapi: 3.0.0 info: title: app-autoscaler custom metrics API description: | app-autoscaler lets you automatically increase or decrease the number of your application instances based on the policies you have defined. Your applications can call the app-autoscaler custom metrics API to submit custom metrics defined and used in a dynamic scaling policy to enable automatic scaling based on application-specific metrics. version: 1.0.0 security: -- mtls: [] +# - mtls: [] - basicAuthentication: [] tags: - name: Custom Metrics API V1 @@ -17,18 +17,21 @@ paths: - in: path name: appGuid description: | - The GUID identifying the application for which the scaling history is fetched. + The GUID identifying the application for which the metrics are fetched. It can be found in the `application_id` property of the JSON object stored in the `VCAP_APPLICATION` environment variable. + example: 58d162ad-87d5-4f52-8abf-e56a63a67292 required: true schema: - # type: string - $ref: "shared_definitions.yaml#/schemas/GUID" + $ref: "./shared_definitions.yaml#/schemas/GUID" post: summary: Submits application-specific custom metrics to app-autoscaler. description: | - Use to submit custom metrics to app-autoscaler which are defined and used in a dynamic scaling policy to enable automatic scaling based on application-specific metrics. We recommend submitting the custom metrics every 40 seconds from every application instance. + Use to submit custom metrics to app-autoscaler which are defined and used in a dynamic + scaling policy to enable automatic scaling based on application-specific metrics. + + We recommend submitting the custom metrics every 40 seconds from every application instance. tags: - Custom Metrics API V1 requestBody: @@ -47,14 +50,6 @@ paths: - mtls: [] x-codegen-request-body-name: body components: - responses: - Error: - description: | - Error, the response body may contain further information. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' schemas: Metrics: required: @@ -90,19 +85,10 @@ components: type: string description: An optional unit for the metric, for display purposes only. example: jobs - ErrorResponse: - type: object - properties: - code: - type: string - description: The textual error code. - message: - type: string - description: The message describing the cause of the error. securitySchemes: - mtls: - type: mutualTLS - description: Use the Instance Identity Credentials provided by the Cloud Foundry runtime + # mtls: + # type: mutualTLS + # description: Use the Instance Identity Credentials provided by the Cloud Foundry runtime basicAuthentication: type: http scheme: basic diff --git a/api/policy-api.yaml b/api/policy-api.yaml index 293add7690..f4bf29d425 100644 --- a/api/policy-api.yaml +++ b/api/policy-api.yaml @@ -1,15 +1,16 @@ -openapi: 3.1.0 -info: +openapi: 3.0.0 +info: title: Policy API description: This API is used to create, delete, retrieve the policy version: 1.0.0 -security: -- basicAuthentication: [] #TODO +security: +# - mtls: [] +- basicAuthentication: [] tags: - name: Policy API V1 description: This API is used to create, delete, retrieve the policy -paths: +paths: /v1/apps/{guid}/policy: parameters: - name: guid @@ -21,19 +22,15 @@ paths: It can be found in the `application_id` property of the JSON object stored in the `VCAP_APPLICATION` environment variable. schema: - # type: string - # pattern: (\d|[a-f]){8}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){4}-(\d|[a-f]){12} - # example: 8d0cee08-23ad-4813-a779-ad8118ea0b91 $ref: "./shared_definitions.yaml#/schemas/GUID" - - #- name: Authorization - #in: header - #schema: - #type: string - #example: | - #bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o + # - name: Authorization + # in: header + # schema: + # type: string + # example: | + # bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o put: - summary: Retrieves the Policy + summary: Retrieves the Policy description: This API is used to create the policy tags: - Create Policy API V1 @@ -42,91 +39,61 @@ paths: application/json: schema: $ref: "#/components/schemas/Policy" #TODO - responses: + responses: "200": description: "OK" content: application/json: schema: $ref: "#/components/schemas/Policy" - default: - # description: | - # Error, the response body may contain further information. - # content: - # application/json: - # schema: - # $ref: "#/components/schemas/ErrorResponse" + default: $ref: "./shared_definitons.yaml#/responses/Error" security: - basicAuthentication: [] x-codegen-request-body-name: body delete: - summary: Deletes the policy + summary: Deletes the policy description: This API is used to delete the policy - tags: + tags: - Delete Policy API V1 - responses: + responses: "200": description: "OK" content: application/json: schema: $ref: "#/components/schemas/Policy" - default: - # description: | - # Error, the response body may contain further information. - # content: - # application/json: - # schema: - # $ref: "#/components/schemas/ErrorResponse" + default: $ref: "./shared_definitons.yaml#/responses/Error" security: - basicAuthentication: [] x-codegen-request-body-name: body get: - summary: Retrieves the Policy + summary: Retrieves the Policy description: This API is used to retrieve the policy tags: - - Get Policy API V1 - responses: + - Get Policy API V1 + responses: "200": description: "OK" content: application/json: schema: $ref: "#/components/schemas/Policy" - default: - # description: | - # Error, the response body may contain further information. - # content: - # application/json: - # schema: - # $ref: "#/components/schemas/ErrorResponse" + default: $ref: "./shared_definitons.yaml#/responses/Error" - security: - - basicAuthentication: [] - x-codegen-request-body-name: body components: schemas: - ErrorResponse: - type: object - properties: - code: - type: string - description: The textual error code. - message: - type: string - description: The message describing the cause of the error. Policy: - description: Object creating Policy + description: Object containing Policy type: object properties: instance_min_count: type: integer format: int64 description: minimal number of instance count - example: 1 - instance_max_count: + example: 2 + instance_max_count: type: integer format: int64 description: maximal number of instance count @@ -142,20 +109,20 @@ components: - adjustment properties: metric_type: - schema: + # schema: # description: | - # One user-defined custom metric type or one of the system-default metric types, which are: + # One user-defined custom metric type or one of the system-default metric types, which are: # "memoryused", "memoryutil", "responsetime", "throughput" and "cpu" # type: string # example: memoryused - $ref: "./shared_definitions.yaml#/schemas/metric_type" + $ref: "./shared_definitions.yaml#/schemas/metric_type" threshold: description: | The boundary when metric value exceeds is considered as a breach - #required: true - schema: - type: int - format: int64 + # required: true + # schema: + type: integer + format: int64 example: 30 operator: description: Used for standard operting signs - ">", "<", ">=", "<=" @@ -195,8 +162,8 @@ components: timezone: description: Using timezone definition of Java #https://docs.oracle.com/javase/8/docs/api/java/util/TimeZone.html - Do we need to implement it? #required: true - schema: - type: string + # schema: + type: string example: Asia/Shanghai # TODO: Try to make use of #- $ref: "../../src/autoscaler/api/policyvalidator/policy_json.schema.json#/" # TODO: @@ -220,20 +187,20 @@ components: description: the end date of the schedule. Must be a future time. type: string format: date - example: 2016-07-23 + example: 2016-07-23 start_time: description: the start time of the schedule in HH:MM format #required: true - schema: - type: string - pattern: ^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$ + # schema: + type: string + pattern: ^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$ example: 11:00 end_time: description: the end time of the schedule in HH:MM format #required: true - schema: - type: string - pattern: ^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$ + # schema: + type: string + pattern: ^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$ example: 19:30 end time of the schedule: description: | @@ -243,16 +210,16 @@ components: instance_min_count: description: minimal number of instance count for this schedule #required: true - schema: - type: integer - format: int64 + # schema: + type: integer + format: int64 example: 3 instance_max_count: description: maximal number of instance count for this schedule #required: true - schema: - type: integer - format: int64 + # schema: + type: integer + format: int64 example: 10 instance_min_instance_count: description: the initial minimal number of instance count for this schedule @@ -273,30 +240,30 @@ components: start_date_time: description: the start time of the schedule. Must be a future time #required: true - schema: - type: string - pattern: /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]/ + # schema: + type: string + pattern: /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]/ example: 2015-01-04T20:00 - end_date_time: + end_date_time: description: the start time of the schedule. Must be a future time #required: true - schema: - type: string - pattern: /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]/ + # schema: + type: string + pattern: /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]/ example: 2015-01-04T20:00 instance_min_count: description: minimal number of instance count for this schedule #required: true - schema: - type: integer - format: int64 + # schema: + type: integer + format: int64 example: 2 instance_max_count: description: maximal number of instance count for this schedule #required: true - schema: - type: integer - format: int64 + # schema: + type: integer + format: int64 example: 5 instance_min_instance_count: description: the initial minimal number of instance count for this schedule diff --git a/api/scaling-history-api.yaml b/api/scaling-history-api.yaml index 79081ff781..43045a83fb 100644 --- a/api/scaling-history-api.yaml +++ b/api/scaling-history-api.yaml @@ -1,10 +1,10 @@ -openapi: 3.1.0 +openapi: 3.0.0 info: title: Scaling History API description: List scaling history of an application version: 1.0.0 security: # Do we need that? -#- mtls: [] +# - mtls: [] - basicAuthentication: [] tags: - name: Scaling History API V1 @@ -22,7 +22,7 @@ paths: It can be found in the `application_id` property of the JSON object stored in the `VCAP_APPLICATION` environment variable. schema: - $ref: "shared_definitions.yaml#/schemas/GUID" + $ref: "./shared_definitions.yaml#/schemas/GUID" - name: start-time in: query description: | @@ -64,12 +64,12 @@ paths: minimum: 0 # Or Should it be "1"? default: 50 example: results-per-page=10 - #- name: Authorization - #in: header - #schema: - #type: string - #example: | - #bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o + # - name: Authorization + # in: header + # schema: + # type: string + # example: | + # bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o get: summary: Retrieves the scaling history of an application. description: | @@ -84,22 +84,13 @@ paths: schema: $ref: "#/components/schemas/History" default: - $ref: "./shared_definitions.yaml#/responses/Error" + $ref: "./shared_definitions.yaml#/responses/Error" security: - basicAuthentication: [] x-codegen-request-body-name: body components: schemas: - ErrorResponse: - type: object - properties: - code: - type: string - description: The textual error code. - message: - type: string - description: The message describing the cause of the error. History: description: Object containing scaling history. type: object @@ -165,13 +156,7 @@ components: This field is as well a selector of which of the other ones are used and which not. example: 0 app_guid: - description: | - The GUID identifying the application for which the scaling history is fetched. - - It can be found in the `application_id` property of the JSON object stored in the - `VCAP_APPLICATION` environment variable. - schema: - $ref: "./shared_definitions.yaml#/schemas/GUID" + $ref: "./shared_definitions.yaml#/schemas/GUID" timestamp: type: integer description: | diff --git a/api/shared_definitions.yaml b/api/shared_definitions.yaml index e2fd262d90..15dc3e60af 100644 --- a/api/shared_definitions.yaml +++ b/api/shared_definitions.yaml @@ -1,10 +1,3 @@ -openapi: 3.1.0 -info: - title: app-autoscaler custom metrics API - description: | - app-autoscaler lets you automatically increase or decrease the number of your application instances based on the policies you have defined. Your applications can call the app-autoscaler custom metrics API to submit custom metrics defined and used in a dynamic scaling policy to enable automatic scaling based on application-specific metrics. - version: 1.0.0 -paths: {} parameters: {} responses: Error: @@ -34,9 +27,7 @@ schemas: example: 8d0cee08-23ad-4813-a779-ad8118ea0b91 metric_type: description: | - One user-defined custom metric type or one of the system-default metric types, which are: + One user-defined custom metric type or one of the system-default metric types, which are: "memoryused", "memoryutil", "responsetime", "throughput" and "cpu" type: string - example: memoryused - - \ No newline at end of file + example: memoryused \ No newline at end of file