Skip to content

Commit

Permalink
update grafana client codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
Giems committed Dec 4, 2024
1 parent 5b8ee0f commit 658433a
Show file tree
Hide file tree
Showing 55 changed files with 160 additions and 1,283 deletions.
51 changes: 38 additions & 13 deletions grafana-client-gen/run_codegen.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

# Source both .env files
if [ -f .env ]; then
export $(cat .env | xargs)
Expand Down Expand Up @@ -30,20 +29,39 @@ rm -rf $OPENAPI_GENERATOR_DIR
echo "Setting up new build directory..."
mkdir -p $OPENAPI_GENERATOR_DIR

# Get the commit hash for the version tag
echo "Getting commit hash for Grafana version $GRAFANA_VERSION_CLEAN..."
COMMIT_HASH=$(curl -s "https://api.github.com/repos/grafana/grafana/git/refs/tags/v$GRAFANA_VERSION_CLEAN" | grep -o '"sha": "[^"]*' | cut -d'"' -f4)
# First, get the tag reference
TAG_URL="https://api.github.com/repos/grafana/grafana/git/refs/tags/v$GRAFANA_VERSION_CLEAN"
echo "Fetching from tag URL: $TAG_URL"
TAG_DATA=$(curl -s "$TAG_URL")
echo "Tag API Response:"
echo "$TAG_DATA"

# Get the SHA of the tag object
TAG_SHA=$(echo "$TAG_DATA" | grep -o '"sha": "[^"]*"' | head -1 | cut -d'"' -f4)
echo "Tag SHA: $TAG_SHA"

# Now get the actual commit SHA that this tag points to
TAG_URL="https://api.github.com/repos/grafana/grafana/git/tags/$TAG_SHA"
echo "Fetching tag details from: $TAG_URL"
TAG_DETAILS=$(curl -s "$TAG_URL")
echo "Tag Details Response:"
echo "$TAG_DETAILS"

if [ -z "$COMMIT_HASH" ]; then
echo "Failed to get commit hash for version $GRAFANA_VERSION_CLEAN"
# Extract the actual commit SHA
COMMIT_HASH=$(echo "$TAG_DETAILS" | grep -o '"sha": "[^"]*"' | tail -1 | cut -d'"' -f4)

if [ -z "$COMMIT_HASH" ] || [ "$COMMIT_HASH" = "null" ]; then
echo "Failed to get proper commit hash for version $GRAFANA_VERSION_CLEAN"
exit 1
fi

echo "Found commit hash: $COMMIT_HASH"

# Download the OpenAPI spec for the specific version
echo "Downloading OpenAPI spec for commit $COMMIT_HASH..."
curl -o $OPENAPI_GENERATOR_DIR/openapi3.json "https://raw.githubusercontent.com/grafana/grafana/$COMMIT_HASH/public/openapi3.json"
SPEC_URL="https://raw.githubusercontent.com/grafana/grafana/$COMMIT_HASH/public/openapi3.json"
echo "Downloading from: $SPEC_URL"
curl -L -o $OPENAPI_GENERATOR_DIR/openapi3.json "$SPEC_URL"

if [ -f $OPENAPI_GENERATOR_DIR/openapi3.json ]; then
echo "OPENAPI file downloaded successfully."
Expand All @@ -52,11 +70,18 @@ else
exit 1
fi

# Get current user's UID and GID
USER_ID=$(id -u)
GROUP_ID=$(id -g)

echo "Running Docker to generate code..."
docker run --rm -v ${PWD}/${OPENAPI_GENERATOR_DIR}:/local openapitools/openapi-generator-cli generate \
-i /local/openapi3.json \
-g $OPENAPI_LANGUAGE \
-o /local/grafana-rust-client
docker run --rm \
--user $USER_ID:$GROUP_ID \
-v ${PWD}/${OPENAPI_GENERATOR_DIR}:/local \
openapitools/openapi-generator-cli generate \
-i /local/openapi3.json \
-g $OPENAPI_LANGUAGE \
-o /local/grafana-rust-client

echo "Code generation complete."

Expand All @@ -73,9 +98,9 @@ if [ -d "$OPENAPI_GENERATOR_DIR/grafana-rust-client/src" ]; then
cp -r "$OPENAPI_GENERATOR_DIR/grafana-rust-client" "$TARGET_DIR"
echo "Files copied successfully to $TARGET_DIR."

echo "Setting full permissions for $TARGET_DIR..."
echo "Setting permissions for $TARGET_DIR..."
chmod -R 777 "$TARGET_DIR"
echo "Permissions set to 777 for all files and directories in $TARGET_DIR."
echo "Permissions set for all files and directories in $TARGET_DIR."
else
echo "Code generation did not complete successfully; src directory not found."
exit 1
Expand Down
15 changes: 0 additions & 15 deletions openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,6 @@ Class | Method | HTTP request | Description
*LicensingApi* | [**post_license_token**](docs/LicensingApi.md#post_license_token) | **POST** /licensing/token | Create license token.
*LicensingApi* | [**post_renew_license_token**](docs/LicensingApi.md#post_renew_license_token) | **POST** /licensing/token/renew | Manually force license refresh.
*LicensingApi* | [**refresh_license_stats**](docs/LicensingApi.md#refresh_license_stats) | **GET** /licensing/refresh-stats | Refresh license stats.
*MigrationsApi* | [**create_cloud_migration_token**](docs/MigrationsApi.md#create_cloud_migration_token) | **POST** /cloudmigration/token | Create gcom access token.
*MigrationsApi* | [**create_migration**](docs/MigrationsApi.md#create_migration) | **POST** /cloudmigration/migration | Create a migration.
*MigrationsApi* | [**delete_cloud_migration**](docs/MigrationsApi.md#delete_cloud_migration) | **DELETE** /cloudmigration/migration/{id} | Delete a migration.
*MigrationsApi* | [**get_cloud_migration**](docs/MigrationsApi.md#get_cloud_migration) | **GET** /cloudmigration/migration/{id} | Get a cloud migration.
*MigrationsApi* | [**get_cloud_migration_run**](docs/MigrationsApi.md#get_cloud_migration_run) | **GET** /cloudmigration/migration/{id}/run/{runID} | Get the result of a single migration run.
*MigrationsApi* | [**get_cloud_migration_run_list**](docs/MigrationsApi.md#get_cloud_migration_run_list) | **GET** /cloudmigration/migration/{id}/run | Get a list of migration runs for a migration.
*MigrationsApi* | [**get_migration_list**](docs/MigrationsApi.md#get_migration_list) | **GET** /cloudmigration/migration | Get a list of all cloud migrations.
*MigrationsApi* | [**run_cloud_migration**](docs/MigrationsApi.md#run_cloud_migration) | **POST** /cloudmigration/migration/{id}/run | Trigger the run of a migration to the Grafana Cloud.
*OrgApi* | [**add_org_user_to_current_org**](docs/OrgApi.md#add_org_user_to_current_org) | **POST** /org/users | Add a new user to the current organization.
*OrgApi* | [**get_current_org**](docs/OrgApi.md#get_current_org) | **GET** /org | Get current Organization.
*OrgApi* | [**get_org_users_for_current_org**](docs/OrgApi.md#get_org_users_for_current_org) | **GET** /org/users | Get all users within the current organization.
Expand Down Expand Up @@ -446,18 +438,13 @@ Class | Method | HTTP request | Description
- [Certificate](docs/Certificate.md)
- [ChangeUserPasswordCommand](docs/ChangeUserPasswordCommand.md)
- [ClearHelpFlags200Response](docs/ClearHelpFlags200Response.md)
- [CloudMigrationListResponse](docs/CloudMigrationListResponse.md)
- [CloudMigrationRequest](docs/CloudMigrationRequest.md)
- [CloudMigrationResponse](docs/CloudMigrationResponse.md)
- [CloudMigrationRunList](docs/CloudMigrationRunList.md)
- [ClusterStatus](docs/ClusterStatus.md)
- [Config](docs/Config.md)
- [ContactPointExport](docs/ContactPointExport.md)
- [CookiePreferences](docs/CookiePreferences.md)
- [Correlation](docs/Correlation.md)
- [CorrelationConfig](docs/CorrelationConfig.md)
- [CorrelationConfigUpdateDto](docs/CorrelationConfigUpdateDto.md)
- [CreateAccessTokenResponseDto](docs/CreateAccessTokenResponseDto.md)
- [CreateCorrelationCommand](docs/CreateCorrelationCommand.md)
- [CreateCorrelationResponseBody](docs/CreateCorrelationResponseBody.md)
- [CreateDashboardSnapshot200Response](docs/CreateDashboardSnapshot200Response.md)
Expand Down Expand Up @@ -566,8 +553,6 @@ Class | Method | HTTP request | Description
- [MassDeleteAnnotationsCmd](docs/MassDeleteAnnotationsCmd.md)
- [Matcher](docs/Matcher.md)
- [MetricRequest](docs/MetricRequest.md)
- [MigrateDataResponseDto](docs/MigrateDataResponseDto.md)
- [MigrateDataResponseItemDto](docs/MigrateDataResponseItemDto.md)
- [MoveFolderCommand](docs/MoveFolderCommand.md)
- [MsTeamsConfig](docs/MsTeamsConfig.md)
- [MuteTimeInterval](docs/MuteTimeInterval.md)
Expand Down
5 changes: 2 additions & 3 deletions openapi/docs/AccessControlApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,17 @@ Name | Type | Description | Required | Notes

## list_roles

> Vec<models::RoleDto> list_roles(delegatable, include_hidden)
> Vec<models::RoleDto> list_roles(delegatable)
Get all roles.

Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in. You need to have a permission with action `roles:read` and scope `roles:*`. The `delegatable` flag reduces the set of roles to only those for which the signed-in user has permissions to assign.
Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in. You need to have a permission with action `roles:read` and scope `roles:*`.

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**delegatable** | Option<**bool**> | | |
**include_hidden** | Option<**bool**> | | |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion openapi/docs/AlertQueryExport.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**datasource_uid** | Option<**String**> | | [optional]
**model** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | | [optional]
**model** | Option<[**serde_json::Value**](.md)> | | [optional]
**query_type** | Option<**String**> | | [optional]
**ref_id** | Option<**String**> | | [optional]
**relative_time_range** | Option<[**models::RelativeTimeRangeExport**](RelativeTimeRangeExport.md)> | | [optional]
Expand Down
3 changes: 1 addition & 2 deletions openapi/docs/Certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Name | Type | Description | Notes
**permitted_email_addresses** | Option<**Vec<String>**> | | [optional]
**permitted_ip_ranges** | Option<[**Vec<models::IpNet>**](IPNet.md)> | | [optional]
**permitted_uri_domains** | Option<**Vec<String>**> | | [optional]
**policies** | Option<[**Vec<serde_json::Value>**](serde_json::Value.md)> | Policies contains all policy identifiers included in the certificate. In Go 1.22, encoding/gob cannot handle and ignores this field. | [optional]
**policy_identifiers** | Option<[**Vec<Vec<i64>>**](Vec.md)> | PolicyIdentifiers contains asn1.ObjectIdentifiers, the components of which are limited to int32. If a certificate contains a policy which cannot be represented by asn1.ObjectIdentifier, it will not be included in PolicyIdentifiers, but will be present in Policies, which contains all parsed policy OIDs. | [optional]
**policy_identifiers** | Option<[**Vec<Vec<i64>>**](Vec.md)> | | [optional]
**public_key** | Option<[**serde_json::Value**](.md)> | | [optional]
**public_key_algorithm** | Option<**i64**> | | [optional]
**raw** | Option<**Vec<i32>**> | | [optional]
Expand Down
11 changes: 0 additions & 11 deletions openapi/docs/CloudMigrationListResponse.md

This file was deleted.

11 changes: 0 additions & 11 deletions openapi/docs/CloudMigrationRequest.md

This file was deleted.

14 changes: 0 additions & 14 deletions openapi/docs/CloudMigrationResponse.md

This file was deleted.

11 changes: 0 additions & 11 deletions openapi/docs/CloudMigrationRunList.md

This file was deleted.

6 changes: 3 additions & 3 deletions openapi/docs/CookiePreferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**analytics** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | | [optional]
**functional** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | | [optional]
**performance** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | | [optional]
**analytics** | Option<[**serde_json::Value**](.md)> | | [optional]
**functional** | Option<[**serde_json::Value**](.md)> | | [optional]
**performance** | Option<[**serde_json::Value**](.md)> | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
2 changes: 1 addition & 1 deletion openapi/docs/CorrelationConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**field** | **String** | Field used to attach the correlation link |
**target** | [**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md) | Target data query |
**target** | [**serde_json::Value**](.md) | Target data query |
**transformations** | Option<[**Vec<models::Transformation>**](Transformation.md)> | | [optional]
**r#type** | **String** | |

Expand Down
2 changes: 1 addition & 1 deletion openapi/docs/CorrelationConfigUpdateDto.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**field** | Option<**String**> | Field used to attach the correlation link | [optional]
**target** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | Target data query | [optional]
**target** | Option<[**serde_json::Value**](.md)> | Target data query | [optional]
**transformations** | Option<[**Vec<models::Transformation>**](Transformation.md)> | Source data transformations | [optional]
**r#type** | Option<**String**> | | [optional]

Expand Down
11 changes: 0 additions & 11 deletions openapi/docs/CreateAccessTokenResponseDto.md

This file was deleted.

5 changes: 2 additions & 3 deletions openapi/docs/EnterpriseApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -902,18 +902,17 @@ This endpoint does not need any parameter.

## list_roles

> Vec<models::RoleDto> list_roles(delegatable, include_hidden)
> Vec<models::RoleDto> list_roles(delegatable)
Get all roles.

Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in. You need to have a permission with action `roles:read` and scope `roles:*`. The `delegatable` flag reduces the set of roles to only those for which the signed-in user has permissions to assign.
Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in. You need to have a permission with action `roles:read` and scope `roles:*`.

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**delegatable** | Option<**bool**> | | |
**include_hidden** | Option<**bool**> | | |

### Return type

Expand Down
4 changes: 2 additions & 2 deletions openapi/docs/FieldConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**color** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | Map values to a display color NOTE: this interface is under development in the frontend... so simple map for now | [optional]
**custom** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | Panel Specific Values | [optional]
**color** | Option<[**serde_json::Value**](.md)> | Map values to a display color NOTE: this interface is under development in the frontend... so simple map for now | [optional]
**custom** | Option<[**serde_json::Value**](.md)> | Panel Specific Values | [optional]
**decimals** | Option<**i32**> | | [optional]
**description** | Option<**String**> | Description is human readable field metadata | [optional]
**display_name** | Option<**String**> | DisplayName overrides Grafana default naming, should not be used from a data source | [optional]
Expand Down
2 changes: 1 addition & 1 deletion openapi/docs/IpNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ip** | Option<**String**> | | [optional]
**mask** | Option<**Vec<i32>**> | See type [IPNet] and func [ParseCIDR] for details. | [optional]
**mask** | Option<**Vec<i32>**> | See type IPNet and func ParseCIDR for details. | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
2 changes: 1 addition & 1 deletion openapi/docs/ListAllProvidersSettings200ResponseInner.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**String**> | | [optional]
**provider** | Option<**String**> | | [optional]
**settings** | Option<[**std::collections::HashMap<String, serde_json::Value>**](serde_json::Value.md)> | | [optional]
**settings** | Option<[**serde_json::Value**](.md)> | | [optional]
**source** | Option<**String**> | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
12 changes: 0 additions & 12 deletions openapi/docs/MigrateDataResponseDto.md

This file was deleted.

14 changes: 0 additions & 14 deletions openapi/docs/MigrateDataResponseItemDto.md

This file was deleted.

Loading

0 comments on commit 658433a

Please sign in to comment.