feat: [CDE-243]: add repo_type in repo lookup api (#2550)

* feat: [CDE-243]: add repo_type in repo lookup api
This commit is contained in:
Deepesh Kumar 2024-08-21 05:32:03 +00:00 committed by Harness
parent 57e7b7247c
commit dadac33e57
3 changed files with 52 additions and 239 deletions

View File

@ -38,7 +38,7 @@ export const CDEAnyGitImport = () => {
let errorMessage = '' let errorMessage = ''
try { try {
if (isValidUrl(url)) { if (isValidUrl(url)) {
const response = (await mutate({ url })) as { const response = (await mutate({ url, repo_type: EnumGitspaceCodeRepoType.UNKNOWN })) as {
is_private?: boolean is_private?: boolean
branch: string branch: string
url: string url: string

View File

@ -5,8 +5,6 @@ import { Get, GetProps, useGet, UseGetProps, Mutate, MutateProps, useMutate, Use
import { getConfig } from '../config' import { getConfig } from '../config'
export const SPEC_VERSION = '0.0.0' export const SPEC_VERSION = '0.0.0'
export type EnumCodeRepoAccessType = 'private' | 'public'
export type EnumCodeRepoType = 'github' | 'gitlab' | 'harnessCode' | 'bitbucket' | 'unknown' export type EnumCodeRepoType = 'github' | 'gitlab' | 'harnessCode' | 'bitbucket' | 'unknown'
export type EnumGitspaceAccessType = 'jwt_token' | 'user_credentials' | 'ssh_key' export type EnumGitspaceAccessType = 'jwt_token' | 'user_credentials' | 'ssh_key'
@ -103,10 +101,6 @@ export interface OpenapiCreateInfraProviderConfigRequest {
type?: EnumInfraProviderType type?: EnumInfraProviderType
} }
export interface OpenapiCreateInfraProviderResourceResponse {
resources?: TypesInfraProviderResourceRequest[] | null
}
export interface OpenapiCreateInfraProviderResponse { export interface OpenapiCreateInfraProviderResponse {
created?: number created?: number
id?: string id?: string
@ -143,9 +137,9 @@ export interface OpenapiGetCodeRepositoryRequest {
} }
export interface OpenapiGetCodeRepositoryResponse { export interface OpenapiGetCodeRepositoryResponse {
access_type?: EnumCodeRepoAccessType access_type?: EnumGitspaceAccessType
branch?: string branch?: string
repo_type?: EnumCodeRepoType repo_type?: EnumGitspaceCodeRepoType
url?: string url?: string
} }
@ -174,9 +168,8 @@ export interface OpenapiGitspaceActionRequest {
action?: EnumGitspaceActionType action?: EnumGitspaceActionType
} }
export type OpenapiListInfraProviderResourceResponse = TypesInfraProviderResourceResponse[] | null
export interface OpenapiLookupRepoGitspaceRequest { export interface OpenapiLookupRepoGitspaceRequest {
repo_type?: EnumGitspaceCodeRepoType
space_ref?: string space_ref?: string
url?: string url?: string
} }
@ -205,6 +198,7 @@ export interface ScmCodeRepositoryResponse {
export interface TypesGitspaceConfig { export interface TypesGitspaceConfig {
branch?: string branch?: string
code_repo_is_private?: boolean
code_repo_ref?: string | null code_repo_ref?: string | null
code_repo_type?: EnumGitspaceCodeRepoType code_repo_type?: EnumGitspaceCodeRepoType
code_repo_url?: string code_repo_url?: string
@ -219,6 +213,8 @@ export interface TypesGitspaceConfig {
ssh_token_identifier?: string ssh_token_identifier?: string
state?: EnumGitspaceStateType state?: EnumGitspaceStateType
updated?: number updated?: number
user_display_name?: string
user_email?: string
user_id?: string user_id?: string
} }
@ -252,6 +248,7 @@ export interface TypesGitspaceEventResponse {
export interface TypesGitspaceInstance { export interface TypesGitspaceInstance {
access_key?: string | null access_key?: string | null
access_key_ref?: string | null
access_type?: EnumGitspaceAccessType access_type?: EnumGitspaceAccessType
created?: number created?: number
identifier?: string identifier?: string
@ -300,42 +297,8 @@ export interface TypesInfraProviderResource {
updated?: number updated?: number
} }
export interface TypesInfraProviderResourceRequest { export interface TypesInfraProviderResourceType2 {
cpu?: string [key: string]: any
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 UsererrorError { export interface UsererrorError {
@ -382,58 +345,6 @@ export const useListGitspacesForAccount = ({ accountIdentifier, ...props }: UseL
{ base: getConfig('cde/api/v1'), pathParams: { accountIdentifier }, ...props } { 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<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesForAccountPathParams>,
'path'
> &
ListInfraProviderResourcesForAccountPathParams
/**
* List infraProvider Resources
*/
export const ListInfraProviderResourcesForAccount = ({
accountIdentifier,
infraprovider_identifier,
...props
}: ListInfraProviderResourcesForAccountProps) => (
<Get<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesForAccountPathParams>
path={`/accounts/${accountIdentifier}/infraproviders/${infraprovider_identifier}/resources`}
base={getConfig('cde/api/v1')}
{...props}
/>
)
export type UseListInfraProviderResourcesForAccountProps = Omit<
UseGetProps<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesForAccountPathParams>,
'path'
> &
ListInfraProviderResourcesForAccountPathParams
/**
* List infraProvider Resources
*/
export const useListInfraProviderResourcesForAccount = ({
accountIdentifier,
infraprovider_identifier,
...props
}: UseListInfraProviderResourcesForAccountProps) =>
useGet<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesForAccountPathParams>(
(paramsInPath: ListInfraProviderResourcesForAccountPathParams) =>
`/accounts/${paramsInPath.accountIdentifier}/infraproviders/${paramsInPath.infraprovider_identifier}/resources`,
{ base: getConfig('cde/api/v1'), pathParams: { accountIdentifier, infraprovider_identifier }, ...props }
)
export interface GetCodeRepositoryPathParams { export interface GetCodeRepositoryPathParams {
/** /**
* account identifier. * account identifier.
@ -1401,7 +1312,7 @@ export const useGetInfraProvider = ({
} }
) )
export interface ListInfraProviderResourcesPathParams { export interface CreateInfraProviderResourcePathParams {
/** /**
* account identifier. * account identifier.
*/ */
@ -1420,47 +1331,49 @@ export interface ListInfraProviderResourcesPathParams {
infraprovider_identifier: string infraprovider_identifier: string
} }
export type ListInfraProviderResourcesProps = Omit< export type CreateInfraProviderResourceProps = Omit<
GetProps<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesPathParams>, MutateProps<TypesInfraProviderResourceType2[], unknown, void, void, CreateInfraProviderResourcePathParams>,
'path' 'path' | 'verb'
> & > &
ListInfraProviderResourcesPathParams CreateInfraProviderResourcePathParams
/** /**
* List infraProvider Resources * Create InfraProvider Resource
*/ */
export const ListInfraProviderResources = ({ export const CreateInfraProviderResource = ({
accountIdentifier, accountIdentifier,
orgIdentifier, orgIdentifier,
projectIdentifier, projectIdentifier,
infraprovider_identifier, infraprovider_identifier,
...props ...props
}: ListInfraProviderResourcesProps) => ( }: CreateInfraProviderResourceProps) => (
<Get<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesPathParams> <Mutate<TypesInfraProviderResourceType2[], unknown, void, void, CreateInfraProviderResourcePathParams>
verb="POST"
path={`/accounts/${accountIdentifier}/orgs/${orgIdentifier}/projects/${projectIdentifier}/infraproviders/${infraprovider_identifier}/resources`} path={`/accounts/${accountIdentifier}/orgs/${orgIdentifier}/projects/${projectIdentifier}/infraproviders/${infraprovider_identifier}/resources`}
base={getConfig('cde/api/v1')} base={getConfig('cde/api/v1')}
{...props} {...props}
/> />
) )
export type UseListInfraProviderResourcesProps = Omit< export type UseCreateInfraProviderResourceProps = Omit<
UseGetProps<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesPathParams>, UseMutateProps<TypesInfraProviderResourceType2[], unknown, void, void, CreateInfraProviderResourcePathParams>,
'path' 'path' | 'verb'
> & > &
ListInfraProviderResourcesPathParams CreateInfraProviderResourcePathParams
/** /**
* List infraProvider Resources * Create InfraProvider Resource
*/ */
export const useListInfraProviderResources = ({ export const useCreateInfraProviderResource = ({
accountIdentifier, accountIdentifier,
orgIdentifier, orgIdentifier,
projectIdentifier, projectIdentifier,
infraprovider_identifier, infraprovider_identifier,
...props ...props
}: UseListInfraProviderResourcesProps) => }: UseCreateInfraProviderResourceProps) =>
useGet<OpenapiListInfraProviderResourceResponse, unknown, void, ListInfraProviderResourcesPathParams>( useMutate<TypesInfraProviderResourceType2[], unknown, void, void, CreateInfraProviderResourcePathParams>(
(paramsInPath: ListInfraProviderResourcesPathParams) => 'POST',
(paramsInPath: CreateInfraProviderResourcePathParams) =>
`/accounts/${paramsInPath.accountIdentifier}/orgs/${paramsInPath.orgIdentifier}/projects/${paramsInPath.projectIdentifier}/infraproviders/${paramsInPath.infraprovider_identifier}/resources`, `/accounts/${paramsInPath.accountIdentifier}/orgs/${paramsInPath.orgIdentifier}/projects/${paramsInPath.projectIdentifier}/infraproviders/${paramsInPath.infraprovider_identifier}/resources`,
{ {
base: getConfig('cde/api/v1'), base: getConfig('cde/api/v1'),

View File

@ -30,32 +30,6 @@ paths:
summary: List gitspaces for account summary: List gitspaces for account
tags: tags:
- gitspaces - 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: /accounts/{accountIdentifier}/orgs/{orgIdentifier}/projects/{projectIdentifier}/coderepository:
post: post:
operationId: getCodeRepository operationId: getCodeRepository
@ -778,8 +752,8 @@ paths:
tags: tags:
- infraproviders - infraproviders
/accounts/{accountIdentifier}/orgs/{orgIdentifier}/projects/{projectIdentifier}/infraproviders/{infraprovider_identifier}/resources: /accounts/{accountIdentifier}/orgs/{orgIdentifier}/projects/{projectIdentifier}/infraproviders/{infraprovider_identifier}/resources:
get: post:
operationId: listInfraProviderResources operationId: createInfraProviderResource
parameters: parameters:
- description: account identifier. - description: account identifier.
in: path in: path
@ -806,22 +780,19 @@ paths:
schema: schema:
type: string type: string
responses: responses:
'200': '201':
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/OpenapiListInfraProviderResourceResponse' items:
description: OK $ref: '#/components/schemas/TypesInfraProviderResourceType2'
summary: List infraProvider Resources type: array
description: Created
summary: Create InfraProvider Resource
tags: tags:
- infraproviderresources - infraproviderresources
components: components:
schemas: schemas:
EnumCodeRepoAccessType:
enum:
- private
- public
type: string
EnumCodeRepoType: EnumCodeRepoType:
enum: enum:
- github - github
@ -1022,14 +993,6 @@ components:
type: type:
$ref: '#/components/schemas/EnumInfraProviderType' $ref: '#/components/schemas/EnumInfraProviderType'
type: object type: object
OpenapiCreateInfraProviderResourceResponse:
properties:
resources:
items:
$ref: '#/components/schemas/TypesInfraProviderResourceRequest'
nullable: true
type: array
type: object
OpenapiCreateInfraProviderResponse: OpenapiCreateInfraProviderResponse:
properties: properties:
created: created:
@ -1091,11 +1054,11 @@ components:
OpenapiGetCodeRepositoryResponse: OpenapiGetCodeRepositoryResponse:
properties: properties:
access_type: access_type:
$ref: '#/components/schemas/EnumCodeRepoAccessType' $ref: '#/components/schemas/EnumGitspaceAccessType'
branch: branch:
type: string type: string
repo_type: repo_type:
$ref: '#/components/schemas/EnumCodeRepoType' $ref: '#/components/schemas/EnumGitspaceCodeRepoType'
url: url:
type: string type: string
type: object type: object
@ -1140,13 +1103,10 @@ components:
action: action:
$ref: '#/components/schemas/EnumGitspaceActionType' $ref: '#/components/schemas/EnumGitspaceActionType'
type: object type: object
OpenapiListInfraProviderResourceResponse:
items:
$ref: '#/components/schemas/TypesInfraProviderResourceResponse'
nullable: true
type: array
OpenapiLookupRepoGitspaceRequest: OpenapiLookupRepoGitspaceRequest:
properties: properties:
repo_type:
$ref: '#/components/schemas/EnumGitspaceCodeRepoType'
space_ref: space_ref:
type: string type: string
url: url:
@ -1193,6 +1153,8 @@ components:
properties: properties:
branch: branch:
type: string type: string
code_repo_is_private:
type: boolean
code_repo_ref: code_repo_ref:
nullable: true nullable: true
type: string type: string
@ -1223,6 +1185,10 @@ components:
$ref: '#/components/schemas/EnumGitspaceStateType' $ref: '#/components/schemas/EnumGitspaceStateType'
updated: updated:
type: integer type: integer
user_display_name:
type: string
user_email:
type: string
user_id: user_id:
type: string type: string
type: object type: object
@ -1281,6 +1247,9 @@ components:
access_key: access_key:
nullable: true nullable: true
type: string type: string
access_key_ref:
nullable: true
type: string
access_type: access_type:
$ref: '#/components/schemas/EnumGitspaceAccessType' $ref: '#/components/schemas/EnumGitspaceAccessType'
created: created:
@ -1380,76 +1349,7 @@ components:
updated: updated:
type: integer type: integer
type: object type: object
TypesInfraProviderResourceRequest: TypesInfraProviderResourceType2:
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
type: object type: object
UsererrorError: UsererrorError:
properties: properties: