diff --git a/web/src/cde-gitness/components/CDEAnyGitImport/CDEAnyGitImport.tsx b/web/src/cde-gitness/components/CDEAnyGitImport/CDEAnyGitImport.tsx index d92c4d715..4912931d7 100644 --- a/web/src/cde-gitness/components/CDEAnyGitImport/CDEAnyGitImport.tsx +++ b/web/src/cde-gitness/components/CDEAnyGitImport/CDEAnyGitImport.tsx @@ -38,7 +38,7 @@ export const CDEAnyGitImport = () => { let errorMessage = '' try { if (isValidUrl(url)) { - const response = (await mutate({ url })) as { + const response = (await mutate({ url, repo_type: EnumGitspaceCodeRepoType.UNKNOWN })) as { is_private?: boolean branch: string url: string diff --git a/web/src/services/cde/index.tsx b/web/src/services/cde/index.tsx index d442f3811..9c6065548 100644 --- a/web/src/services/cde/index.tsx +++ b/web/src/services/cde/index.tsx @@ -5,8 +5,6 @@ import { Get, GetProps, useGet, UseGetProps, Mutate, MutateProps, useMutate, Use import { getConfig } from '../config' export const SPEC_VERSION = '0.0.0' -export type EnumCodeRepoAccessType = 'private' | 'public' - export type EnumCodeRepoType = 'github' | 'gitlab' | 'harnessCode' | 'bitbucket' | 'unknown' export type EnumGitspaceAccessType = 'jwt_token' | 'user_credentials' | 'ssh_key' @@ -103,10 +101,6 @@ export interface OpenapiCreateInfraProviderConfigRequest { type?: EnumInfraProviderType } -export interface OpenapiCreateInfraProviderResourceResponse { - resources?: TypesInfraProviderResourceRequest[] | null -} - export interface OpenapiCreateInfraProviderResponse { created?: number id?: string @@ -143,9 +137,9 @@ export interface OpenapiGetCodeRepositoryRequest { } export interface OpenapiGetCodeRepositoryResponse { - access_type?: EnumCodeRepoAccessType + access_type?: EnumGitspaceAccessType branch?: string - repo_type?: EnumCodeRepoType + repo_type?: EnumGitspaceCodeRepoType url?: string } @@ -174,9 +168,8 @@ export interface OpenapiGitspaceActionRequest { action?: EnumGitspaceActionType } -export type OpenapiListInfraProviderResourceResponse = TypesInfraProviderResourceResponse[] | null - export interface OpenapiLookupRepoGitspaceRequest { + repo_type?: EnumGitspaceCodeRepoType space_ref?: string url?: string } @@ -205,6 +198,7 @@ export interface ScmCodeRepositoryResponse { export interface TypesGitspaceConfig { branch?: string + code_repo_is_private?: boolean code_repo_ref?: string | null code_repo_type?: EnumGitspaceCodeRepoType code_repo_url?: string @@ -219,6 +213,8 @@ export interface TypesGitspaceConfig { ssh_token_identifier?: string state?: EnumGitspaceStateType updated?: number + user_display_name?: string + user_email?: string user_id?: string } @@ -252,6 +248,7 @@ export interface TypesGitspaceEventResponse { export interface TypesGitspaceInstance { access_key?: string | null + access_key_ref?: string | null access_type?: EnumGitspaceAccessType created?: number identifier?: string @@ -300,42 +297,8 @@ export interface TypesInfraProviderResource { updated?: number } -export interface TypesInfraProviderResourceRequest { - cpu?: string - disk?: string - gateway_host?: string - gateway_port?: string - id?: string - infra_provider_type?: EnumProviderType - memory?: string - name?: string - network?: string - opentofu_params?: { - [key: string]: string - } | null - region?: string[] | null - template_id?: string -} - -export interface TypesInfraProviderResourceResponse { - cpu?: string - created?: number - disk?: string - gateway_host?: string - gateway_port?: string - id?: string - infra_provider_config_id?: string - infra_provider_type?: EnumProviderType - memory?: string - name?: string - network?: string - opentofu_params?: { - [key: string]: string - } | null - region?: string - space_path?: string - template_id?: string - updated?: number +export interface TypesInfraProviderResourceType2 { + [key: string]: any } export interface UsererrorError { @@ -382,58 +345,6 @@ export const useListGitspacesForAccount = ({ accountIdentifier, ...props }: UseL { base: getConfig('cde/api/v1'), pathParams: { accountIdentifier }, ...props } ) -export interface ListInfraProviderResourcesForAccountPathParams { - /** - * account identifier. - */ - accountIdentifier: string - /** - * infra Provider Config Identifier. - */ - infraprovider_identifier: string -} - -export type ListInfraProviderResourcesForAccountProps = Omit< - GetProps, - 'path' -> & - ListInfraProviderResourcesForAccountPathParams - -/** - * List infraProvider Resources - */ -export const ListInfraProviderResourcesForAccount = ({ - accountIdentifier, - infraprovider_identifier, - ...props -}: ListInfraProviderResourcesForAccountProps) => ( - - path={`/accounts/${accountIdentifier}/infraproviders/${infraprovider_identifier}/resources`} - base={getConfig('cde/api/v1')} - {...props} - /> -) - -export type UseListInfraProviderResourcesForAccountProps = Omit< - UseGetProps, - 'path' -> & - ListInfraProviderResourcesForAccountPathParams - -/** - * List infraProvider Resources - */ -export const useListInfraProviderResourcesForAccount = ({ - accountIdentifier, - infraprovider_identifier, - ...props -}: UseListInfraProviderResourcesForAccountProps) => - useGet( - (paramsInPath: ListInfraProviderResourcesForAccountPathParams) => - `/accounts/${paramsInPath.accountIdentifier}/infraproviders/${paramsInPath.infraprovider_identifier}/resources`, - { base: getConfig('cde/api/v1'), pathParams: { accountIdentifier, infraprovider_identifier }, ...props } - ) - export interface GetCodeRepositoryPathParams { /** * account identifier. @@ -1401,7 +1312,7 @@ export const useGetInfraProvider = ({ } ) -export interface ListInfraProviderResourcesPathParams { +export interface CreateInfraProviderResourcePathParams { /** * account identifier. */ @@ -1420,47 +1331,49 @@ export interface ListInfraProviderResourcesPathParams { infraprovider_identifier: string } -export type ListInfraProviderResourcesProps = Omit< - GetProps, - 'path' +export type CreateInfraProviderResourceProps = Omit< + MutateProps, + 'path' | 'verb' > & - ListInfraProviderResourcesPathParams + CreateInfraProviderResourcePathParams /** - * List infraProvider Resources + * Create InfraProvider Resource */ -export const ListInfraProviderResources = ({ +export const CreateInfraProviderResource = ({ accountIdentifier, orgIdentifier, projectIdentifier, infraprovider_identifier, ...props -}: ListInfraProviderResourcesProps) => ( - +}: CreateInfraProviderResourceProps) => ( + + verb="POST" path={`/accounts/${accountIdentifier}/orgs/${orgIdentifier}/projects/${projectIdentifier}/infraproviders/${infraprovider_identifier}/resources`} base={getConfig('cde/api/v1')} {...props} /> ) -export type UseListInfraProviderResourcesProps = Omit< - UseGetProps, - 'path' +export type UseCreateInfraProviderResourceProps = Omit< + UseMutateProps, + 'path' | 'verb' > & - ListInfraProviderResourcesPathParams + CreateInfraProviderResourcePathParams /** - * List infraProvider Resources + * Create InfraProvider Resource */ -export const useListInfraProviderResources = ({ +export const useCreateInfraProviderResource = ({ accountIdentifier, orgIdentifier, projectIdentifier, infraprovider_identifier, ...props -}: UseListInfraProviderResourcesProps) => - useGet( - (paramsInPath: ListInfraProviderResourcesPathParams) => +}: UseCreateInfraProviderResourceProps) => + useMutate( + 'POST', + (paramsInPath: CreateInfraProviderResourcePathParams) => `/accounts/${paramsInPath.accountIdentifier}/orgs/${paramsInPath.orgIdentifier}/projects/${paramsInPath.projectIdentifier}/infraproviders/${paramsInPath.infraprovider_identifier}/resources`, { base: getConfig('cde/api/v1'), diff --git a/web/src/services/cde/swagger.yaml b/web/src/services/cde/swagger.yaml index 60f130686..cfb80beed 100644 --- a/web/src/services/cde/swagger.yaml +++ b/web/src/services/cde/swagger.yaml @@ -30,32 +30,6 @@ paths: summary: List gitspaces for account tags: - gitspaces - /accounts/{accountIdentifier}/infraproviders/{infraprovider_identifier}/resources: - get: - operationId: listInfraProviderResourcesForAccount - parameters: - - description: account identifier. - in: path - name: accountIdentifier - required: true - schema: - type: string - - description: infra Provider Config Identifier. - in: path - name: infraprovider_identifier - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/OpenapiListInfraProviderResourceResponse' - description: OK - summary: List infraProvider Resources - tags: - - infraproviderresources /accounts/{accountIdentifier}/orgs/{orgIdentifier}/projects/{projectIdentifier}/coderepository: post: operationId: getCodeRepository @@ -778,8 +752,8 @@ paths: tags: - infraproviders /accounts/{accountIdentifier}/orgs/{orgIdentifier}/projects/{projectIdentifier}/infraproviders/{infraprovider_identifier}/resources: - get: - operationId: listInfraProviderResources + post: + operationId: createInfraProviderResource parameters: - description: account identifier. in: path @@ -806,22 +780,19 @@ paths: schema: type: string responses: - '200': + '201': content: application/json: schema: - $ref: '#/components/schemas/OpenapiListInfraProviderResourceResponse' - description: OK - summary: List infraProvider Resources + items: + $ref: '#/components/schemas/TypesInfraProviderResourceType2' + type: array + description: Created + summary: Create InfraProvider Resource tags: - infraproviderresources components: schemas: - EnumCodeRepoAccessType: - enum: - - private - - public - type: string EnumCodeRepoType: enum: - github @@ -1022,14 +993,6 @@ components: type: $ref: '#/components/schemas/EnumInfraProviderType' type: object - OpenapiCreateInfraProviderResourceResponse: - properties: - resources: - items: - $ref: '#/components/schemas/TypesInfraProviderResourceRequest' - nullable: true - type: array - type: object OpenapiCreateInfraProviderResponse: properties: created: @@ -1091,11 +1054,11 @@ components: OpenapiGetCodeRepositoryResponse: properties: access_type: - $ref: '#/components/schemas/EnumCodeRepoAccessType' + $ref: '#/components/schemas/EnumGitspaceAccessType' branch: type: string repo_type: - $ref: '#/components/schemas/EnumCodeRepoType' + $ref: '#/components/schemas/EnumGitspaceCodeRepoType' url: type: string type: object @@ -1140,13 +1103,10 @@ components: action: $ref: '#/components/schemas/EnumGitspaceActionType' type: object - OpenapiListInfraProviderResourceResponse: - items: - $ref: '#/components/schemas/TypesInfraProviderResourceResponse' - nullable: true - type: array OpenapiLookupRepoGitspaceRequest: properties: + repo_type: + $ref: '#/components/schemas/EnumGitspaceCodeRepoType' space_ref: type: string url: @@ -1193,6 +1153,8 @@ components: properties: branch: type: string + code_repo_is_private: + type: boolean code_repo_ref: nullable: true type: string @@ -1223,6 +1185,10 @@ components: $ref: '#/components/schemas/EnumGitspaceStateType' updated: type: integer + user_display_name: + type: string + user_email: + type: string user_id: type: string type: object @@ -1281,6 +1247,9 @@ components: access_key: nullable: true type: string + access_key_ref: + nullable: true + type: string access_type: $ref: '#/components/schemas/EnumGitspaceAccessType' created: @@ -1380,76 +1349,7 @@ components: updated: type: integer type: object - TypesInfraProviderResourceRequest: - properties: - cpu: - type: string - disk: - type: string - gateway_host: - type: string - gateway_port: - type: string - id: - type: string - infra_provider_type: - $ref: '#/components/schemas/EnumProviderType' - memory: - type: string - name: - type: string - network: - type: string - opentofu_params: - additionalProperties: - type: string - nullable: true - type: object - region: - items: - type: string - nullable: true - type: array - template_id: - type: string - type: object - TypesInfraProviderResourceResponse: - properties: - cpu: - type: string - created: - type: integer - disk: - type: string - gateway_host: - type: string - gateway_port: - type: string - id: - type: string - infra_provider_config_id: - type: string - infra_provider_type: - $ref: '#/components/schemas/EnumProviderType' - memory: - type: string - name: - type: string - network: - type: string - opentofu_params: - additionalProperties: - type: string - nullable: true - type: object - region: - type: string - space_path: - type: string - template_id: - type: string - updated: - type: integer + TypesInfraProviderResourceType2: type: object UsererrorError: properties: