From b6db3dd9844d6d970319815c557479ff7ce05884 Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 25 Jul 2024 14:22:22 +0300 Subject: [PATCH 1/2] Updated openAPI with new call GetAccountKeys --- openapi/access.yaml | 45 ++++++ openapi/go-client-generated/README.md | 2 + openapi/go-client-generated/api/swagger.yaml | 103 +++++++++++++ openapi/go-client-generated/api_accounts.go | 135 ++++++++++++++++++ .../docs/AccountPublicKeys.md | 9 ++ .../go-client-generated/docs/AccountsApi.md | 39 +++++ .../model_account_public_keys.go | 13 ++ 7 files changed, 346 insertions(+) create mode 100644 openapi/go-client-generated/docs/AccountPublicKeys.md create mode 100644 openapi/go-client-generated/model_account_public_keys.go diff --git a/openapi/access.yaml b/openapi/access.yaml index 04a1463e4..90b80d8b4 100644 --- a/openapi/access.yaml +++ b/openapi/access.yaml @@ -381,6 +381,40 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalServerError' + /accounts/{address}/keys: + get: + summary: Get an Account Keys By Address + description: Get an account data by provided address in latest "sealed" block or by provided block height. + tags: + - Accounts + parameters: + - name: address + in: path + schema: + $ref: '#/components/schemas/Address' + required: true + description: The address of the account. + - name: block_height + in: query + schema: + $ref: '#/components/schemas/BlockHeight' + required: false + description: The block height to query for the account details at the "sealed" is used by default. + - $ref: '#/components/parameters/expandParam' + - $ref: '#/components/parameters/selectParam' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AccountPublicKeys' + '400': + $ref: '#/components/responses/400BadRequest' + '404': + $ref: '#/components/responses/404NotFound' + '500': + $ref: '#/components/responses/500InternalServerError' /accounts/{address}/keys/{index}: get: summary: Get an individual Account Key By Address and Index @@ -725,6 +759,17 @@ components: type: string _links: $ref: '#/components/schemas/Links' + AccountPublicKeys: + type: object + required: + - keys + properties: + keys: + type: array + items: + $ref: '#/components/schemas/AccountPublicKey' + minItems: 1 + uniqueItems: true AccountPublicKey: type: object required: diff --git a/openapi/go-client-generated/README.md b/openapi/go-client-generated/README.md index 101ebd46a..5259fd0fe 100644 --- a/openapi/go-client-generated/README.md +++ b/openapi/go-client-generated/README.md @@ -22,6 +22,7 @@ All URIs are relative to *https://rest-canary.onflow.org/v1/* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AccountsApi* | [**AccountsAddressGet**](docs/AccountsApi.md#accountsaddressget) | **Get** /accounts/{address} | Get an Account By Address +*AccountsApi* | [**AccountsAddressKeysGet**](docs/AccountsApi.md#accountsaddresskeysget) | **Get** /accounts/{address}/keys | Get an Account Keys By Address *AccountsApi* | [**AccountsAddressKeysIndexGet**](docs/AccountsApi.md#accountsaddresskeysindexget) | **Get** /accounts/{address}/keys/{index} | Get an individual Account Key By Address and Index *BlocksApi* | [**BlocksGet**](docs/BlocksApi.md#blocksget) | **Get** /blocks | Gets Blocks by Height *BlocksApi* | [**BlocksIdGet**](docs/BlocksApi.md#blocksidget) | **Get** /blocks/{id} | Get Blocks by ID. @@ -43,6 +44,7 @@ Class | Method | HTTP request | Description - [Account](docs/Account.md) - [AccountExpandable](docs/AccountExpandable.md) - [AccountPublicKey](docs/AccountPublicKey.md) + - [AccountPublicKeys](docs/AccountPublicKeys.md) - [AggregatedSignature](docs/AggregatedSignature.md) - [Block](docs/Block.md) - [BlockEvents](docs/BlockEvents.md) diff --git a/openapi/go-client-generated/api/swagger.yaml b/openapi/go-client-generated/api/swagger.yaml index 6759eb841..bb8d83d3f 100644 --- a/openapi/go-client-generated/api/swagger.yaml +++ b/openapi/go-client-generated/api/swagger.yaml @@ -707,6 +707,82 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + /accounts/{address}/keys: + get: + tags: + - Accounts + summary: Get an Account Keys By Address + description: Get an account data by provided address in latest "sealed" block + or by provided block height. + parameters: + - name: address + in: path + description: The address of the account. + required: true + style: simple + explode: false + schema: + $ref: '#/components/schemas/Address' + - name: block_height + in: query + description: The block height to query for the account details at the "sealed" + is used by default. + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/BlockHeight' + - name: expand + in: query + description: A comma-separated list indicating which properties of the content + to expand. + required: false + style: form + explode: false + schema: + minItems: 1 + uniqueItems: true + type: array + items: + type: string + - name: select + in: query + description: A comma-separated list indicating which properties of the content + to return. + required: false + style: form + explode: false + schema: + minItems: 1 + uniqueItems: true + type: array + items: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AccountPublicKeys' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' /accounts/{address}/keys/{index}: get: tags: @@ -1179,6 +1255,33 @@ components: _expandable: keys: keys contracts: contracts + AccountPublicKeys: + required: + - keys + type: object + properties: + keys: + minItems: 1 + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/AccountPublicKey' + example: + keys: + - public_key: public_key + sequence_number: sequence_number + index: index + weight: weight + signing_algorithm: BLSBLS12381 + revoked: true + hashing_algorithm: SHA2_256 + - public_key: public_key + sequence_number: sequence_number + index: index + weight: weight + signing_algorithm: BLSBLS12381 + revoked: true + hashing_algorithm: SHA2_256 AccountPublicKey: required: - hashing_algorithm diff --git a/openapi/go-client-generated/api_accounts.go b/openapi/go-client-generated/api_accounts.go index 8c35024b0..e0edab495 100644 --- a/openapi/go-client-generated/api_accounts.go +++ b/openapi/go-client-generated/api_accounts.go @@ -161,6 +161,141 @@ func (a *AccountsApiService) AccountsAddressGet(ctx context.Context, address str return localVarReturnValue, localVarHttpResponse, nil } /* +AccountsApiService Get an Account Keys By Address +Get an account data by provided address in latest \"sealed\" block or by provided block height. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param address The address of the account. + * @param optional nil or *AccountsApiAccountsAddressKeysGetOpts - Optional Parameters: + * @param "BlockHeight" (optional.Interface of BlockHeight) - The block height to query for the account details at the \"sealed\" is used by default. + * @param "Expand" (optional.Interface of []string) - A comma-separated list indicating which properties of the content to expand. + * @param "Select_" (optional.Interface of []string) - A comma-separated list indicating which properties of the content to return. +@return AccountPublicKeys +*/ + +type AccountsApiAccountsAddressKeysGetOpts struct { + BlockHeight optional.Interface + Expand optional.Interface + Select_ optional.Interface +} + +func (a *AccountsApiService) AccountsAddressKeysGet(ctx context.Context, address string, localVarOptionals *AccountsApiAccountsAddressKeysGetOpts) (AccountPublicKeys, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue AccountPublicKeys + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/accounts/{address}/keys" + localVarPath = strings.Replace(localVarPath, "{"+"address"+"}", fmt.Sprintf("%v", address), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.BlockHeight.IsSet() { + localVarQueryParams.Add("block_height", parameterToString(localVarOptionals.BlockHeight.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Expand.IsSet() { + localVarQueryParams.Add("expand", parameterToString(localVarOptionals.Expand.Value(), "csv")) + } + if localVarOptionals != nil && localVarOptionals.Select_.IsSet() { + localVarQueryParams.Add("select", parameterToString(localVarOptionals.Select_.Value(), "csv")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v AccountPublicKeys + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + if localVarHttpResponse.StatusCode == 500 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} +/* AccountsApiService Get an individual Account Key By Address and Index Get an account data by provided address in latest \"sealed\" block or by provided block height. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). diff --git a/openapi/go-client-generated/docs/AccountPublicKeys.md b/openapi/go-client-generated/docs/AccountPublicKeys.md new file mode 100644 index 000000000..f600ce620 --- /dev/null +++ b/openapi/go-client-generated/docs/AccountPublicKeys.md @@ -0,0 +1,9 @@ +# AccountPublicKeys + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Keys** | [**[]AccountPublicKey**](AccountPublicKey.md) | | [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/openapi/go-client-generated/docs/AccountsApi.md b/openapi/go-client-generated/docs/AccountsApi.md index 51d3c5dbb..9f8a17df8 100644 --- a/openapi/go-client-generated/docs/AccountsApi.md +++ b/openapi/go-client-generated/docs/AccountsApi.md @@ -5,6 +5,7 @@ All URIs are relative to *https://rest-canary.onflow.org/v1/* Method | HTTP request | Description ------------- | ------------- | ------------- [**AccountsAddressGet**](AccountsApi.md#AccountsAddressGet) | **Get** /accounts/{address} | Get an Account By Address +[**AccountsAddressKeysGet**](AccountsApi.md#AccountsAddressKeysGet) | **Get** /accounts/{address}/keys | Get an Account Keys By Address [**AccountsAddressKeysIndexGet**](AccountsApi.md#AccountsAddressKeysIndexGet) | **Get** /accounts/{address}/keys/{index} | Get an individual Account Key By Address and Index # **AccountsAddressGet** @@ -45,6 +46,44 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **AccountsAddressKeysGet** +> AccountPublicKeys AccountsAddressKeysGet(ctx, address, optional) +Get an Account Keys By Address + +Get an account data by provided address in latest \"sealed\" block or by provided block height. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **address** | [**string**](.md)| The address of the account. | + **optional** | ***AccountsApiAccountsAddressKeysGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a AccountsApiAccountsAddressKeysGetOpts struct +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **blockHeight** | [**optional.Interface of BlockHeight**](.md)| The block height to query for the account details at the \"sealed\" is used by default. | + **expand** | [**optional.Interface of []string**](string.md)| A comma-separated list indicating which properties of the content to expand. | + **select_** | [**optional.Interface of []string**](string.md)| A comma-separated list indicating which properties of the content to return. | + +### Return type + +[**AccountPublicKeys**](AccountPublicKeys.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **AccountsAddressKeysIndexGet** > AccountPublicKey AccountsAddressKeysIndexGet(ctx, address, index, optional) Get an individual Account Key By Address and Index diff --git a/openapi/go-client-generated/model_account_public_keys.go b/openapi/go-client-generated/model_account_public_keys.go new file mode 100644 index 000000000..75804a0d9 --- /dev/null +++ b/openapi/go-client-generated/model_account_public_keys.go @@ -0,0 +1,13 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package swagger + +type AccountPublicKeys struct { + Keys []AccountPublicKey `json:"keys"` +} From ef5539f9fd4ab68f1975c4aa658aa4bc87b5504e Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 26 Jul 2024 13:01:03 +0300 Subject: [PATCH 2/2] Removed expand parts for response --- openapi/access.yaml | 4 +-- openapi/go-client-generated/api/swagger.yaml | 30 ++----------------- openapi/go-client-generated/api_accounts.go | 12 +------- .../go-client-generated/docs/AccountsApi.md | 4 +-- 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/openapi/access.yaml b/openapi/access.yaml index 90b80d8b4..f90fe1c3f 100644 --- a/openapi/access.yaml +++ b/openapi/access.yaml @@ -399,9 +399,7 @@ paths: schema: $ref: '#/components/schemas/BlockHeight' required: false - description: The block height to query for the account details at the "sealed" is used by default. - - $ref: '#/components/parameters/expandParam' - - $ref: '#/components/parameters/selectParam' + description: The block height to query for the account balance. "sealed" is used by default. responses: '200': description: OK diff --git a/openapi/go-client-generated/api/swagger.yaml b/openapi/go-client-generated/api/swagger.yaml index bb8d83d3f..57ece66e0 100644 --- a/openapi/go-client-generated/api/swagger.yaml +++ b/openapi/go-client-generated/api/swagger.yaml @@ -725,39 +725,13 @@ paths: $ref: '#/components/schemas/Address' - name: block_height in: query - description: The block height to query for the account details at the "sealed" - is used by default. + description: The block height to query for the account balance. "sealed" is + used by default. required: false style: form explode: true schema: $ref: '#/components/schemas/BlockHeight' - - name: expand - in: query - description: A comma-separated list indicating which properties of the content - to expand. - required: false - style: form - explode: false - schema: - minItems: 1 - uniqueItems: true - type: array - items: - type: string - - name: select - in: query - description: A comma-separated list indicating which properties of the content - to return. - required: false - style: form - explode: false - schema: - minItems: 1 - uniqueItems: true - type: array - items: - type: string responses: "200": description: OK diff --git a/openapi/go-client-generated/api_accounts.go b/openapi/go-client-generated/api_accounts.go index e0edab495..32436a409 100644 --- a/openapi/go-client-generated/api_accounts.go +++ b/openapi/go-client-generated/api_accounts.go @@ -166,16 +166,12 @@ Get an account data by provided address in latest \"sealed\" block or * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param address The address of the account. * @param optional nil or *AccountsApiAccountsAddressKeysGetOpts - Optional Parameters: - * @param "BlockHeight" (optional.Interface of BlockHeight) - The block height to query for the account details at the \"sealed\" is used by default. - * @param "Expand" (optional.Interface of []string) - A comma-separated list indicating which properties of the content to expand. - * @param "Select_" (optional.Interface of []string) - A comma-separated list indicating which properties of the content to return. + * @param "BlockHeight" (optional.Interface of BlockHeight) - The block height to query for the account balance. \"sealed\" is used by default. @return AccountPublicKeys */ type AccountsApiAccountsAddressKeysGetOpts struct { BlockHeight optional.Interface - Expand optional.Interface - Select_ optional.Interface } func (a *AccountsApiService) AccountsAddressKeysGet(ctx context.Context, address string, localVarOptionals *AccountsApiAccountsAddressKeysGetOpts) (AccountPublicKeys, *http.Response, error) { @@ -198,12 +194,6 @@ func (a *AccountsApiService) AccountsAddressKeysGet(ctx context.Context, address if localVarOptionals != nil && localVarOptionals.BlockHeight.IsSet() { localVarQueryParams.Add("block_height", parameterToString(localVarOptionals.BlockHeight.Value(), "")) } - if localVarOptionals != nil && localVarOptionals.Expand.IsSet() { - localVarQueryParams.Add("expand", parameterToString(localVarOptionals.Expand.Value(), "csv")) - } - if localVarOptionals != nil && localVarOptionals.Select_.IsSet() { - localVarQueryParams.Add("select", parameterToString(localVarOptionals.Select_.Value(), "csv")) - } // to determine the Content-Type header localVarHttpContentTypes := []string{} diff --git a/openapi/go-client-generated/docs/AccountsApi.md b/openapi/go-client-generated/docs/AccountsApi.md index 9f8a17df8..2e8481d74 100644 --- a/openapi/go-client-generated/docs/AccountsApi.md +++ b/openapi/go-client-generated/docs/AccountsApi.md @@ -65,9 +65,7 @@ Optional parameters are passed through a pointer to a AccountsApiAccountsAddress Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **blockHeight** | [**optional.Interface of BlockHeight**](.md)| The block height to query for the account details at the \"sealed\" is used by default. | - **expand** | [**optional.Interface of []string**](string.md)| A comma-separated list indicating which properties of the content to expand. | - **select_** | [**optional.Interface of []string**](string.md)| A comma-separated list indicating which properties of the content to return. | + **blockHeight** | [**optional.Interface of BlockHeight**](.md)| The block height to query for the account balance. \"sealed\" is used by default. | ### Return type