diff --git a/web/config/webpack.common.js b/web/config/webpack.common.js index d3fba8a8b..6f14de945 100644 --- a/web/config/webpack.common.js +++ b/web/config/webpack.common.js @@ -30,6 +30,7 @@ const moduleFederationConfig = require('./moduleFederation.config') const moduleFederationConfigCDE = require('./cde/moduleFederation.config') const CONTEXT = process.cwd() const DEV = process.env.NODE_ENV === 'development' +const ENABLE_GITSPACE = process.env.ENABLE_GITSPACE === 'true' const getModuleFields = () => { if (process.env.MODULE === 'cde') { @@ -223,7 +224,8 @@ module.exports = { moduleFederationPlugin, new DefinePlugin({ 'process.env': '{}', // required for @blueprintjs/core - __DEV__: DEV + __DEV__: DEV, + __ENABLE_GITSPACE__: ENABLE_GITSPACE }), new GenerateStringTypesPlugin(), new RetryChunkLoadPlugin({ diff --git a/web/config/webpack.dev.js b/web/config/webpack.dev.js index cd1a2c11b..27fb17e76 100644 --- a/web/config/webpack.dev.js +++ b/web/config/webpack.dev.js @@ -34,12 +34,13 @@ const API_URL = process.env.API_URL ?? 'http://localhost:3000' const HOST = 'localhost' const PORT = getPortByModule() const STANDALONE = process.env.STANDALONE === 'true' +const ENABLE_GITSPACE = process.env.ENABLE_GITSPACE === 'true' const CONTEXT = process.cwd() const prodConfig = require('./webpack.prod') console.info(`Starting development build... http://${HOST}:${PORT}`) console.info('Environment variables:') -console.table({ STANDALONE, HOST, PORT, API_URL }) +console.table({ STANDALONE, ENABLE_GITSPACE, HOST, PORT, API_URL }) const devConfig = { mode: 'development', diff --git a/web/package.json b/web/package.json index 7d470b875..38a8584ad 100644 --- a/web/package.json +++ b/web/package.json @@ -19,12 +19,12 @@ "webpack:cde": "NODE_ENV=development MODULE=cde webpack serve --config config/webpack.dev.js", "typed-scss": "typed-scss-modules src --watch", "dev": "run-p webpack typed-scss", - "dev:cde": "MODULE=cde run-p webpack:cde typed-scss", + "dev:cde": "MODULE=cde ENABLE_GITSPACE=true run-p webpack:cde typed-scss", "test": "jest src --silent", "test:watch": "jest --watch", "build": "rm -rf dist && webpack --config config/webpack.prod.js", - "build:cde": "rm -rf dist && MODULE=cde webpack --config config/webpack.prod.js", - "lint": "eslint --rulesdir ./scripts/eslint-rules --ext .ts --ext .tsx src", + "build:cde": "rm -rf dist && MODULE=cde ENABLE_GITSPACE=true webpack --config config/webpack.prod.js", + "lint": "eslint --fix --rulesdir ./scripts/eslint-rules --ext .ts --ext .tsx src", "prettier": "prettier --check \"./src/**/*.{ts,tsx,css,scss}\"", "coverage": "npm test --coverage", "typecheck": "tsc", @@ -47,7 +47,7 @@ "@codemirror/state": "^6.2.0", "@codemirror/view": "^6.9.6", "@harnessio/design-system": "^2.1.1", - "@harnessio/icons": "^2.1.3", + "@harnessio/icons": "^2.1.5", "@harnessio/uicore": "^4.1.2", "@types/dompurify": "^3.0.2", "@types/react-monaco-editor": "^0.16.0", diff --git a/web/src/RouteDestinations.tsx b/web/src/RouteDestinations.tsx index 57eac4cf6..ad5cf7228 100644 --- a/web/src/RouteDestinations.tsx +++ b/web/src/RouteDestinations.tsx @@ -51,7 +51,7 @@ import CodeSearchPage from 'pages/Search/CodeSearchPage' import AddUpdatePipeline from 'pages/AddUpdatePipeline/AddUpdatePipeline' import { useAppContext } from 'AppContext' import PipelineSettings from 'components/PipelineSettings/PipelineSettings' -import GitspaceDetail from 'cde/pages/GitspaceDetail/GitspaceDetail' +import { GitspaceDetails } from 'cde-gitness/pages/GitspaceDetails/GitspaceDetails' import { GitspaceListing } from 'cde-gitness/pages/GitspaceListing/GitspaceListing' import { GitspaceCreate } from 'cde-gitness/pages/GitspaceCreate/GitspaceCreate' @@ -283,7 +283,7 @@ export const RouteDestinations: React.FC = React.memo(function RouteDestinations {standalone && ( - + )} diff --git a/web/src/cde-gitness/assests/banner.svg b/web/src/cde-gitness/assests/banner.svg new file mode 100644 index 000000000..54fd00d48 --- /dev/null +++ b/web/src/cde-gitness/assests/banner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/bannerLower.svg b/web/src/cde-gitness/assests/bannerLower.svg new file mode 100644 index 000000000..845b45002 --- /dev/null +++ b/web/src/cde-gitness/assests/bannerLower.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/delete.svg b/web/src/cde-gitness/assests/delete.svg new file mode 100644 index 000000000..c75abe701 --- /dev/null +++ b/web/src/cde-gitness/assests/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/components/GitnessRepoImportForm/gitness.svg b/web/src/cde-gitness/assests/gitness.svg similarity index 100% rename from web/src/cde-gitness/components/GitnessRepoImportForm/gitness.svg rename to web/src/cde-gitness/assests/gitness.svg diff --git a/web/src/cde-gitness/assests/gitspace.svg b/web/src/cde-gitness/assests/gitspace.svg new file mode 100644 index 000000000..bcd220c72 --- /dev/null +++ b/web/src/cde-gitness/assests/gitspace.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/home.svg b/web/src/cde-gitness/assests/home.svg new file mode 100644 index 000000000..483b1a739 --- /dev/null +++ b/web/src/cde-gitness/assests/home.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/noRepo.svg b/web/src/cde-gitness/assests/noRepo.svg new file mode 100644 index 000000000..cc9e134ac --- /dev/null +++ b/web/src/cde-gitness/assests/noRepo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/pause.svg b/web/src/cde-gitness/assests/pause.svg new file mode 100644 index 000000000..3f934e761 --- /dev/null +++ b/web/src/cde-gitness/assests/pause.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/textLeft.svg b/web/src/cde-gitness/assests/textLeft.svg new file mode 100644 index 000000000..011d1307b --- /dev/null +++ b/web/src/cde-gitness/assests/textLeft.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/assests/web.svg b/web/src/cde-gitness/assests/web.svg new file mode 100644 index 000000000..6ef4455ab --- /dev/null +++ b/web/src/cde-gitness/assests/web.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss new file mode 100644 index 000000000..4960a9395 --- /dev/null +++ b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss @@ -0,0 +1,92 @@ +/* + * Copyright 2023 Harness, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import 'src/utils/utils'; + +.consoleContainer { + min-height: 500px !important; + max-height: 70vh !important; + overflow: scroll; + align-items: start !important; + padding-top: var(--spacing-large) !important; + padding-left: var(--spacing-xlarge) !important; + background-color: var(--black) !important; + color: var(--white) !important; + pre { + background-color: var(--black) !important; + color: var(--white) !important; + text-align: start !important; + font-size: 12px; + font-family: var(--font-family-mono) !important; + } +} + +.logTitle { + color: var(--white) !important; + background: var(--black) !important; + border-top-left-radius: 50px; + border-top-right-radius: 50px; + padding-top: var(--spacing-medium) !important; + text-align: left; + padding-left: var(--spacing-xxlarge) !important; + padding-bottom: var(--spacing-large) !important; + font-size: 16px !important; +} + +.mainLog { + flex-shrink: 0; + + .line { + margin: 0; + padding: 0; + cursor: text; + min-height: 20px; + display: block; + + @include mono-font; + color: var(--white); + + word-wrap: break-word !important; + white-space: pre-wrap !important; + } +} + +.stepLogContainer { + padding: var(--spacing-small) !important; + flex-shrink: 0; + + .consoleLine { + color: var(--white); + + @include mono-font; + + word-wrap: break-word !important; + white-space: pre-wrap !important; + cursor: text; + margin: 0; + padding: 0; + + &:empty { + display: inline-block; + min-height: 20px; + } + } +} + +.logContainer { + width: 60%; + max-width: 800px !important; +} diff --git a/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss.d.ts b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss.d.ts new file mode 100644 index 000000000..0e2cecda3 --- /dev/null +++ b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.module.scss.d.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2023 Harness, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +// This is an auto-generated file +export declare const consoleContainer: string +export declare const consoleLine: string +export declare const line: string +export declare const logContainer: string +export declare const logTitle: string +export declare const mainLog: string +export declare const stepLogContainer: string diff --git a/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.tsx b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.tsx new file mode 100644 index 000000000..d9d13b2d8 --- /dev/null +++ b/web/src/cde-gitness/components/ContainerLogs/ContainerLogs.tsx @@ -0,0 +1,52 @@ +import { Container } from '@harnessio/uicore' +import cx from 'classnames' +import React, { useEffect, useRef } from 'react' +import { lineElement } from 'components/LogViewer/LogViewer' +import type { LogData } from '../../hooks/useGetLogStream' +import css from './ContainerLogs.module.scss' + +const ContainerLogs = ({ data }: { data: LogData[] }) => { + const localRef = useRef() + + useEffect(() => { + try { + if (data) { + const fragment = new DocumentFragment() + const logContainer = localRef.current as HTMLDivElement + // Clear the container first + if (localRef.current) { + localRef.current.innerHTML = '' + } + if (data) { + data?.forEach((line: any) => { + const linePos = line.pos + 1 + const localDate = new Date(line.time) + // Format date to a more readable format (local time) + const formattedDate = localDate.toLocaleString() + fragment.appendChild(lineElement(`${linePos} ${formattedDate.replace(',', '')} ${line.out}`)) + }) + + logContainer.appendChild(fragment) + } + + const scrollParent = logContainer.parentElement as HTMLDivElement + const autoScroll = + scrollParent && scrollParent.scrollTop === scrollParent.scrollHeight - scrollParent.offsetHeight + + if (autoScroll || scrollParent.scrollTop === 0) { + scrollParent.scrollTop = scrollParent.scrollHeight + } + } + } catch (_err) { + // + } + }, [data]) + + return ( + + + + ) +} + +export default ContainerLogs diff --git a/web/src/cde-gitness/components/DetailsCard/DetailsCard.tsx b/web/src/cde-gitness/components/DetailsCard/DetailsCard.tsx new file mode 100644 index 000000000..76e54e9ec --- /dev/null +++ b/web/src/cde-gitness/components/DetailsCard/DetailsCard.tsx @@ -0,0 +1,89 @@ +import { Color } from '@harnessio/design-system' +import { Layout, Text } from '@harnessio/uicore' +import React from 'react' +import ReactTimeago from 'react-timeago' +import { Circle } from 'iconoir-react' +import type { IconName } from '@harnessio/icons' +import { useStrings } from 'framework/strings' +import { getIconByRepoType } from 'cde/components/CreateGitspace/components/SelectRepository/SelectRepository.utils' +import type { TypesGitspaceConfig } from 'cde-gitness/services' +import { GitspaceStatus } from 'cde/constants' +import { getStatusColor, getStatusText } from '../GitspaceListing/ListGitspaces' + +export const DetailsCard = ({ data }: { data: TypesGitspaceConfig | null; loading?: boolean }) => { + const { getString } = useStrings() + const { branch, state, name, code_repo_url, code_repo_type, instance } = data || {} + const color = getStatusColor(state) + const customProps = + state === GitspaceStatus.STARTING + ? { + icon: 'loading' as IconName, + iconProps: { color: Color.PRIMARY_4 } + } + : { icon: undefined } + return ( + <> + + + {getString('cde.status')} + + {state !== GitspaceStatus.STARTING && } + + {getStatusText(getString, state)} + + + + + + {getString('cde.repository.repo')} + { + e.preventDefault() + e.stopPropagation() + }}> + {getIconByRepoType({ repoType: code_repo_type, height: 20 })} + window.open(code_repo_url, '_blank')}> + {name} + + + + + + {getString('branch')} + window.open(code_repo_url, '_blank')}> + {branch} + + + + + {getString('cde.lastUsed')} + {instance?.last_used ? ( + + ) : ( + {getString('cde.na')} + )} + + + + ) +} diff --git a/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss b/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss new file mode 100644 index 000000000..144159ae7 --- /dev/null +++ b/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss @@ -0,0 +1,23 @@ +.marker { + align-self: center; + position: relative; + left: 5.5px; + height: 12px; + width: 12px; + background: var(--grey-400) !important; + border-radius: 6px; + padding: 2px; + border: 2px solid #fff; +} + +.main { + overflow: scroll; + max-height: 350px; +} + +.lightBackground { + background: #dee8f9 !important; +} +.darkBackground { + background: #bbd1f6 !important; +} diff --git a/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss.d.ts b/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss.d.ts new file mode 100644 index 000000000..fc4dcd62e --- /dev/null +++ b/web/src/cde-gitness/components/EventTimeline/EventTimeline.module.scss.d.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 Harness, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +// This is an auto-generated file +export declare const darkBackground: string +export declare const lightBackground: string +export declare const main: string +export declare const marker: string diff --git a/web/src/cde-gitness/components/EventTimeline/EventTimeline.tsx b/web/src/cde-gitness/components/EventTimeline/EventTimeline.tsx new file mode 100644 index 000000000..cf29db3f1 --- /dev/null +++ b/web/src/cde-gitness/components/EventTimeline/EventTimeline.tsx @@ -0,0 +1,80 @@ +import React, { useEffect, useRef, useState } from 'react' +import { Color } from '@harnessio/design-system' +import { Container, Text, Layout } from '@harnessio/uicore' +import { isArray, isEqual } from 'lodash-es' +import type { TypesGitspaceEventResponse } from 'cde-gitness/services' +import { useStrings } from 'framework/strings' +import { formatTimestamp } from './EventTimeline.utils' +import css from './EventTimeline.module.scss' + +const EventTimeline = ({ data }: { data?: TypesGitspaceEventResponse[] | null; polling?: boolean }) => { + const localRef = useRef(null) + const scrollContainerRef = useRef(null) + + const { getString } = useStrings() + const [cache, setCache] = useState(data) + + useEffect(() => { + if (!isEqual(data, cache)) { + setCache(data) + } + }, [data]) + + useEffect(() => { + if (scrollContainerRef.current) { + const scrollParent = scrollContainerRef.current + + const autoScroll = scrollParent.scrollTop <= scrollParent.scrollHeight - scrollParent.clientHeight + + if (autoScroll || scrollParent.scrollTop === 0) { + scrollParent.scrollTop = scrollParent.scrollHeight + } + } + }, [cache]) + + return ( + + {!data?.length && isArray(data) && ( + + + {getString('cde.details.fetchingDetails')} + + + )} + + {data?.map((item, index) => { + return ( + + + {formatTimestamp(item.timestamp || 0)} + + + + + {`${item.message}`} + + + + ) + })} + + + ) +} + +export default EventTimeline diff --git a/web/src/cde-gitness/components/EventTimeline/EventTimeline.utils.tsx b/web/src/cde-gitness/components/EventTimeline/EventTimeline.utils.tsx new file mode 100644 index 000000000..54107519c --- /dev/null +++ b/web/src/cde-gitness/components/EventTimeline/EventTimeline.utils.tsx @@ -0,0 +1,28 @@ +import React from 'react' +import moment from 'moment' +import { Text, Layout } from '@harnessio/uicore' +import { Color } from '@harnessio/design-system' + +export const formatTimestamp = (timestamp: number) => { + const inputDate = moment(timestamp) + const currentDate = moment() + + if (inputDate.isSame(currentDate, 'day')) { + return ( + + {inputDate.format('HH:mm:ss')} + + ) + } else { + return ( + + + {inputDate.format('YYYY-MM-DD')} + + + {inputDate.format('HH:mm:ss')} + + + ) + } +} diff --git a/web/src/cde-gitness/components/EventTimelineAccordion/EventTimelineAccordion.tsx b/web/src/cde-gitness/components/EventTimelineAccordion/EventTimelineAccordion.tsx new file mode 100644 index 000000000..c4954c381 --- /dev/null +++ b/web/src/cde-gitness/components/EventTimelineAccordion/EventTimelineAccordion.tsx @@ -0,0 +1,25 @@ +import React from 'react' +import { defaultTo } from 'lodash-es' +import { Accordion } from '@harnessio/uicore' +import type { TypesGitspaceEventResponse } from 'cde-gitness/services' +import EventTimelineSummary from '../EventTimelineSummary/EventTimelineSummary' +import EventTimeline from '../EventTimeline/EventTimeline' +import parentCss from 'cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss' + +const EventTimelineAccordion = ({ data }: { data: TypesGitspaceEventResponse[] | null; polling?: boolean }) => { + const sortedData = data?.sort((a, b) => defaultTo(a?.timestamp, 0) - defaultTo(b?.timestamp, 0)) + const latestEvent = sortedData?.[sortedData?.length - 1] || { message: '', timestamp: 0 } + return ( + + } + summary={} + className={parentCss.accordionnCustomSummary} + /> + + ) +} + +export default EventTimelineAccordion diff --git a/web/src/cde-gitness/components/EventTimelineSummary/EventTimelineSummary.tsx b/web/src/cde-gitness/components/EventTimelineSummary/EventTimelineSummary.tsx new file mode 100644 index 000000000..3b74d86d6 --- /dev/null +++ b/web/src/cde-gitness/components/EventTimelineSummary/EventTimelineSummary.tsx @@ -0,0 +1,28 @@ +import React from 'react' +import moment from 'moment' +import { Container, Text, Layout } from '@harnessio/uicore' +import { Color, FontVariation } from '@harnessio/design-system' +import { useStrings } from 'framework/strings' + +const EventTimelineSummary = ({ timestamp, message }: { timestamp?: number; message?: string }) => { + const { getString } = useStrings() + return ( + + + {getString('cde.details.gitspaceActivity')} + + {Boolean(message) && ( + + + {message} + + + {moment(timestamp).format('DD MMM, YYYY hh:mma')} + + + )} + + ) +} + +export default EventTimelineSummary diff --git a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss index 86a082562..7e4395073 100644 --- a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss +++ b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss @@ -1,3 +1,8 @@ .repoAndBranch { margin-bottom: 0 !important; } + +.noReposContainer { + padding: var(--spacing-large) !important; + background-color: var(--grey-50) !important; +} diff --git a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss.d.ts b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss.d.ts index ebc423548..9836ccf91 100644 --- a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss.d.ts +++ b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.module.scss.d.ts @@ -16,4 +16,5 @@ /* eslint-disable */ // This is an auto-generated file +export declare const noReposContainer: string export declare const repoAndBranch: string diff --git a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.tsx b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.tsx index 705fa5238..df206cb2e 100644 --- a/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.tsx +++ b/web/src/cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import { useGet } from 'restful-react' -import { Container, ExpandingSearchInput, Layout, Text } from '@harnessio/uicore' +import { Button, ButtonVariation, Container, ExpandingSearchInput, Layout, Text } from '@harnessio/uicore' import { Menu, MenuItem } from '@blueprintjs/core' import { Color } from '@harnessio/design-system' import { Icon } from '@harnessio/icons' @@ -10,8 +10,10 @@ import { useGetSpaceParam } from 'hooks/useGetSpaceParam' import { String, useStrings } from 'framework/strings' import { LIST_FETCHING_LIMIT } from 'utils/Utils' import NewRepoModalButton from 'components/NewRepoModalButton/NewRepoModalButton' +import noRepo from 'cde-gitness/assests/noRepo.svg?url' +import { RepoCreationType } from 'utils/GitUtils' +import gitnessRepoLogo from 'cde-gitness/assests/gitness.svg?url' import { GitspaceSelect } from '../../../cde/components/GitspaceSelect/GitspaceSelect' -import gitnessRepoLogo from './gitness.svg?url' import css from './GitnessRepoImportForm.module.scss' const RepositoryText = ({ repoList, value }: { repoList: TypesRepository[] | null; value?: string }) => { @@ -64,6 +66,7 @@ export const GitnessRepoImportForm = () => { const space = useGetSpaceParam() const [branchSearch, setBranchSearch] = useState('') const [repoSearch, setRepoSearch] = useState('') + const [hadReops, setHadRepos] = useState(false) const [repoRef, setReporef] = useState('') const { @@ -76,6 +79,12 @@ export const GitnessRepoImportForm = () => { debounce: 500 }) + useEffect(() => { + if (!hadReops && repositories?.length) { + setHadRepos(true) + } + }, [repositories]) + const { data: branches, refetch, @@ -100,6 +109,7 @@ export const GitnessRepoImportForm = () => { }, [repoRef, branchSearch]) const repoListOptions = repositories || [] + const hideInitialMenu = Boolean(repoSearch) || Boolean(repositories) const formik = useFormikContext() @@ -124,15 +134,17 @@ export const GitnessRepoImportForm = () => { }} renderMenu={ - - - + {hideInitialMenu && ( + + + + )} {loading ? ( ) : repoListOptions?.length ? ( @@ -147,11 +159,12 @@ export const GitnessRepoImportForm = () => { } active={repo.git_url === values.code_repo_url} onClick={() => { + const repoParams = repo?.path?.split('/') || [] formik.setValues((prvValues: any) => { return { ...prvValues, code_repo_url: repo.git_url, - id: repo.path, + identifier: repoParams?.[repoParams.length - 1], name: repo.path } }) @@ -159,18 +172,69 @@ export const GitnessRepoImportForm = () => { }} /> )) - ) : ( + ) : hideInitialMenu ? ( ( + } + onClick={fn} + /> + )} modalTitle={getString('createRepo')} onSubmit={() => { refetchRepos() }} /> + ) : !hadReops ? ( + + + + + + {getString('cde.getStarted')} + + + {getString('cde.createImport')} + + + ( + + )} + modalTitle={getString('newRepo')} + onSubmit={() => { + refetchRepos() + }} + /> + ( + + )} + modalTitle={getString('importGitRepo')} + onSubmit={() => { + refetchRepos() + }} + /> + + + ) : ( + )} } diff --git a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss index 5f4c5b721..13963188d 100644 --- a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss +++ b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss @@ -34,6 +34,7 @@ } .listContainer { + border-radius: 20px !important; :global { a.bp3-menu-item:hover, .bp3-active { @@ -52,4 +53,18 @@ .repositoryCell { width: fit-content !important; + margin-right: var(--spacing-xxlarge) !important; +} + +.stopModal { + width: 650px !important; + [class*='ConfirmationDialog--body'] { + margin-bottom: 0px !important; + } + span[data-icon='info-messaging'] { + display: none; + } + svg { + fill: #004ba4; + } } diff --git a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss.d.ts b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss.d.ts index 7b5539a28..b3004fd2b 100644 --- a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss.d.ts +++ b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.module.scss.d.ts @@ -20,4 +20,5 @@ export declare const gitspaceUrl: string export declare const listContainer: string export declare const popover: string export declare const repositoryCell: string +export declare const stopModal: string export declare const table: string diff --git a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.tsx b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.tsx index 9f14e7509..ebb0e331c 100644 --- a/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.tsx +++ b/web/src/cde-gitness/components/GitspaceListing/ListGitspaces.tsx @@ -14,45 +14,55 @@ * limitations under the License. */ -import { Container, Layout, TableV2, Text, useToaster } from '@harnessio/uicore' -import React from 'react' +import { + ConfirmationDialog, + Container, + Layout, + TableV2, + Text, + useToaster, + Button, + ButtonVariation +} from '@harnessio/uicore' +import React, { useEffect, useState } from 'react' import { Color } from '@harnessio/design-system' import type { Renderer, CellProps } from 'react-table' import ReactTimeago from 'react-timeago' import { Circle, - GitBranch, Cpu, Clock, Play, - Square, Db, ModernTv, - OpenInBrowser, - DeleteCircle, - EditPencil, - ViewColumns2, GithubCircle, GitLabFull, Code, Bitbucket as BitbucketIcon } from 'iconoir-react' -import { Menu, MenuItem, PopoverInteractionKind, Position } from '@blueprintjs/core' +import { Intent, Menu, MenuItem, PopoverInteractionKind, Position } from '@blueprintjs/core' import { useHistory } from 'react-router-dom' import { isNil } from 'lodash-es' +import { useMutate } from 'restful-react' +import type { IconName } from '@harnessio/icons' import { UseStringsReturn, useStrings } from 'framework/strings' import { useAppContext } from 'AppContext' import { getErrorMessage } from 'utils/Utils' import { useConfirmAct } from 'hooks/useConfirmAction' import VSCode from 'cde/icons/VSCode.svg?url' -import { GitspaceStatus } from 'cde/constants' -import { +import { GitspaceActionType, GitspaceStatus } from 'cde/constants' +import type { EnumGitspaceStateType, EnumIDEType, - useDeleteGitspace, - type TypesGitspaceConfig, - type EnumCodeRepoType + TypesGitspaceConfig, + EnumGitspaceCodeRepoType } from 'cde-gitness/services' +import { useGetSpaceParam } from 'hooks/useGetSpaceParam' +import gitspaceIcon from 'cde-gitness/assests/gitspace.svg?url' +import { useModalHook } from 'hooks/useModalHook' +import pause from 'cde-gitness/assests/pause.svg?url' +import web from 'cde-gitness/assests/web.svg?url' +import deleteIcon from 'cde-gitness/assests/delete.svg?url' import css from './ListGitspaces.module.scss' enum CodeRepoType { @@ -63,18 +73,18 @@ enum CodeRepoType { Unknown = 'unknown' } -const getIconByRepoType = ({ repoType }: { repoType?: EnumCodeRepoType }): React.ReactNode => { +const getIconByRepoType = ({ repoType }: { repoType?: EnumGitspaceCodeRepoType }): React.ReactNode => { switch (repoType) { case CodeRepoType.Github: - return + return case CodeRepoType.Gitlab: - return + return case CodeRepoType.Bitbucket: - return + return default: case CodeRepoType.Unknown: case CodeRepoType.HarnessCode: - return + return } } @@ -82,8 +92,11 @@ export const getStatusColor = (status?: EnumGitspaceStateType) => { switch (status) { case GitspaceStatus.RUNNING: return '#42AB45' + case GitspaceStatus.STOPPING: + return '#FF832B' case GitspaceStatus.STOPPED: - return '#F3F3FA' + case GitspaceStatus.UNINITIALIZED: + return '#D0D0D9' case GitspaceStatus.ERROR: return '#FF0000' default: @@ -99,6 +112,10 @@ export const getStatusText = (getString: UseStringsReturn['getString'], status?: return getString('cde.listing.offline') case GitspaceStatus.ERROR: return getString('cde.listing.error') + case GitspaceStatus.STARTING: + return getString('cde.listing.starting') + case GitspaceStatus.STOPPING: + return getString('cde.listing.stopping') default: return getString('cde.listing.offline') } @@ -148,7 +165,7 @@ export const RenderRepository: Renderer> = ({ row const { name, branch, code_repo_url, code_repo_type, instance } = details || {} return ( - + > = ({ row e.stopPropagation() window.open(code_repo_url, '_blank') }}> - {getIconByRepoType({ repoType: code_repo_type })} - + + {getIconByRepoType({ repoType: code_repo_type })} + + {name} : - - + {branch} @@ -182,7 +206,7 @@ export const RenderCPUUsage: Renderer> = ({ row } const instance = row.original.instance const { resource_usage, total_time_used } = instance || {} - return getUsageTemplate(getString, , resource_usage, total_time_used) + return getUsageTemplate(getString, , resource_usage as string, total_time_used) } export const RenderStorageUsage: Renderer> = ({ row }) => { @@ -190,7 +214,7 @@ export const RenderStorageUsage: Renderer> = ({ r const instance = row.original.instance const { resource_usage, total_time_used } = instance || {} - return getUsageTemplate(getString, , resource_usage, total_time_used) + return getUsageTemplate(getString, , resource_usage as string, total_time_used) } export const RenderLastActivity: Renderer> = ({ row }) => { @@ -214,13 +238,23 @@ export const RenderLastActivity: Renderer> = ({ r export const RenderGitspaceStatus: Renderer> = ({ row }) => { const { getString } = useStrings() const details = row.original - const { instance, name } = details - const { state } = instance || {} + const { name, state } = details const color = getStatusColor(state) + const customProps = + state === GitspaceStatus.STARTING + ? { + icon: 'loading' as IconName, + iconProps: { color: Color.PRIMARY_4 } + } + : { icon: undefined } return ( - - + {state !== GitspaceStatus.STARTING && } + {getStatusText(getString, state)} @@ -231,10 +265,14 @@ export const StartStopButton = ({ state, loading }: { state?: EnumGitspaceStateT const { getString } = useStrings() return ( - {loading ? <> : state === GitspaceStatus.RUNNING ? : } + {loading ? <> : state === GitspaceStatus.RUNNING ? : } {state === GitspaceStatus.RUNNING - ? getString('cde.details.stopGitspace') + ? loading + ? getString('cde.stopingGitspace') + : getString('cde.details.stopGitspace') + : loading + ? getString('cde.startingGitspace') : getString('cde.details.startGitspace')} @@ -246,7 +284,7 @@ export const OpenGitspaceButton = ({ ide }: { ide?: EnumIDEType }) => { return ( - {ide === IDEType.VSCODE ? : } + {ide === IDEType.VSCODE ? : } {ide === IDEType.VSCODE ? getString('cde.ide.openVSCode') : getString('cde.ide.openBrowser')} ) @@ -254,8 +292,8 @@ export const OpenGitspaceButton = ({ ide }: { ide?: EnumIDEType }) => { interface ActionMenuProps { data: TypesGitspaceConfig - refreshList: () => void - handleStartStop?: () => Promise + handleStartGitspace?: () => void + handleStopGitspace?: () => void loading?: boolean actionLoading?: boolean deleteLoading?: boolean @@ -265,19 +303,21 @@ interface ActionMenuProps { const ActionMenu = ({ data, deleteGitspace, - refreshList, - handleStartStop, + handleStartGitspace, + handleStopGitspace, actionLoading, deleteLoading }: ActionMenuProps) => { const { getString } = useStrings() const { showError } = useToaster() - const { instance, ide } = data - const { id, state, url = ' ' } = instance || {} + const { instance, ide, identifier = '', space_path = '', state } = data + const { identifier: id, url = '' } = instance || {} const history = useHistory() const { routes } = useAppContext() const pathparamsList = instance?.space_path?.split('/') || [] const projectIdentifier = pathparamsList[pathparamsList.length - 1] || '' + const topBorder = state === GitspaceStatus.RUNNING && !actionLoading ? { top: true } : {} + const disabledActionButtons = [GitspaceStatus.STARTING, GitspaceStatus.STOPPING].includes(state as GitspaceStatus) return ( - { - history.push( - routes.toCDEGitspaceDetail({ - space: instance?.space_path || '', - gitspaceId: instance?.id || '' - }) - ) - }} - text={ - - - {getString('cde.viewGitspace')} - - } - /> - { - history.push( - routes.toCDEGitspacesEdit({ - space: instance?.space_path || '', - gitspaceId: instance?.id || '' - }) - ) - }} - text={ - - - {getString('cde.editGitspace')} - - } - /> - { - try { - if (!actionLoading) { - e.preventDefault() - e.stopPropagation() - await handleStartStop?.() - await refreshList() - } - } catch (error) { - showError(getErrorMessage(error)) - } - }} - text={ - - - - } - /> - {ide && state == GitspaceStatus.RUNNING && ( + {ide && state == GitspaceStatus.RUNNING && !actionLoading && ( { e.preventDefault() @@ -346,7 +335,7 @@ const ActionMenu = ({ if (ide === IDEType.VSCODE) { window.open(`vscode://harness-inc.gitspaces/${projectIdentifier}/${id}`, '_blank') } else { - window.open(url, '_blank') + window.open(url || '', '_blank') } }} text={ @@ -356,12 +345,55 @@ const ActionMenu = ({ } /> )} + + + {!disabledActionButtons && ( + { + try { + if (!actionLoading) { + e.preventDefault() + e.stopPropagation() + if (state === GitspaceStatus.RUNNING) { + handleStopGitspace?.() + } else { + handleStartGitspace?.() + } + } + } catch (error) { + showError(getErrorMessage(error)) + } + }} + disabled={disabledActionButtons} + text={ + + + + } + /> + )} + + { + history.push( + routes.toCDEGitspaceDetail({ + space: space_path, + gitspaceId: identifier + }) + ) + }} + text={{getString('cde.viewGitspace')}} + /> + + void} text={ - {deleteLoading ? <> : } - {getString('cde.deleteGitspace')} + {deleteLoading ? <> : } + + {getString('cde.deleteGitspace')} + } /> @@ -376,24 +408,132 @@ interface RenderActionsProps extends CellProps { export const RenderActions = ({ row, refreshList }: RenderActionsProps) => { const { getString } = useStrings() + const space = useGetSpaceParam() + const history = useHistory() + const { routes } = useAppContext() const { showError, showSuccess } = useToaster() const details = row.original - const { instance, name } = details - const { mutate: deleteGitspace, loading: deleteLoading } = useDeleteGitspace({}) + const { identifier, name, space_path } = details + // const { mutate: deleteGitspace, loading: deleteLoading } = useDeleteGitspace({}) - // To be added in BE later. - // const { mutate: actionGitspace, loading: actionLoading } = useGitspaceAction({ - // accountIdentifier, - // projectIdentifier, - // orgIdentifier, - // gitspaceIdentifier: instance?.id || '' - // }) + const { mutate: deleteGitspace, loading: deleteLoading } = useMutate({ + verb: 'DELETE', + path: `/api/v1/gitspaces/${space}/${identifier}/+` + }) - // const handleStartStop = async () => { - // return await actionGitspace({ - // action: instance?.state === GitspaceStatus.RUNNING ? GitspaceActionType.STOP : GitspaceActionType.START - // }) - // } + const { mutate: actionGitspace, loading: actionLoading } = useMutate({ + verb: 'POST', + path: `/api/v1/gitspaces/${space}/${identifier}/+/actions` + }) + + const [handleStopGitspace, hideModal] = useModalHook(() => { + return ( + + + {`Do you want to stop the Gitspace “${name}” ?`} + + } + contentText={ + + + By clicking on “Stop Gitspace”, the gitspace will start de-provisioning. + + + + + + + + + + } + onClose={hideModal} + /> + ) + }, [details, actionGitspace, history, routes]) + + const [handleStartGitspace, hideStartModal] = useModalHook(() => { + return ( + + + {`Do you want to start the Gitspace “${name}” ?`} + + } + contentText={ + + + By clicking on “Start Gitspace”, the gitspace will start provisioning. + + + + + + + + + + } + onClose={hideStartModal} + /> + ) + }, [details, actionGitspace, history, routes]) const confirmDelete = useConfirmAct() @@ -405,7 +545,7 @@ export const RenderActions = ({ row, refreshList }: RenderActionsProps) => { try { e.preventDefault() e.stopPropagation() - await deleteGitspace(instance?.id || '') + await deleteGitspace({}) showSuccess(getString('cde.deleteSuccess')) await refreshList() } catch (exception) { @@ -426,10 +566,11 @@ export const RenderActions = ({ row, refreshList }: RenderActionsProps) => { tooltip={ } tooltipProps={{ @@ -447,6 +588,77 @@ export const ListGitspaces = ({ data, refreshList }: { data: TypesGitspaceConfig const { getString } = useStrings() const { routes } = useAppContext() + const [currentRow, setCurrentRow] = useState() + + const [handleStartGitspace, hideStartModal] = useModalHook(() => { + return ( + setCurrentRow(undefined)} + titleText={ + + + {`Do you want to start the Gitspace “${currentRow?.name}” ?`} + + } + contentText={ + + + By clicking on “Start Gitspace”, the gitspace will start provisioning. + + + + + + + + + + } + onClose={hideStartModal} + /> + ) + }, [currentRow, history, routes]) + + useEffect(() => { + if (currentRow) { + setTimeout(() => { + handleStartGitspace() + }, 100) + } + }, [currentRow]) + return ( {data && ( @@ -456,17 +668,22 @@ export const ListGitspaces = ({ data, refreshList }: { data: TypesGitspaceConfig const pathparamsList = row?.instance?.space_path?.split('/') || [] const projectIdentifier = pathparamsList[pathparamsList.length - 1] || '' - if (row?.instance?.state === GitspaceStatus.RUNNING) { + if (row?.state === GitspaceStatus.RUNNING) { if (row?.ide === IDEType.VSCODE) { - window.open(`vscode://harness-inc.gitspaces/${projectIdentifier}/${row?.instance?.id}`, '_blank') + window.open( + `vscode://harness-inc.gitspaces/${projectIdentifier}/${row?.instance?.identifier}`, + '_blank' + ) } else { - window.open(row?.instance.url, '_blank') + window.open(row?.instance?.url || '', '_blank') } + } else if (row?.state === GitspaceStatus.STOPPED) { + setCurrentRow(row) } else { history.push( routes.toCDEGitspaceDetail({ - space: row?.instance?.space_path as string, - gitspaceId: row?.instance?.id as string + space: row?.space_path as string, + gitspaceId: row?.identifier as string }) ) } @@ -489,7 +706,7 @@ export const ListGitspaces = ({ data, refreshList }: { data: TypesGitspaceConfig }, { id: 'lastactivity', - Header: getString('cde.sessionDuration'), + Header: getString('cde.lastActivated'), Cell: RenderLastActivity }, { diff --git a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss index f1b5d8534..1d64a6ebc 100644 --- a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss +++ b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss @@ -1,12 +1,37 @@ -.hideContainer { - :global { - --bp3-intent-color: unset !important; - .bp3-form-helper-text { - margin-top: unset !important; - } +.formFields { + [class*='repoInput'], + [class*='branchDropdown'] { + width: 100% !important; } } -.repoAndBranch { - width: 47% !important; +.importForm { + cursor: pointer; + display: contents; + font-size: var(--font-size-small) !important; +} + +.repoInput { + span[icon='git-repo'], + span[icon='git-branch'] { + top: 20%; + left: 2% !important; + color: var(--grey-500) !important; + } + + input { + height: 50px !important; + border-radius: 7px !important; + border: 1px solid var(--grey-200) !important; + box-shadow: none !important; + background: var(--grey-100); + padding-left: 10% !important; + + &:active { + background: white; + } + &:focus { + background: white; + } + } } diff --git a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss.d.ts b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss.d.ts index ea39a05c1..dcec826a4 100644 --- a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss.d.ts +++ b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.module.scss.d.ts @@ -16,5 +16,6 @@ /* eslint-disable */ // This is an auto-generated file -export declare const hideContainer: string -export declare const repoAndBranch: string +export declare const formFields: string +export declare const importForm: string +export declare const repoInput: string diff --git a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.tsx b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.tsx index b1be9648a..6a61a1da9 100644 --- a/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.tsx +++ b/web/src/cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm.tsx @@ -1,125 +1,145 @@ -import { FormInput, FormikForm, Layout } from '@harnessio/uicore' -import React, { useState } from 'react' +import React, { useCallback, useState } from 'react' +import { get, debounce } from 'lodash-es' +import cx from 'classnames' +import { FormikForm, Layout, FormInput, Container, Text } from '@harnessio/uicore' import { useFormikContext } from 'formik' +import { Color } from '@harnessio/design-system' +import { useHistory } from 'react-router-dom' +import { Icon } from '@harnessio/icons' import { useStrings } from 'framework/strings' -import { GitProviders, ImportFormData, getOrgLabel, getOrgPlaceholder, getProviders } from 'utils/GitUtils' +import { + getRepoIdFromURL, + getRepoNameFromURL, + isValidUrl +} from 'cde/components/CreateGitspace/components/SelectRepository/SelectRepository.utils' +import { BranchInput } from 'cde/components/CreateGitspace/components/BranchInput/BranchInput' +import { useGetSpaceParam } from 'hooks/useGetSpaceParam' +import NewRepoModalButton from 'components/NewRepoModalButton/NewRepoModalButton' +import { RepoCreationType } from 'utils/GitUtils' +import { useAppContext } from 'AppContext' +import { OpenapiCreateGitspaceRequest, useGitspacelookup } from 'cde-gitness/services' import css from './ThirdPartyRepoImportForm.module.scss' -export interface ThirdPartyRepoImportFormProps extends ImportFormData { - branch: string - ide: string - id: string +enum RepoCheckStatus { + Valid = 'valid', + InValid = 'InValid' } export const ThirdPartyRepoImportForm = () => { - const [auth, setAuth] = useState(false) const { getString } = useStrings() - const { values, setFieldValue, validateField } = useFormikContext() + const history = useHistory() + const space = useGetSpaceParam() + const { routes } = useAppContext() + const { setValues, setFieldError } = useFormikContext() + + const { mutate, loading } = useGitspacelookup({}) + + const [repoCheckState, setRepoCheckState] = useState() + + const onChange = useCallback( + debounce(async (url: string) => { + let errorMessage = '' + try { + if (isValidUrl(url)) { + const response = (await mutate({ space_ref: space, url })) as { + is_private?: boolean + branch: string + url: string + } + if (response?.is_private) { + errorMessage = getString('cde.repository.privateRepoWarning') + setRepoCheckState(RepoCheckStatus.InValid) + } else { + setValues((prvValues: any) => { + return { + ...prvValues, + code_repo_url: response.url, + branch: response.branch, + identifier: getRepoIdFromURL(response.url), + name: getRepoNameFromURL(response.url) + } + }) + setRepoCheckState(RepoCheckStatus.Valid) + } + } else { + if (url?.trim()?.length) { + errorMessage = 'Invalid URL Format' + setRepoCheckState(RepoCheckStatus.InValid) + } else { + if (repoCheckState) { + setRepoCheckState(undefined) + } + } + } + } catch (err) { + errorMessage = get(err, 'message') || '' + } + setFieldError('code_repo_url', errorMessage) + }, 1000), + [repoCheckState] + ) + return ( - - {![GitProviders.GITHUB, GitProviders.GITLAB, GitProviders.BITBUCKET, GitProviders.AZURE].includes( - values.gitProvider - ) && ( - - )} - - {values.gitProvider === GitProviders.AZURE && ( - - )} - - - { - const target = event.target as HTMLInputElement - setFieldValue('repo', target.value) - if (target.value) { - setFieldValue('name', target.value) - validateField('repo') - } - }} - /> - - - { - const target = event.target as HTMLInputElement - setFieldValue('branch', target.value) - }} - /> - - - - { - setAuth(!auth) - }} - style={auth ? {} : { margin: 0 }} - /> - - - {auth ? ( - <> - {[GitProviders.BITBUCKET, GitProviders.AZURE].includes(values.gitProvider) && ( - + + {getString('cde.create.importWarning')} + { + ( + + {getString('cde.importInto')} + + )} + modalTitle={getString('importGitRepo')} + onSubmit={() => { + history.push(routes.toCDEGitspacesCreate({ space })) }} /> - )} + } + + + + + {loading ? ( + + ) : repoCheckState ? ( + repoCheckState === RepoCheckStatus.Valid ? ( + + ) : ( + + ) + ) : undefined} + + ) + }} + placeholder={getString('cde.repository.repositoryURL')} + className={cx(css.repoInput)} + onChange={async event => { + const target = event.target as HTMLInputElement + await onChange(target.value) }} /> - - ) : null} + + + + + ) } diff --git a/web/src/cde-gitness/constants/index.ts b/web/src/cde-gitness/constants/index.ts new file mode 100644 index 000000000..8480ad4b2 --- /dev/null +++ b/web/src/cde-gitness/constants/index.ts @@ -0,0 +1,4 @@ +export enum StandaloneIDEType { + VSCODE = 'vs_code', + VSCODEWEB = 'vs_code_web' +} diff --git a/web/src/cde-gitness/hooks/useGetLogStream.tsx b/web/src/cde-gitness/hooks/useGetLogStream.tsx new file mode 100644 index 000000000..667e7464c --- /dev/null +++ b/web/src/cde-gitness/hooks/useGetLogStream.tsx @@ -0,0 +1,54 @@ +import { useEffect, useState } from 'react' + +export interface LogData { + pos: number + out: string + time: number +} + +export function parseLog(log: string): LogData[] { + const logLines = log.trim().split('\n\n') + const parsedData: LogData[] = [] + + logLines.forEach(line => { + const dataMatch = line.match(/data: (.+)/) + + if (dataMatch && dataMatch[1] !== 'eof') { + const eventData: LogData = JSON.parse(dataMatch[1]) + + parsedData.push(eventData) + } + }) + + return parsedData +} + +export const useGetLogStream = ({ response }: { response: any }) => { + const [data, setData] = useState('') + + useEffect(() => { + const fetchStreamData = async () => { + const reader = response?.body?.getReader() + const decoder = new TextDecoder() + let done = false + + while (!done) { + /* eslint-disable no-await-in-loop */ + const { value, done: streamDone } = (await reader?.read()) || {} + done = streamDone + const chunk = decoder.decode(value) + setData(prevData => prevData + chunk) + } + } + + try { + if (response && !response.body.locked) { + fetchStreamData() + } + } catch (error) { + // + } + }, [response]) + + return { data: parseLog(data) } +} diff --git a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.constants.ts b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.constants.ts index ea8f52a72..9e1708ddf 100644 --- a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.constants.ts +++ b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.constants.ts @@ -1,28 +1,10 @@ -import type { ThirdPartyRepoImportFormProps } from 'cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm' import type { EnumIDEType, OpenapiCreateGitspaceRequest } from 'cde-gitness/services' -import { GitProviders } from 'utils/GitUtils' export const gitnessFormInitialValues: OpenapiCreateGitspaceRequest = { branch: '', code_repo_url: '', - devcontainer_path: '', - id: '', - ide: 'vsCode' as EnumIDEType, - infra_provider_resource_id: 'default', + identifier: '', + ide: 'vs_code' as EnumIDEType, + resource_identifier: 'default', name: '' } -export const thirdPartyformInitialValues: ThirdPartyRepoImportFormProps = { - gitProvider: GitProviders.GITHUB, - hostUrl: '', - org: '', - project: '', - repo: '', - username: '', - password: '', - name: '', - description: '', - branch: '', - ide: 'vsCode' as EnumIDEType, - id: '', - importPipelineLabel: false -} diff --git a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss index c2ef7f09f..8b952f355 100644 --- a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss +++ b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss @@ -1,7 +1,21 @@ .main { display: flex; - justify-content: center; align-items: center; + flex-direction: column; + margin-top: 10% !important; + + .titleContainer { + width: 50%; + margin-bottom: var(--spacing-medium) !important; + + h2 { + font-size: 24px !important; + } + p { + font-size: 16px !important; + color: #383946; + } + } .cardMain { width: 50%; diff --git a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss.d.ts b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss.d.ts index 841fb6516..5538cdcf0 100644 --- a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss.d.ts +++ b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.module.scss.d.ts @@ -24,3 +24,4 @@ export declare const formOuterContainer: string export declare const formTitleContainer: string export declare const main: string export declare const subContainers: string +export declare const titleContainer: string diff --git a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.tsx b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.tsx index a603bf23a..c67326222 100644 --- a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.tsx +++ b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.tsx @@ -1,23 +1,22 @@ import React, { useState } from 'react' import { + Breadcrumbs, Button, ButtonVariation, Card, Container, Formik, FormikForm, + Heading, Layout, Page, Text, useToaster } from '@harnessio/uicore' -import { FontVariation } from '@harnessio/design-system' +import { Color, FontVariation } from '@harnessio/design-system' import { useHistory } from 'react-router-dom' import { useStrings } from 'framework/strings' -import { - ThirdPartyRepoImportForm, - ThirdPartyRepoImportFormProps -} from 'cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm' +import { ThirdPartyRepoImportForm } from 'cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm' import { GitnessRepoImportForm } from 'cde-gitness/components/GitnessRepoImportForm/GitnessRepoImportForm' import { SelectIDE } from 'cde/components/CreateGitspace/components/SelectIDE/SelectIDE' import { useCreateGitspace, type OpenapiCreateGitspaceRequest } from 'cde-gitness/services' @@ -25,8 +24,8 @@ import { useGetSpaceParam } from 'hooks/useGetSpaceParam' import { getErrorMessage } from 'utils/Utils' import { useAppContext } from 'AppContext' import RepositoryTypeButton, { RepositoryType } from '../../components/RepositoryTypeButton/RepositoryTypeButton' -import { gitnessFormInitialValues, thirdPartyformInitialValues } from './GitspaceCreate.constants' -import { handleImportSubmit, validateGitnessForm, validationSchemaStepOne } from './GitspaceCreate.utils' +import { gitnessFormInitialValues } from './GitspaceCreate.constants' +import { validateGitnessForm } from './GitspaceCreate.utils' import css from './GitspaceCreate.module.scss' export const GitspaceCreate = () => { @@ -40,38 +39,49 @@ export const GitspaceCreate = () => { return ( <> - + + } + /> + + + + {getString('cde.createGitspace')} + + {getString('cde.create.subtext')} + + - - {getString('cde.createGitspace')} - { try { - const payload = - activeButton === RepositoryType.GITNESS - ? data - : handleImportSubmit(data as ThirdPartyRepoImportFormProps) - await mutate({ ...payload, space_ref: space } as OpenapiCreateGitspaceRequest & { + const payload = data + const response = await mutate({ ...payload, space_ref: space } as OpenapiCreateGitspaceRequest & { space_ref?: string }) showSuccess(getString('cde.create.gitspaceCreateSuccess')) - history.push(routes.toCDEGitspaces({ space })) + history.push( + `${routes.toCDEGitspaceDetail({ + space, + gitspaceId: response.identifier || '' + })}?redirectFrom=login` + ) } catch (error) { showError(getString('cde.create.gitspaceCreateFailed')) showError(getErrorMessage(error)) } }} - initialValues={ - activeButton === RepositoryType.GITNESS ? gitnessFormInitialValues : thirdPartyformInitialValues - } - validationSchema={ - activeButton === RepositoryType.GITNESS - ? validateGitnessForm(getString) - : validationSchemaStepOne(getString) - } + initialValues={gitnessFormInitialValues} + validationSchema={validateGitnessForm(getString)} formName="importRepoForm" enableReinitialize> {formik => { @@ -105,7 +115,7 @@ export const GitspaceCreate = () => { )} - + diff --git a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.utils.ts b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.utils.ts index 87b9c12fc..f23342eda 100644 --- a/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.utils.ts +++ b/web/src/cde-gitness/pages/GitspaceCreate/GitspaceCreate.utils.ts @@ -1,90 +1,12 @@ import * as yup from 'yup' -import { compact } from 'lodash-es' import type { UseStringsReturn } from 'framework/strings' -import { GitProviders, getProviderTypeMapping } from 'utils/GitUtils' -import type { ThirdPartyRepoImportFormProps } from 'cde-gitness/components/ThirdPartyRepoImportForm/ThirdPartyRepoImportForm' export const validateGitnessForm = (getString: UseStringsReturn['getString']) => yup.object().shape({ branch: yup.string().trim().required(getString('cde.branchValidationMessage')), code_repo_url: yup.string().trim().required(getString('cde.repoValidationMessage')), - id: yup.string().trim().required(), + identifier: yup.string().trim().required(), ide: yup.string().trim().required(), - infra_provider_resource_id: yup.string().trim().required(getString('cde.machineValidationMessage')), + resource_identifier: yup.string().trim().required(getString('cde.machineValidationMessage')), name: yup.string().trim().required() }) - -export const validationSchemaStepOne = (getString: UseStringsReturn['getString']) => - yup.object().shape({ - gitProvider: yup.string().required(), - repo: yup - .string() - .trim() - .when('gitProvider', { - is: gitProvider => [GitProviders.GITHUB, GitProviders.GITLAB, GitProviders.BITBUCKET].includes(gitProvider), - then: yup.string().required(getString('importSpace.orgRequired')) - }), - branch: yup.string().trim().required(getString('cde.branchValidationMessage')), - hostUrl: yup - .string() - // .matches(MATCH_REPOURL_REGEX, getString('importSpace.invalidUrl')) - .when('gitProvider', { - is: gitProvider => - ![GitProviders.GITHUB, GitProviders.GITLAB, GitProviders.BITBUCKET, GitProviders.AZURE].includes(gitProvider), - then: yup.string().required(getString('importRepo.required')), - otherwise: yup.string().notRequired() // Optional based on your needs - }), - org: yup - .string() - .trim() - .when('gitProvider', { - is: GitProviders.AZURE, - then: yup.string().required(getString('importSpace.orgRequired')) - }), - project: yup - .string() - .trim() - .when('gitProvider', { - is: GitProviders.AZURE, - then: yup.string().required(getString('importSpace.spaceNameRequired')) - }), - name: yup.string().trim().required(getString('validation.nameIsRequired')) - }) - -export const handleImportSubmit = (formData: ThirdPartyRepoImportFormProps) => { - const type = getProviderTypeMapping(formData.gitProvider) - - const provider = { - type, - username: formData.username, - password: formData.password, - host: '' - } - - if ( - ![GitProviders.GITHUB, GitProviders.GITLAB, GitProviders.BITBUCKET, GitProviders.AZURE].includes( - formData.gitProvider - ) - ) { - provider.host = formData.hostUrl - } - - const importPayload = { - name: formData.repo || formData.name, - description: formData.description || '', - id: formData.repo, - provider, - ide: formData.ide, - branch: formData.branch, - infra_provider_resource_id: 'default', - provider_repo: compact([ - formData.org, - formData.gitProvider === GitProviders.AZURE ? formData.project : '', - formData.repo - ]) - .join('/') - .replace(/\.git$/, '') - } - - return importPayload -} diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss new file mode 100644 index 000000000..5462786bd --- /dev/null +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss @@ -0,0 +1,69 @@ +.customSubheader { + height: 10vh; +} + +.pageMain { + margin: var(--spacing-xxlarge) !important; +} + +@media (min-width: 2000px) { + .titleContainer { + width: 80% !important; + margin: 0 10% !important; + } +} + +.titleContainer { + width: 95% !important; + margin: 0 5% !important; +} + +.cardContainer { + margin-top: var(--spacing-xxlarge) !important; + width: 100% !important; + + [data-testid='eventsCard-panel'] { + padding: 0px !important; + } + + &:first-child { + margin-top: 0px !important; + } +} + +.popover { + > div[class*='popover-arrow'] { + display: none; + } + + :global { + a.bp3-menu-item:hover, + .bp3-active { + background: var(--primary-1) !important; + color: var(--grey-1000) !important; + } + } +} + +.accordionnCustomSummary { + :global(.Accordion--chevron) { + margin-left: auto; + color: var(--grey-700); + } + + :global([class*='Accordion--panel']) { + padding: 0px !important; + } + + div[data-testid='eventsCard-summary'], + div[data-testid='logsCard-summary'] { + flex-direction: row-reverse; + justify-content: flex-end; + margin: 0 var(--spacing-medium); + width: 100%; + + div:first-child { + width: 97%; + } + } +} diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts new file mode 100644 index 000000000..9c9cd578f --- /dev/null +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Harness, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +// This is an auto-generated file +export declare const accordionnCustomSummary: string +export declare const cardContainer: string +export declare const customSubheader: string +export declare const pageMain: string +export declare const popover: string +export declare const titleContainer: string diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx new file mode 100644 index 000000000..81ad4d979 --- /dev/null +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx @@ -0,0 +1,347 @@ +import React, { useEffect, useState } from 'react' +import { + Breadcrumbs, + Button, + ButtonVariation, + Card, + Container, + Layout, + Accordion, + Page, + Text, + useToaster +} from '@harnessio/uicore' +import { Play } from 'iconoir-react' +import { useHistory, useParams } from 'react-router-dom' +import { Color, FontVariation, PopoverProps } from '@harnessio/design-system' +import { Menu, MenuItem, PopoverInteractionKind, PopoverPosition } from '@blueprintjs/core' +import { useGet, useMutate } from 'restful-react' +import { defaultTo } from 'lodash-es' +import { useGetSpaceParam } from 'hooks/useGetSpaceParam' +import { useAppContext } from 'AppContext' +import { useStrings } from 'framework/strings' +import EventTimelineAccordion from 'cde-gitness/components/EventTimelineAccordion/EventTimelineAccordion' +import { DetailsCard } from 'cde-gitness/components/DetailsCard/DetailsCard' +import type { TypesGitspaceConfig, TypesGitspaceEventResponse } from 'cde-gitness/services' +import { GitspaceActionType, GitspaceStatus } from 'cde/constants' +import { useQueryParams } from 'hooks/useQueryParams' +import { useUpdateQueryParams } from 'hooks/useUpdateQueryParams' +import { getErrorMessage } from 'utils/Utils' +import { usePolling } from 'cde/components/GitspaceDetails/usePolling' +import deleteIcon from 'cde-gitness/assests/delete.svg?url' +import vscodeIcon from 'cde/icons/VSCode.svg?url' +import pauseIcon from 'cde-gitness/assests/pause.svg?url' +import { StandaloneIDEType } from 'cde-gitness/constants' +import homeIcon from 'cde-gitness/assests/home.svg?url' +import ContainerLogs from '../../components/ContainerLogs/ContainerLogs' +import { useGetLogStream } from '../../hooks/useGetLogStream' +import css from './GitspaceDetails.module.scss' + +export const GitspaceDetails = () => { + const space = useGetSpaceParam() + const { getString } = useStrings() + const { routes } = useAppContext() + const { showError } = useToaster() + const history = useHistory() + const [startTriggred, setStartTriggred] = useState(false) + const { gitspaceId = '' } = useParams<{ gitspaceId?: string }>() + + const [isStreamingLogs, setIsStreamingLogs] = useState(false) + + const [startPolling, setStartPolling] = useState(undefined) + + const { loading, data, refetch, error } = useGet({ + path: `/api/v1/gitspaces/${space}/${gitspaceId}/+`, + debounce: 500 + }) + + const { data: eventData, refetch: refetchEventData } = useGet({ + path: `/api/v1/gitspaces/${space}/${gitspaceId}/+/events`, + debounce: 500 + }) + + const { refetch: refetchLogsData, response } = useGet({ + path: `api/v1/gitspaces/${space}/${gitspaceId}/+/logs/stream`, + debounce: 500, + lazy: true + }) + + const { mutate: actionMutate, loading: mutateLoading } = useMutate({ + verb: 'POST', + path: `/api/v1/gitspaces/${space}/${gitspaceId}/+/actions` + }) + + const { mutate: deleteGitspace, loading: deleteLoading } = useMutate({ + verb: 'DELETE', + path: `/api/v1/gitspaces/${space}/${gitspaceId}/+` + }) + + const { updateQueryParams } = useUpdateQueryParams<{ redirectFrom?: string }>() + const { redirectFrom = '' } = useQueryParams<{ redirectFrom?: string }>() + + const pollingCondition = [ + GitspaceStatus.RUNNING, + GitspaceStatus.STOPPED, + GitspaceStatus.ERROR, + GitspaceStatus.UNINITIALIZED + ].includes(data?.state as GitspaceStatus) + + const disabledActionButtons = [GitspaceStatus.STARTING, GitspaceStatus.STOPPING].includes( + data?.state as GitspaceStatus + ) + + useEffect(() => { + const filteredEvent = eventData?.filter( + item => + item.event === 'agent_gitspace_creation_start' && + defaultTo(item?.timestamp, 0) >= defaultTo(data?.instance?.updated, 0) + ) + if (disabledActionButtons && filteredEvent?.length && !isStreamingLogs) { + refetchLogsData() + setIsStreamingLogs(true) + } else if (filteredEvent?.length && !disabledActionButtons && isStreamingLogs) { + setIsStreamingLogs(false) + } + }, [eventData, data?.instance?.updated, disabledActionButtons]) + + usePolling( + async () => { + await refetchEventData() + await refetch() + }, + { + pollingInterval: 10000, + startCondition: Boolean(startPolling) || !pollingCondition + } + ) + + useEffect(() => { + const startTrigger = async () => { + if (redirectFrom && !startTriggred && !mutateLoading) { + try { + setStartTriggred(true) + await actionMutate({ action: GitspaceActionType.START }) + await refetch() + updateQueryParams({ redirectFrom: undefined }) + } catch (err) { + showError(getErrorMessage(err)) + } + } + } + + if (data?.state && data?.state !== GitspaceStatus.RUNNING && redirectFrom) { + startTrigger() + } + }, [data?.state, redirectFrom, mutateLoading, startTriggred]) + + const formattedlogsdata = useGetLogStream({ response }) + + return ( + <> + + } + /> + + + + + + {data?.name} + + + + + + + }> + {getString('cde.details.actions')} + + {(data?.state === GitspaceStatus.RUNNING || + data?.state === GitspaceStatus.STARTING || + data?.state === GitspaceStatus.STOPPING) && + data?.ide ? ( + + ) : ( + + )} + + + + + + !data?.identifier, + message: getString('cde.details.noData') + }} + className={css.pageMain}> + + + {getString('cde.gitspaceDetail')} + + + + + + + + + + + {getString('cde.details.containerLogs')} + + {getString('cde.details.containerLogsSubText')} + + } + id="logsCard" + details={ + + + + } + /> + + + + + + ) +} diff --git a/web/src/cde-gitness/services/index.tsx b/web/src/cde-gitness/services/index.tsx index d34511c57..7e677240f 100644 --- a/web/src/cde-gitness/services/index.tsx +++ b/web/src/cde-gitness/services/index.tsx @@ -1,10 +1,3 @@ -/* - * Copyright 2024 Harness Inc. All rights reserved. - * Use of this source code is governed by the PolyForm Shield 1.0.0 license - * that can be found in the licenses directory at the root of this repository, also available at - * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. - */ - /* Generated by restful-react */ import React from 'react' @@ -23,18 +16,61 @@ export type EnumCheckPayloadKind = '' | 'markdown' | 'pipeline' | 'raw' export type EnumCheckStatus = 'error' | 'failure' | 'pending' | 'running' | 'success' -export type EnumCodeRepoType = 'github' | 'gitlab' | 'harness_code' | 'bitbucket' | 'unknown' - export type EnumContentEncodingType = 'base64' | 'utf8' export type EnumFileDiffStatus = string -export type EnumGitspaceAccessType = 'jwt_token' | 'password' | 'ssh_key' +export type EnumGitspaceAccessType = 'jwt_token' | 'user_credentials' | 'ssh_key' -export type EnumGitspaceStateType = 'running' | 'stopped' | 'error' | 'uninitialized' +export type EnumGitspaceCodeRepoType = 'github' | 'gitlab' | 'harness_code' | 'bitbucket' | 'unknown' + +export type EnumGitspaceEntityType = 'gitspace_config' | 'gitspace_instance' + +export type EnumGitspaceEventType = + | 'gitspace_action_start' + | 'gitspace_action_start_completed' + | 'gitspace_action_start_failed' + | 'gitspace_action_stop' + | 'gitspace_action_stop_completed' + | 'gitspace_action_stop_failed' + | 'fetch_devcontainer_start' + | 'fetch_devcontainer_completed' + | 'fetch_devcontainer_failed' + | 'infra_provisioning_start' + | 'infra_provisioning_completed' + | 'infra_provisioning_failed' + | 'infra_unprovisioning_start' + | 'infra_unprovisioning_completed' + | 'infra_unprovisioning_failed' + | 'agent_connect_start' + | 'agent_connect_completed' + | 'agent_connect_failed' + | 'agent_gitspace_creation_start' + | 'agent_gitspace_creation_completed' + | 'agent_gitspace_creation_failed' + | 'agent_gitspace_deletion_start' + | 'agent_gitspace_deletion_completed' + | 'agent_gitspace_deletion_failed' + | 'agent_gitspace_state_report_running' + | 'agent_gitspace_state_report_error' + | 'agent_gitspace_state_report_stopped' + | 'agent_gitspace_state_report_unknown' + +export type EnumGitspaceInstanceStateType = + | 'running' + | 'uninitialized' + | 'unknown' + | 'error' + | 'deleted' + | 'starting' + | 'stopping' + +export type EnumGitspaceStateType = 'running' | 'stopped' | 'error' | 'uninitialized' | 'starting' | 'stopping' export type EnumIDEType = 'vs_code' | 'vs_code_web' +export type EnumInfraProviderType = 'docker' | 'harness_gcp' + export type EnumMembershipRole = 'contributor' | 'executor' | 'reader' | 'space_owner' export type EnumMergeCheckStatus = string @@ -45,8 +81,6 @@ export type EnumParentResourceType = 'space' | 'repo' export type EnumPrincipalType = 'service' | 'serviceaccount' | 'user' -export type EnumProviderType = 'docker' - export type EnumPublicKeyUsage = 'auth' export type EnumPullReqActivityKind = 'change-comment' | 'comment' | 'system' @@ -69,6 +103,8 @@ export type EnumPullReqReviewerType = 'assigned' | 'requested' | 'self_assigned' export type EnumPullReqState = 'closed' | 'merged' | 'open' +export type EnumRepoState = number + export type EnumResolverType = string export type EnumRuleState = 'active' | 'disabled' | 'monitor' | null @@ -165,6 +201,23 @@ export interface ImporterProvider { export type ImporterProviderType = 'github' | 'gitlab' | 'bitbucket' | 'stash' | 'gitea' | 'gogs' | 'azure' +export interface InfraproviderResourceInput { + cpu?: string | null + disk?: string | null + gateway_host?: string | null + gateway_port?: string | null + identifier?: string + infra_provider_type?: EnumInfraProviderType + memory?: string | null + metadata?: { + [key: string]: string + } | null + name?: string + network?: string | null + region?: string[] | null + template_identifier?: string | null +} + export interface JobProgress { failure?: string progress?: number @@ -266,16 +319,26 @@ export interface OpenapiCreateConnectorRequest { export interface OpenapiCreateGitspaceRequest { branch?: string code_repo_url?: string - devcontainer_path?: string - id?: string + devcontainer_path?: string | null ide?: EnumIDEType - infra_provider_resource_id?: string + identifier?: string metadata?: { [key: string]: string } | null name?: string - provider?: ImporterProvider - provider_repo?: string + resource_identifier?: string + space_ref?: string +} + +export interface OpenapiCreateInfraProviderConfigRequest { + identifier?: string + metadata?: { + [key: string]: string + } | null + name?: string + resources?: InfraproviderResourceInput[] | null + space_ref?: string + type?: EnumInfraProviderType } export interface OpenapiCreatePipelineRequest { @@ -401,6 +464,11 @@ export interface OpenapiLoginRequest { password?: string } +export interface OpenapiLookupRepoGitspaceRequest { + space_ref?: string + url?: string +} + export interface OpenapiMergePullReq { bypass_rules?: boolean dry_run?: boolean @@ -671,6 +739,8 @@ export interface RepoCommitTag { title?: string } +export type RepoContent = {} + export interface RepoContentInfo { latest_commit?: TypesCommit name?: string @@ -725,6 +795,7 @@ export interface RepoRepositoryOutput { path?: string size?: number size_updated?: number + state?: EnumRepoState updated?: number } @@ -750,6 +821,12 @@ export interface ReposettingsSecuritySettings { secret_scanning_enabled?: boolean | null } +export interface ScmCodeRepositoryResponse { + branch?: string + is_private?: boolean + url?: string +} + /** * Git object hash */ @@ -926,60 +1003,82 @@ export interface TypesExecution { export interface TypesGitspaceConfig { branch?: string - code_repo_id?: string - code_repo_type?: EnumCodeRepoType + code_repo_type?: EnumGitspaceCodeRepoType code_repo_url?: string created?: number - devcontainer_path?: string - id?: string + devcontainer_path?: string | null ide?: EnumIDEType - infra_provider_resource_id?: string + identifier?: string instance?: TypesGitspaceInstance name?: string + resource_identifier?: string space_path?: string + state?: EnumGitspaceStateType updated?: number user_id?: string } -export interface TypesGitspaceInstance { - access_key?: string +export interface TypesGitspaceEventResponse { + entity_type?: EnumGitspaceEntityType + event?: EnumGitspaceEventType + event_time?: string + message?: string + query_key?: string + timestamp?: number +} + +export type TypesGitspaceInstance = { + access_key?: string | null access_type?: EnumGitspaceAccessType created?: number - id?: string + identifier?: string last_used?: number - machine_user?: string - resource_usage?: string + machine_user?: string | null + resource_usage?: string | null space_path?: string - state?: EnumGitspaceStateType + state?: EnumGitspaceInstanceStateType total_time_used?: number - tracked_changes?: string + tracked_changes?: string | null updated?: number - url?: string -} + url?: string | null +} | null export interface TypesIdentity { email?: string name?: string } -export interface TypesInfraProviderResource { - cpu?: string +export interface TypesInfraProviderConfig { created?: number - disk?: string - gateway_host?: string - gateway_port?: string - id?: string - infra_provider_config_id?: string - infra_provider_type?: EnumProviderType - memory?: string + identifier?: string metadata?: { [key: string]: string } | null name?: string - network?: string + resources?: TypesInfraProviderResource[] | null + space_path?: string + type?: EnumInfraProviderType + updated?: number +} + +export interface TypesInfraProviderResource { + config_identifier?: string + cpu?: string | null + created?: number + disk?: string | null + gateway_host?: string | null + gateway_port?: string | null + identifier?: string + infra_provider_type?: EnumInfraProviderType + memory?: string | null + metadata?: { + [key: string]: string + } | null + name?: string + network?: string | null region?: string space_path?: string - template_id?: string + template_identifier?: string | null updated?: number } @@ -1039,6 +1138,7 @@ export interface TypesPipeline { description?: string disabled?: boolean execution?: TypesExecution + id?: number identifier?: string repo_id?: number seq?: number @@ -1192,7 +1292,6 @@ export interface TypesRepository { git_url?: string id?: number identifier?: string - importing?: boolean is_empty?: boolean num_closed_pulls?: number num_forks?: number @@ -1203,6 +1302,7 @@ export interface TypesRepository { path?: string size?: number size_updated?: number + state?: EnumRepoState updated?: number } @@ -1429,6 +1529,263 @@ export interface UsererrorError { values?: { [key: string]: any } } +export interface AdminListUsersQueryParams { + sort?: 'id' | 'email' | 'created' | 'updated' + order?: 'asc' | 'desc' + page?: number + limit?: number +} + +export type AdminListUsersProps = Omit, 'path'> + +export const AdminListUsers = (props: AdminListUsersProps) => ( + + path={`/admin/users`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseAdminListUsersProps = Omit< + UseGetProps, + 'path' +> + +export const useAdminListUsers = (props: UseAdminListUsersProps) => + useGet(`/admin/users`, { + base: getConfig('api/v1'), + ...props + }) + +export type AdminCreateUserProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const AdminCreateUser = (props: AdminCreateUserProps) => ( + + verb="POST" + path={`/admin/users`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseAdminCreateUserProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useAdminCreateUser = (props: UseAdminCreateUserProps) => + useMutate('POST', `/admin/users`, { + base: getConfig('api/v1'), + ...props + }) + +export type AdminDeleteUserProps = Omit, 'path' | 'verb'> + +export const AdminDeleteUser = (props: AdminDeleteUserProps) => ( + + verb="DELETE" + path={`/admin/users`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseAdminDeleteUserProps = Omit, 'path' | 'verb'> + +export const useAdminDeleteUser = (props: UseAdminDeleteUserProps) => + useMutate('DELETE', `/admin/users`, { base: getConfig('api/v1'), ...props }) + +export interface AdminGetUserPathParams { + user_uid: string +} + +export type AdminGetUserProps = Omit, 'path'> & + AdminGetUserPathParams + +export const AdminGetUser = ({ user_uid, ...props }: AdminGetUserProps) => ( + + path={`/admin/users/${user_uid}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseAdminGetUserProps = Omit, 'path'> & + AdminGetUserPathParams + +export const useAdminGetUser = ({ user_uid, ...props }: UseAdminGetUserProps) => + useGet( + (paramsInPath: AdminGetUserPathParams) => `/admin/users/${paramsInPath.user_uid}`, + { base: getConfig('api/v1'), pathParams: { user_uid }, ...props } + ) + +export interface AdminUpdateUserPathParams { + user_uid: string +} + +export type AdminUpdateUserProps = Omit< + MutateProps, + 'path' | 'verb' +> & + AdminUpdateUserPathParams + +export const AdminUpdateUser = ({ user_uid, ...props }: AdminUpdateUserProps) => ( + + verb="PATCH" + path={`/admin/users/${user_uid}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseAdminUpdateUserProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + AdminUpdateUserPathParams + +export const useAdminUpdateUser = ({ user_uid, ...props }: UseAdminUpdateUserProps) => + useMutate( + 'PATCH', + (paramsInPath: AdminUpdateUserPathParams) => `/admin/users/${paramsInPath.user_uid}`, + { base: getConfig('api/v1'), pathParams: { user_uid }, ...props } + ) + +export interface UpdateUserAdminPathParams { + user_uid: string +} + +export type UpdateUserAdminProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateUserAdminPathParams + +export const UpdateUserAdmin = ({ user_uid, ...props }: UpdateUserAdminProps) => ( + + verb="PATCH" + path={`/admin/users/${user_uid}/admin`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateUserAdminProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateUserAdminPathParams + +export const useUpdateUserAdmin = ({ user_uid, ...props }: UseUpdateUserAdminProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateUserAdminPathParams) => `/admin/users/${paramsInPath.user_uid}/admin`, + { base: getConfig('api/v1'), pathParams: { user_uid }, ...props } + ) + +export type CreateConnectorProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateConnector = (props: CreateConnectorProps) => ( + + verb="POST" + path={`/connectors`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateConnectorProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreateConnector = (props: UseCreateConnectorProps) => + useMutate('POST', `/connectors`, { + base: getConfig('api/v1'), + ...props + }) + +export type DeleteConnectorProps = Omit, 'path' | 'verb'> + +export const DeleteConnector = (props: DeleteConnectorProps) => ( + + verb="DELETE" + path={`/connectors`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteConnectorProps = Omit, 'path' | 'verb'> + +export const useDeleteConnector = (props: UseDeleteConnectorProps) => + useMutate('DELETE', `/connectors`, { base: getConfig('api/v1'), ...props }) + +export interface FindConnectorPathParams { + connector_ref: string +} + +export type FindConnectorProps = Omit, 'path'> & + FindConnectorPathParams + +export const FindConnector = ({ connector_ref, ...props }: FindConnectorProps) => ( + + path={`/connectors/${connector_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindConnectorProps = Omit< + UseGetProps, + 'path' +> & + FindConnectorPathParams + +export const useFindConnector = ({ connector_ref, ...props }: UseFindConnectorProps) => + useGet( + (paramsInPath: FindConnectorPathParams) => `/connectors/${paramsInPath.connector_ref}`, + { base: getConfig('api/v1'), pathParams: { connector_ref }, ...props } + ) + +export interface UpdateConnectorPathParams { + connector_ref: string +} + +export type UpdateConnectorProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateConnectorPathParams + +export const UpdateConnector = ({ connector_ref, ...props }: UpdateConnectorProps) => ( + + verb="PATCH" + path={`/connectors/${connector_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateConnectorProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateConnectorPathParams + +export const useUpdateConnector = ({ connector_ref, ...props }: UseUpdateConnectorProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateConnectorPathParams) => `/connectors/${paramsInPath.connector_ref}`, + { base: getConfig('api/v1'), pathParams: { connector_ref }, ...props } + ) + export interface ListGitspacesQueryParams { sort?: 'id' | 'created' | 'updated' order?: 'asc' | 'desc' @@ -1447,7 +1804,7 @@ export type ListGitspacesProps = Omit< export const ListGitspaces = (props: ListGitspacesProps) => ( path={`/gitspaces`} - base={getConfig('code/api/v1')} + base={getConfig('api/v1')} {...props} /> ) @@ -1462,12 +1819,12 @@ export type UseListGitspacesProps = Omit< */ export const useListGitspaces = (props: UseListGitspacesProps) => useGet(`/gitspaces`, { - base: getConfig('code/api/v1'), + base: getConfig('api/v1'), ...props }) export type CreateGitspaceProps = Omit< - MutateProps, + MutateProps, 'path' | 'verb' > @@ -1475,16 +1832,16 @@ export type CreateGitspaceProps = Omit< * Create gitspace config */ export const CreateGitspace = (props: CreateGitspaceProps) => ( - + verb="POST" path={`/gitspaces`} - base={getConfig('code/api/v1')} + base={getConfig('api/v1')} {...props} /> ) export type UseCreateGitspaceProps = Omit< - UseMutateProps, + UseMutateProps, 'path' | 'verb' > @@ -1492,8 +1849,8 @@ export type UseCreateGitspaceProps = Omit< * Create gitspace config */ export const useCreateGitspace = (props: UseCreateGitspaceProps) => - useMutate('POST', `/gitspaces`, { - base: getConfig('code/api/v1'), + useMutate('POST', `/gitspaces`, { + base: getConfig('api/v1'), ...props }) @@ -1506,7 +1863,7 @@ export const DeleteGitspace = (props: DeleteGitspaceProps) => ( verb="DELETE" path={`/gitspaces`} - base={getConfig('code/api/v1')} + base={getConfig('api/v1')} {...props} /> ) @@ -1517,13 +1874,10 @@ export type UseDeleteGitspaceProps = Omit - useMutate('DELETE', `/gitspaces`, { - base: getConfig('code/api/v1'), - ...props - }) + useMutate('DELETE', `/gitspaces`, { base: getConfig('api/v1'), ...props }) export interface FindGitspacePathParams { - gitspace_ref: string + gitspace_identifier: string } export type FindGitspaceProps = Omit< @@ -1535,10 +1889,10 @@ export type FindGitspaceProps = Omit< /** * Get gitspace */ -export const FindGitspace = ({ gitspace_ref, ...props }: FindGitspaceProps) => ( +export const FindGitspace = ({ gitspace_identifier, ...props }: FindGitspaceProps) => ( - path={`/gitspaces/${gitspace_ref}`} - base={getConfig('code/api/v1')} + path={`/gitspaces/${gitspace_identifier}`} + base={getConfig('api/v1')} {...props} /> ) @@ -1552,8 +1906,5499 @@ export type UseFindGitspaceProps = Omit< /** * Get gitspace */ -export const useFindGitspace = ({ gitspace_ref, ...props }: UseFindGitspaceProps) => +export const useFindGitspace = ({ gitspace_identifier, ...props }: UseFindGitspaceProps) => useGet( - (paramsInPath: FindGitspacePathParams) => `/gitspaces/${paramsInPath.gitspace_ref}`, - { base: getConfig('code/api/v1'), pathParams: { gitspace_ref }, ...props } + (paramsInPath: FindGitspacePathParams) => `/gitspaces/${paramsInPath.gitspace_identifier}`, + { base: getConfig('api/v1'), pathParams: { gitspace_identifier }, ...props } ) + +export interface ListGitspaceEventsQueryParams { + page?: number + limit?: number +} + +export interface ListGitspaceEventsPathParams { + gitspace_identifier: string +} + +export type ListGitspaceEventsProps = Omit< + GetProps, + 'path' +> & + ListGitspaceEventsPathParams + +/** + * List gitspace events + */ +export const ListGitspaceEvents = ({ gitspace_identifier, ...props }: ListGitspaceEventsProps) => ( + + path={`/gitspaces/${gitspace_identifier}/events`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListGitspaceEventsProps = Omit< + UseGetProps< + TypesGitspaceEventResponse[], + UsererrorError, + ListGitspaceEventsQueryParams, + ListGitspaceEventsPathParams + >, + 'path' +> & + ListGitspaceEventsPathParams + +/** + * List gitspace events + */ +export const useListGitspaceEvents = ({ gitspace_identifier, ...props }: UseListGitspaceEventsProps) => + useGet( + (paramsInPath: ListGitspaceEventsPathParams) => `/gitspaces/${paramsInPath.gitspace_identifier}/events`, + { base: getConfig('api/v1'), pathParams: { gitspace_identifier }, ...props } + ) + +export interface OpStreamLogsPathParams { + gitspace_identifier: string +} + +export type OpStreamLogsProps = Omit, 'path'> & + OpStreamLogsPathParams + +export const OpStreamLogs = ({ gitspace_identifier, ...props }: OpStreamLogsProps) => ( + + path={`/gitspaces/${gitspace_identifier}/logs/stream`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseOpStreamLogsProps = Omit< + UseGetProps, + 'path' +> & + OpStreamLogsPathParams + +export const useOpStreamLogs = ({ gitspace_identifier, ...props }: UseOpStreamLogsProps) => + useGet( + (paramsInPath: OpStreamLogsPathParams) => `/gitspaces/${paramsInPath.gitspace_identifier}/logs/stream`, + { base: getConfig('api/v1'), pathParams: { gitspace_identifier }, ...props } + ) + +export type GitspacelookupProps = Omit< + MutateProps, + 'path' | 'verb' +> + +/** + * Create gitspace config + */ +export const Gitspacelookup = (props: GitspacelookupProps) => ( + + verb="POST" + path={`/gitspaces/lookup-repo`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGitspacelookupProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +/** + * Create gitspace config + */ +export const useGitspacelookup = (props: UseGitspacelookupProps) => + useMutate( + 'POST', + `/gitspaces/lookup-repo`, + { base: getConfig('api/v1'), ...props } + ) + +export type CreateInfraProviderProps = Omit< + MutateProps, + 'path' | 'verb' +> + +/** + * Create infraProvider config + */ +export const CreateInfraProvider = (props: CreateInfraProviderProps) => ( + + verb="POST" + path={`/infraproviders`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateInfraProviderProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +/** + * Create infraProvider config + */ +export const useCreateInfraProvider = (props: UseCreateInfraProviderProps) => + useMutate( + 'POST', + `/infraproviders`, + { base: getConfig('api/v1'), ...props } + ) + +export interface GetInfraProviderPathParams { + infraprovider_identifier: string +} + +export type GetInfraProviderProps = Omit< + GetProps, + 'path' +> & + GetInfraProviderPathParams + +/** + * Get infraProviderConfig + */ +export const GetInfraProvider = ({ infraprovider_identifier, ...props }: GetInfraProviderProps) => ( + + path={`/infraproviders/${infraprovider_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetInfraProviderProps = Omit< + UseGetProps, + 'path' +> & + GetInfraProviderPathParams + +/** + * Get infraProviderConfig + */ +export const useGetInfraProvider = ({ infraprovider_identifier, ...props }: UseGetInfraProviderProps) => + useGet( + (paramsInPath: GetInfraProviderPathParams) => `/infraproviders/${paramsInPath.infraprovider_identifier}`, + { base: getConfig('api/v1'), pathParams: { infraprovider_identifier }, ...props } + ) + +export interface OnLoginQueryParams { + /** + * If set to true the token is also returned as a cookie. + */ + include_cookie?: boolean +} + +export type OnLoginProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const OnLogin = (props: OnLoginProps) => ( + + verb="POST" + path={`/login`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseOnLoginProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useOnLogin = (props: UseOnLoginProps) => + useMutate('POST', `/login`, { + base: getConfig('api/v1'), + ...props + }) + +export type OpLogoutProps = Omit, 'path' | 'verb'> + +export const OpLogout = (props: OpLogoutProps) => ( + verb="POST" path={`/logout`} base={getConfig('api/v1')} {...props} /> +) + +export type UseOpLogoutProps = Omit, 'path' | 'verb'> + +export const useOpLogout = (props: UseOpLogoutProps) => + useMutate('POST', `/logout`, { base: getConfig('api/v1'), ...props }) + +export interface ListPluginsQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * The substring which is used to filter the plugins by their name. + */ + query?: string +} + +export type ListPluginsProps = Omit, 'path'> + +export const ListPlugins = (props: ListPluginsProps) => ( + + path={`/plugins`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPluginsProps = Omit, 'path'> + +export const useListPlugins = (props: UseListPluginsProps) => + useGet(`/plugins`, { + base: getConfig('api/v1'), + ...props + }) + +export interface ListPrincipalsQueryParams { + /** + * The substring by which the principals are filtered. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * The types of principals to include. + */ + type?: ('service' | 'serviceaccount' | 'user')[] +} + +export type ListPrincipalsProps = Omit< + GetProps, + 'path' +> + +export const ListPrincipals = (props: ListPrincipalsProps) => ( + + path={`/principals`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPrincipalsProps = Omit< + UseGetProps, + 'path' +> + +export const useListPrincipals = (props: UseListPrincipalsProps) => + useGet(`/principals`, { + base: getConfig('api/v1'), + ...props + }) + +export interface OnRegisterQueryParams { + /** + * If set to true the token is also returned as a cookie. + */ + include_cookie?: boolean +} + +export type OnRegisterProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const OnRegister = (props: OnRegisterProps) => ( + + verb="POST" + path={`/register`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseOnRegisterProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useOnRegister = (props: UseOnRegisterProps) => + useMutate( + 'POST', + `/register`, + { base: getConfig('api/v1'), ...props } + ) + +export interface CreateRepositoryQueryParams { + /** + * path of parent space (Not needed in standalone). + */ + space_path?: string +} + +export type CreateRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateRepository = (props: CreateRepositoryProps) => ( + + verb="POST" + path={`/repos`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateRepositoryProps = Omit< + UseMutateProps< + RepoRepositoryOutput, + UsererrorError, + CreateRepositoryQueryParams, + OpenapiCreateRepositoryRequest, + void + >, + 'path' | 'verb' +> + +export const useCreateRepository = (props: UseCreateRepositoryProps) => + useMutate( + 'POST', + `/repos`, + { base: getConfig('api/v1'), ...props } + ) + +export type DeleteRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const DeleteRepository = (props: DeleteRepositoryProps) => ( + + verb="DELETE" + path={`/repos`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteRepositoryProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useDeleteRepository = (props: UseDeleteRepositoryProps) => + useMutate('DELETE', `/repos`, { + base: getConfig('api/v1'), + ...props + }) + +export interface FindRepositoryPathParams { + repo_ref: string +} + +export type FindRepositoryProps = Omit< + GetProps, + 'path' +> & + FindRepositoryPathParams + +export const FindRepository = ({ repo_ref, ...props }: FindRepositoryProps) => ( + + path={`/repos/${repo_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindRepositoryProps = Omit< + UseGetProps, + 'path' +> & + FindRepositoryPathParams + +export const useFindRepository = ({ repo_ref, ...props }: UseFindRepositoryProps) => + useGet( + (paramsInPath: FindRepositoryPathParams) => `/repos/${paramsInPath.repo_ref}`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface UpdateRepositoryPathParams { + repo_ref: string +} + +export type UpdateRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateRepositoryPathParams + +export const UpdateRepository = ({ repo_ref, ...props }: UpdateRepositoryProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateRepositoryProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateRepositoryPathParams + +export const useUpdateRepository = ({ repo_ref, ...props }: UseUpdateRepositoryProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateRepositoryPathParams) => `/repos/${paramsInPath.repo_ref}`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface ArchiveQueryParams { + /** + * Without an optional path parameter, all files and subdirectories of the current working directory are included in the archive. If one or more paths are specified, only these are included. + */ + path?: string[] + /** + * Prepend / to paths in the archive. + */ + prefix?: string + /** + * Look for attributes in .gitattributes files in the working tree as well + */ + attributes?: string + /** + * Set modification time of archive entries. Without this option the committer time is used if is a commit or tag, and the current time if it is a tree. + */ + time?: string + /** + * Specify compression level. Larger values allow the command to spend more time to compress to smaller size. + */ + compression?: number +} + +export interface ArchivePathParams { + repo_ref: string + git_ref: string + format: string +} + +export type ArchiveProps = Omit, 'path'> & + ArchivePathParams + +export const Archive = ({ repo_ref, git_ref, format, ...props }: ArchiveProps) => ( + + path={`/repos/${repo_ref}/archive/${git_ref}.${format}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseArchiveProps = Omit, 'path'> & + ArchivePathParams + +export const useArchive = ({ repo_ref, git_ref, format, ...props }: UseArchiveProps) => + useGet( + (paramsInPath: ArchivePathParams) => + `/repos/${paramsInPath.repo_ref}/archive/${paramsInPath.git_ref}.${paramsInPath.format}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, git_ref, format }, ...props } + ) + +export interface GetBlameQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string + /** + * Line number from which the file data is considered + */ + line_from?: number + /** + * Line number to which the file data is considered + */ + line_to?: number +} + +export interface GetBlamePathParams { + repo_ref: string + path: string +} + +export type GetBlameProps = Omit< + GetProps, + 'path' +> & + GetBlamePathParams + +export const GetBlame = ({ repo_ref, path, ...props }: GetBlameProps) => ( + + path={`/repos/${repo_ref}/blame/${path}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetBlameProps = Omit< + UseGetProps, + 'path' +> & + GetBlamePathParams + +export const useGetBlame = ({ repo_ref, path, ...props }: UseGetBlameProps) => + useGet( + (paramsInPath: GetBlamePathParams) => `/repos/${paramsInPath.repo_ref}/blame/${paramsInPath.path}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, path }, ...props } + ) + +export interface ListBranchesQueryParams { + /** + * Indicates whether optional commit information should be included in the response. + */ + include_commit?: boolean + /** + * The substring by which the branches are filtered. + */ + query?: string + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The data by which the branches are sorted. + */ + sort?: 'name' | 'date' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListBranchesPathParams { + repo_ref: string +} + +export type ListBranchesProps = Omit< + GetProps, + 'path' +> & + ListBranchesPathParams + +export const ListBranches = ({ repo_ref, ...props }: ListBranchesProps) => ( + + path={`/repos/${repo_ref}/branches`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListBranchesProps = Omit< + UseGetProps, + 'path' +> & + ListBranchesPathParams + +export const useListBranches = ({ repo_ref, ...props }: UseListBranchesProps) => + useGet( + (paramsInPath: ListBranchesPathParams) => `/repos/${paramsInPath.repo_ref}/branches`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CreateBranchPathParams { + repo_ref: string +} + +export type CreateBranchProps = Omit< + MutateProps< + RepoBranch, + UsererrorError | TypesRulesViolations, + void, + OpenapiCreateBranchRequest, + CreateBranchPathParams + >, + 'path' | 'verb' +> & + CreateBranchPathParams + +export const CreateBranch = ({ repo_ref, ...props }: CreateBranchProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/branches`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateBranchProps = Omit< + UseMutateProps< + RepoBranch, + UsererrorError | TypesRulesViolations, + void, + OpenapiCreateBranchRequest, + CreateBranchPathParams + >, + 'path' | 'verb' +> & + CreateBranchPathParams + +export const useCreateBranch = ({ repo_ref, ...props }: UseCreateBranchProps) => + useMutate< + RepoBranch, + UsererrorError | TypesRulesViolations, + void, + OpenapiCreateBranchRequest, + CreateBranchPathParams + >('POST', (paramsInPath: CreateBranchPathParams) => `/repos/${paramsInPath.repo_ref}/branches`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface DeleteBranchQueryParams { + /** + * Bypass rule violations if possible. + */ + bypass_rules?: boolean +} + +export interface DeleteBranchPathParams { + repo_ref: string +} + +export type DeleteBranchProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeleteBranchPathParams + +export const DeleteBranch = ({ repo_ref, ...props }: DeleteBranchProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/branches`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteBranchProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeleteBranchPathParams + +export const useDeleteBranch = ({ repo_ref, ...props }: UseDeleteBranchProps) => + useMutate( + 'DELETE', + (paramsInPath: DeleteBranchPathParams) => `/repos/${paramsInPath.repo_ref}/branches`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface GetBranchPathParams { + repo_ref: string + branch_name: string +} + +export type GetBranchProps = Omit, 'path'> & + GetBranchPathParams + +export const GetBranch = ({ repo_ref, branch_name, ...props }: GetBranchProps) => ( + + path={`/repos/${repo_ref}/branches/${branch_name}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetBranchProps = Omit, 'path'> & + GetBranchPathParams + +export const useGetBranch = ({ repo_ref, branch_name, ...props }: UseGetBranchProps) => + useGet( + (paramsInPath: GetBranchPathParams) => `/repos/${paramsInPath.repo_ref}/branches/${paramsInPath.branch_name}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, branch_name }, ...props } + ) + +export interface ListStatusCheckResultsQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * The substring which is used to filter the status checks by their Identifier. + */ + query?: string +} + +export interface ListStatusCheckResultsPathParams { + repo_ref: string + commit_sha: string +} + +export type ListStatusCheckResultsProps = Omit< + GetProps, + 'path' +> & + ListStatusCheckResultsPathParams + +export const ListStatusCheckResults = ({ repo_ref, commit_sha, ...props }: ListStatusCheckResultsProps) => ( + + path={`/repos/${repo_ref}/checks/commits/${commit_sha}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListStatusCheckResultsProps = Omit< + UseGetProps, + 'path' +> & + ListStatusCheckResultsPathParams + +export const useListStatusCheckResults = ({ repo_ref, commit_sha, ...props }: UseListStatusCheckResultsProps) => + useGet( + (paramsInPath: ListStatusCheckResultsPathParams) => + `/repos/${paramsInPath.repo_ref}/checks/commits/${paramsInPath.commit_sha}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, commit_sha }, ...props } + ) + +export interface ReportStatusCheckResultsPathParams { + repo_ref: string + commit_sha: string +} + +export interface ReportStatusCheckResultsRequestBody { + check_uid?: string + ended?: number + identifier?: string + link?: string + payload?: TypesCheckPayload + started?: number + status?: EnumCheckStatus + summary?: string +} + +export type ReportStatusCheckResultsProps = Omit< + MutateProps< + TypesCheck, + UsererrorError, + void, + ReportStatusCheckResultsRequestBody, + ReportStatusCheckResultsPathParams + >, + 'path' | 'verb' +> & + ReportStatusCheckResultsPathParams + +export const ReportStatusCheckResults = ({ repo_ref, commit_sha, ...props }: ReportStatusCheckResultsProps) => ( + + verb="PUT" + path={`/repos/${repo_ref}/checks/commits/${commit_sha}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseReportStatusCheckResultsProps = Omit< + UseMutateProps< + TypesCheck, + UsererrorError, + void, + ReportStatusCheckResultsRequestBody, + ReportStatusCheckResultsPathParams + >, + 'path' | 'verb' +> & + ReportStatusCheckResultsPathParams + +export const useReportStatusCheckResults = ({ repo_ref, commit_sha, ...props }: UseReportStatusCheckResultsProps) => + useMutate( + 'PUT', + (paramsInPath: ReportStatusCheckResultsPathParams) => + `/repos/${paramsInPath.repo_ref}/checks/commits/${paramsInPath.commit_sha}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, commit_sha }, ...props } + ) + +export interface ListStatusCheckRecentQueryParams { + /** + * The substring which is used to filter the status checks by their Identifier. + */ + query?: string + /** + * The timestamp (in Unix time millis) since the status checks have been run. + */ + since?: number +} + +export interface ListStatusCheckRecentPathParams { + repo_ref: string +} + +export type ListStatusCheckRecentProps = Omit< + GetProps, + 'path' +> & + ListStatusCheckRecentPathParams + +export const ListStatusCheckRecent = ({ repo_ref, ...props }: ListStatusCheckRecentProps) => ( + + path={`/repos/${repo_ref}/checks/recent`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListStatusCheckRecentProps = Omit< + UseGetProps, + 'path' +> & + ListStatusCheckRecentPathParams + +export const useListStatusCheckRecent = ({ repo_ref, ...props }: UseListStatusCheckRecentProps) => + useGet( + (paramsInPath: ListStatusCheckRecentPathParams) => `/repos/${paramsInPath.repo_ref}/checks/recent`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CodeOwnersValidateQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string +} + +export interface CodeOwnersValidatePathParams { + repo_ref: string +} + +export type CodeOwnersValidateProps = Omit< + GetProps, + 'path' +> & + CodeOwnersValidatePathParams + +export const CodeOwnersValidate = ({ repo_ref, ...props }: CodeOwnersValidateProps) => ( + + path={`/repos/${repo_ref}/codeowners/validate`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCodeOwnersValidateProps = Omit< + UseGetProps, + 'path' +> & + CodeOwnersValidatePathParams + +export const useCodeOwnersValidate = ({ repo_ref, ...props }: UseCodeOwnersValidateProps) => + useGet( + (paramsInPath: CodeOwnersValidatePathParams) => `/repos/${paramsInPath.repo_ref}/codeowners/validate`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface ListCommitsQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string + /** + * The result should only contain commits that occurred after the provided reference. + */ + after?: string + /** + * Path for which commit information should be retrieved + */ + path?: string + /** + * Epoch since when commit information should be retrieved. + */ + since?: number + /** + * Epoch until when commit information should be retrieved. + */ + until?: number + /** + * Committer pattern for which commit information should be retrieved. + */ + committer?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * Indicates whether optional stats should be included in the response. + */ + include_stats?: boolean +} + +export interface ListCommitsPathParams { + repo_ref: string +} + +export type ListCommitsProps = Omit< + GetProps, + 'path' +> & + ListCommitsPathParams + +export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => ( + + path={`/repos/${repo_ref}/commits`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListCommitsProps = Omit< + UseGetProps, + 'path' +> & + ListCommitsPathParams + +export const useListCommits = ({ repo_ref, ...props }: UseListCommitsProps) => + useGet( + (paramsInPath: ListCommitsPathParams) => `/repos/${paramsInPath.repo_ref}/commits`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CommitFilesPathParams { + repo_ref: string +} + +export type CommitFilesProps = Omit< + MutateProps< + TypesCommitFilesResponse, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommitFilesRequest, + CommitFilesPathParams + >, + 'path' | 'verb' +> & + CommitFilesPathParams + +export const CommitFiles = ({ repo_ref, ...props }: CommitFilesProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/commits`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommitFilesProps = Omit< + UseMutateProps< + TypesCommitFilesResponse, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommitFilesRequest, + CommitFilesPathParams + >, + 'path' | 'verb' +> & + CommitFilesPathParams + +export const useCommitFiles = ({ repo_ref, ...props }: UseCommitFilesProps) => + useMutate< + TypesCommitFilesResponse, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommitFilesRequest, + CommitFilesPathParams + >('POST', (paramsInPath: CommitFilesPathParams) => `/repos/${paramsInPath.repo_ref}/commits`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface GetCommitPathParams { + repo_ref: string + commit_sha: string +} + +export type GetCommitProps = Omit, 'path'> & + GetCommitPathParams + +export const GetCommit = ({ repo_ref, commit_sha, ...props }: GetCommitProps) => ( + + path={`/repos/${repo_ref}/commits/${commit_sha}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetCommitProps = Omit, 'path'> & + GetCommitPathParams + +export const useGetCommit = ({ repo_ref, commit_sha, ...props }: UseGetCommitProps) => + useGet( + (paramsInPath: GetCommitPathParams) => `/repos/${paramsInPath.repo_ref}/commits/${paramsInPath.commit_sha}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, commit_sha }, ...props } + ) + +export interface GetCommitDiffPathParams { + repo_ref: string + commit_sha: string +} + +export type GetCommitDiffProps = Omit, 'path'> & + GetCommitDiffPathParams + +export const GetCommitDiff = ({ repo_ref, commit_sha, ...props }: GetCommitDiffProps) => ( + + path={`/repos/${repo_ref}/commits/${commit_sha}/diff`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetCommitDiffProps = Omit, 'path'> & + GetCommitDiffPathParams + +export const useGetCommitDiff = ({ repo_ref, commit_sha, ...props }: UseGetCommitDiffProps) => + useGet( + (paramsInPath: GetCommitDiffPathParams) => + `/repos/${paramsInPath.repo_ref}/commits/${paramsInPath.commit_sha}/diff`, + { base: getConfig('api/v1'), pathParams: { repo_ref, commit_sha }, ...props } + ) + +export interface CalculateCommitDivergencePathParams { + repo_ref: string +} + +export type CalculateCommitDivergenceProps = Omit< + MutateProps< + RepoCommitDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >, + 'path' | 'verb' +> & + CalculateCommitDivergencePathParams + +export const CalculateCommitDivergence = ({ repo_ref, ...props }: CalculateCommitDivergenceProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/commits/calculate-divergence`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCalculateCommitDivergenceProps = Omit< + UseMutateProps< + RepoCommitDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >, + 'path' | 'verb' +> & + CalculateCommitDivergencePathParams + +export const useCalculateCommitDivergence = ({ repo_ref, ...props }: UseCalculateCommitDivergenceProps) => + useMutate< + RepoCommitDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >( + 'POST', + (paramsInPath: CalculateCommitDivergencePathParams) => + `/repos/${paramsInPath.repo_ref}/commits/calculate-divergence`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface GetContentQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string + /** + * Indicates whether optional commit information should be included in the response. + */ + include_commit?: boolean +} + +export interface GetContentPathParams { + repo_ref: string + path: string +} + +export type GetContentProps = Omit< + GetProps, + 'path' +> & + GetContentPathParams + +export const GetContent = ({ repo_ref, path, ...props }: GetContentProps) => ( + + path={`/repos/${repo_ref}/content/${path}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetContentProps = Omit< + UseGetProps, + 'path' +> & + GetContentPathParams + +export const useGetContent = ({ repo_ref, path, ...props }: UseGetContentProps) => + useGet( + (paramsInPath: GetContentPathParams) => `/repos/${paramsInPath.repo_ref}/content/${paramsInPath.path}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, path }, ...props } + ) + +export interface DiffStatsQueryParams { + /** + * provide path for diff operation + */ + path?: string[] +} + +export interface DiffStatsPathParams { + repo_ref: string + range: string +} + +export type DiffStatsProps = Omit< + GetProps, + 'path' +> & + DiffStatsPathParams + +export const DiffStats = ({ repo_ref, range, ...props }: DiffStatsProps) => ( + + path={`/repos/${repo_ref}/diff-stats/${range}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDiffStatsProps = Omit< + UseGetProps, + 'path' +> & + DiffStatsPathParams + +export const useDiffStats = ({ repo_ref, range, ...props }: UseDiffStatsProps) => + useGet( + (paramsInPath: DiffStatsPathParams) => `/repos/${paramsInPath.repo_ref}/diff-stats/${paramsInPath.range}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, range }, ...props } + ) + +export interface RawDiffQueryParams { + /** + * provide path for diff operation + */ + path?: string[] +} + +export interface RawDiffPathParams { + repo_ref: string + range: string +} + +export type RawDiffProps = Omit< + GetProps, + 'path' +> & + RawDiffPathParams + +export const RawDiff = ({ repo_ref, range, ...props }: RawDiffProps) => ( + + path={`/repos/${repo_ref}/diff/${range}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRawDiffProps = Omit< + UseGetProps, + 'path' +> & + RawDiffPathParams + +export const useRawDiff = ({ repo_ref, range, ...props }: UseRawDiffProps) => + useGet( + (paramsInPath: RawDiffPathParams) => `/repos/${paramsInPath.repo_ref}/diff/${paramsInPath.range}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, range }, ...props } + ) + +export interface RawDiffPostPathParams { + repo_ref: string + range: string +} + +export type RawDiffPostProps = Omit< + MutateProps, + 'path' | 'verb' +> & + RawDiffPostPathParams + +export const RawDiffPost = ({ repo_ref, range, ...props }: RawDiffPostProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/diff/${range}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRawDiffPostProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + RawDiffPostPathParams + +export const useRawDiffPost = ({ repo_ref, range, ...props }: UseRawDiffPostProps) => + useMutate( + 'POST', + (paramsInPath: RawDiffPostPathParams) => `/repos/${paramsInPath.repo_ref}/diff/${paramsInPath.range}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, range }, ...props } + ) + +export interface MergeCheckQueryParams { + /** + * provide path for diff operation + */ + path?: string[] +} + +export interface MergeCheckPathParams { + repo_ref: string + range: string +} + +export type MergeCheckProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MergeCheckPathParams + +export const MergeCheck = ({ repo_ref, range, ...props }: MergeCheckProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/merge-check/${range}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMergeCheckProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MergeCheckPathParams + +export const useMergeCheck = ({ repo_ref, range, ...props }: UseMergeCheckProps) => + useMutate( + 'POST', + (paramsInPath: MergeCheckPathParams) => `/repos/${paramsInPath.repo_ref}/merge-check/${paramsInPath.range}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, range }, ...props } + ) + +export interface MoveRepositoryPathParams { + repo_ref: string +} + +export type MoveRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MoveRepositoryPathParams + +export const MoveRepository = ({ repo_ref, ...props }: MoveRepositoryProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/move`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMoveRepositoryProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MoveRepositoryPathParams + +export const useMoveRepository = ({ repo_ref, ...props }: UseMoveRepositoryProps) => + useMutate( + 'POST', + (paramsInPath: MoveRepositoryPathParams) => `/repos/${paramsInPath.repo_ref}/move`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface PathDetailsQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string +} + +export interface PathDetailsPathParams { + repo_ref: string +} + +export type PathDetailsProps = Omit< + MutateProps< + RepoPathsDetailsOutput, + UsererrorError, + PathDetailsQueryParams, + OpenapiPathsDetailsRequest, + PathDetailsPathParams + >, + 'path' | 'verb' +> & + PathDetailsPathParams + +export const PathDetails = ({ repo_ref, ...props }: PathDetailsProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/path-details`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UsePathDetailsProps = Omit< + UseMutateProps< + RepoPathsDetailsOutput, + UsererrorError, + PathDetailsQueryParams, + OpenapiPathsDetailsRequest, + PathDetailsPathParams + >, + 'path' | 'verb' +> & + PathDetailsPathParams + +export const usePathDetails = ({ repo_ref, ...props }: UsePathDetailsProps) => + useMutate< + RepoPathsDetailsOutput, + UsererrorError, + PathDetailsQueryParams, + OpenapiPathsDetailsRequest, + PathDetailsPathParams + >('POST', (paramsInPath: PathDetailsPathParams) => `/repos/${paramsInPath.repo_ref}/path-details`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface ListPathsQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string + /** + * Indicates whether directories should be included in the response. + */ + include_directories?: boolean +} + +export interface ListPathsPathParams { + repo_ref: string +} + +export type ListPathsProps = Omit< + GetProps, + 'path' +> & + ListPathsPathParams + +export const ListPaths = ({ repo_ref, ...props }: ListPathsProps) => ( + + path={`/repos/${repo_ref}/paths`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPathsProps = Omit< + UseGetProps, + 'path' +> & + ListPathsPathParams + +export const useListPaths = ({ repo_ref, ...props }: UseListPathsProps) => + useGet( + (paramsInPath: ListPathsPathParams) => `/repos/${paramsInPath.repo_ref}/paths`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface ListPipelinesQueryParams { + /** + * The substring which is used to filter the repositories by their path name. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * Whether to fetch latest build information for each pipeline. + */ + latest?: boolean +} + +export interface ListPipelinesPathParams { + repo_ref: string +} + +export type ListPipelinesProps = Omit< + GetProps, + 'path' +> & + ListPipelinesPathParams + +export const ListPipelines = ({ repo_ref, ...props }: ListPipelinesProps) => ( + + path={`/repos/${repo_ref}/pipelines`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPipelinesProps = Omit< + UseGetProps, + 'path' +> & + ListPipelinesPathParams + +export const useListPipelines = ({ repo_ref, ...props }: UseListPipelinesProps) => + useGet( + (paramsInPath: ListPipelinesPathParams) => `/repos/${paramsInPath.repo_ref}/pipelines`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CreatePipelinePathParams { + repo_ref: string +} + +export type CreatePipelineProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreatePipelinePathParams + +export const CreatePipeline = ({ repo_ref, ...props }: CreatePipelineProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pipelines`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreatePipelineProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CreatePipelinePathParams + +export const useCreatePipeline = ({ repo_ref, ...props }: UseCreatePipelineProps) => + useMutate( + 'POST', + (paramsInPath: CreatePipelinePathParams) => `/repos/${paramsInPath.repo_ref}/pipelines`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface DeletePipelinePathParams { + repo_ref: string +} + +export type DeletePipelineProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeletePipelinePathParams + +export const DeletePipeline = ({ repo_ref, ...props }: DeletePipelineProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pipelines`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeletePipelineProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeletePipelinePathParams + +export const useDeletePipeline = ({ repo_ref, ...props }: UseDeletePipelineProps) => + useMutate( + 'DELETE', + (paramsInPath: DeletePipelinePathParams) => `/repos/${paramsInPath.repo_ref}/pipelines`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface FindPipelinePathParams { + repo_ref: string + pipeline_identifier: string +} + +export type FindPipelineProps = Omit, 'path'> & + FindPipelinePathParams + +export const FindPipeline = ({ repo_ref, pipeline_identifier, ...props }: FindPipelineProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindPipelineProps = Omit< + UseGetProps, + 'path' +> & + FindPipelinePathParams + +export const useFindPipeline = ({ repo_ref, pipeline_identifier, ...props }: UseFindPipelineProps) => + useGet( + (paramsInPath: FindPipelinePathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface UpdatePipelinePathParams { + repo_ref: string + pipeline_identifier: string +} + +export type UpdatePipelineProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdatePipelinePathParams + +export const UpdatePipeline = ({ repo_ref, pipeline_identifier, ...props }: UpdatePipelineProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdatePipelineProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdatePipelinePathParams + +export const useUpdatePipeline = ({ repo_ref, pipeline_identifier, ...props }: UseUpdatePipelineProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdatePipelinePathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface ListExecutionsQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListExecutionsPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type ListExecutionsProps = Omit< + GetProps, + 'path' +> & + ListExecutionsPathParams + +export const ListExecutions = ({ repo_ref, pipeline_identifier, ...props }: ListExecutionsProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListExecutionsProps = Omit< + UseGetProps, + 'path' +> & + ListExecutionsPathParams + +export const useListExecutions = ({ repo_ref, pipeline_identifier, ...props }: UseListExecutionsProps) => + useGet( + (paramsInPath: ListExecutionsPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface CreateExecutionQueryParams { + /** + * Branch to run the execution for. + */ + branch?: string +} + +export interface CreateExecutionPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type CreateExecutionProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreateExecutionPathParams + +export const CreateExecution = ({ repo_ref, pipeline_identifier, ...props }: CreateExecutionProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateExecutionProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CreateExecutionPathParams + +export const useCreateExecution = ({ repo_ref, pipeline_identifier, ...props }: UseCreateExecutionProps) => + useMutate( + 'POST', + (paramsInPath: CreateExecutionPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface DeleteExecutionPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type DeleteExecutionProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeleteExecutionPathParams + +export const DeleteExecution = ({ repo_ref, pipeline_identifier, ...props }: DeleteExecutionProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteExecutionProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeleteExecutionPathParams + +export const useDeleteExecution = ({ repo_ref, pipeline_identifier, ...props }: UseDeleteExecutionProps) => + useMutate( + 'DELETE', + (paramsInPath: DeleteExecutionPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface FindExecutionPathParams { + repo_ref: string + pipeline_identifier: string + execution_number: string +} + +export type FindExecutionProps = Omit, 'path'> & + FindExecutionPathParams + +export const FindExecution = ({ repo_ref, pipeline_identifier, execution_number, ...props }: FindExecutionProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions/${execution_number}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindExecutionProps = Omit< + UseGetProps, + 'path' +> & + FindExecutionPathParams + +export const useFindExecution = ({ + repo_ref, + pipeline_identifier, + execution_number, + ...props +}: UseFindExecutionProps) => + useGet( + (paramsInPath: FindExecutionPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions/${paramsInPath.execution_number}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier, execution_number }, ...props } + ) + +export interface CancelExecutionPathParams { + repo_ref: string + pipeline_identifier: string + execution_number: string +} + +export type CancelExecutionProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CancelExecutionPathParams + +export const CancelExecution = ({ + repo_ref, + pipeline_identifier, + execution_number, + ...props +}: CancelExecutionProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions/${execution_number}/cancel`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCancelExecutionProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CancelExecutionPathParams + +export const useCancelExecution = ({ + repo_ref, + pipeline_identifier, + execution_number, + ...props +}: UseCancelExecutionProps) => + useMutate( + 'POST', + (paramsInPath: CancelExecutionPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions/${paramsInPath.execution_number}/cancel`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier, execution_number }, ...props } + ) + +export interface ViewLogsPathParams { + repo_ref: string + pipeline_identifier: string + execution_number: string + stage_number: string + step_number: string +} + +export type ViewLogsProps = Omit, 'path'> & + ViewLogsPathParams + +export const ViewLogs = ({ + repo_ref, + pipeline_identifier, + execution_number, + stage_number, + step_number, + ...props +}: ViewLogsProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/executions/${execution_number}/logs/${stage_number}/${step_number}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseViewLogsProps = Omit, 'path'> & + ViewLogsPathParams + +export const useViewLogs = ({ + repo_ref, + pipeline_identifier, + execution_number, + stage_number, + step_number, + ...props +}: UseViewLogsProps) => + useGet( + (paramsInPath: ViewLogsPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/executions/${paramsInPath.execution_number}/logs/${paramsInPath.stage_number}/${paramsInPath.step_number}`, + { + base: getConfig('api/v1'), + pathParams: { repo_ref, pipeline_identifier, execution_number, stage_number, step_number }, + ...props + } + ) + +export interface ListTriggersQueryParams { + /** + * The substring which is used to filter the repositories by their path name. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListTriggersPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type ListTriggersProps = Omit< + GetProps, + 'path' +> & + ListTriggersPathParams + +export const ListTriggers = ({ repo_ref, pipeline_identifier, ...props }: ListTriggersProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/triggers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListTriggersProps = Omit< + UseGetProps, + 'path' +> & + ListTriggersPathParams + +export const useListTriggers = ({ repo_ref, pipeline_identifier, ...props }: UseListTriggersProps) => + useGet( + (paramsInPath: ListTriggersPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/triggers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface CreateTriggerPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type CreateTriggerProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreateTriggerPathParams + +export const CreateTrigger = ({ repo_ref, pipeline_identifier, ...props }: CreateTriggerProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/triggers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateTriggerProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CreateTriggerPathParams + +export const useCreateTrigger = ({ repo_ref, pipeline_identifier, ...props }: UseCreateTriggerProps) => + useMutate( + 'POST', + (paramsInPath: CreateTriggerPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/triggers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface DeleteTriggerPathParams { + repo_ref: string + pipeline_identifier: string +} + +export type DeleteTriggerProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeleteTriggerPathParams + +export const DeleteTrigger = ({ repo_ref, pipeline_identifier, ...props }: DeleteTriggerProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/triggers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteTriggerProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeleteTriggerPathParams + +export const useDeleteTrigger = ({ repo_ref, pipeline_identifier, ...props }: UseDeleteTriggerProps) => + useMutate( + 'DELETE', + (paramsInPath: DeleteTriggerPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/triggers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier }, ...props } + ) + +export interface FindTriggerPathParams { + repo_ref: string + pipeline_identifier: string + trigger_identifier: string +} + +export type FindTriggerProps = Omit, 'path'> & + FindTriggerPathParams + +export const FindTrigger = ({ repo_ref, pipeline_identifier, trigger_identifier, ...props }: FindTriggerProps) => ( + + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/triggers/${trigger_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindTriggerProps = Omit, 'path'> & + FindTriggerPathParams + +export const useFindTrigger = ({ repo_ref, pipeline_identifier, trigger_identifier, ...props }: UseFindTriggerProps) => + useGet( + (paramsInPath: FindTriggerPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/triggers/${paramsInPath.trigger_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier, trigger_identifier }, ...props } + ) + +export interface UpdateTriggerPathParams { + repo_ref: string + pipeline_identifier: string + trigger_identifier: string +} + +export type UpdateTriggerProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateTriggerPathParams + +export const UpdateTrigger = ({ repo_ref, pipeline_identifier, trigger_identifier, ...props }: UpdateTriggerProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/pipelines/${pipeline_identifier}/triggers/${trigger_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateTriggerProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateTriggerPathParams + +export const useUpdateTrigger = ({ + repo_ref, + pipeline_identifier, + trigger_identifier, + ...props +}: UseUpdateTriggerProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateTriggerPathParams) => + `/repos/${paramsInPath.repo_ref}/pipelines/${paramsInPath.pipeline_identifier}/triggers/${paramsInPath.trigger_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pipeline_identifier, trigger_identifier }, ...props } + ) + +export interface UpdatePublicAccessPathParams { + repo_ref: string +} + +export type UpdatePublicAccessProps = Omit< + MutateProps< + RepoRepositoryOutput, + UsererrorError, + void, + OpenapiUpdateRepoPublicAccessRequest, + UpdatePublicAccessPathParams + >, + 'path' | 'verb' +> & + UpdatePublicAccessPathParams + +export const UpdatePublicAccess = ({ repo_ref, ...props }: UpdatePublicAccessProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/public-access`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdatePublicAccessProps = Omit< + UseMutateProps< + RepoRepositoryOutput, + UsererrorError, + void, + OpenapiUpdateRepoPublicAccessRequest, + UpdatePublicAccessPathParams + >, + 'path' | 'verb' +> & + UpdatePublicAccessPathParams + +export const useUpdatePublicAccess = ({ repo_ref, ...props }: UseUpdatePublicAccessProps) => + useMutate< + RepoRepositoryOutput, + UsererrorError, + void, + OpenapiUpdateRepoPublicAccessRequest, + UpdatePublicAccessPathParams + >('POST', (paramsInPath: UpdatePublicAccessPathParams) => `/repos/${paramsInPath.repo_ref}/public-access`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface ListPullReqQueryParams { + /** + * The state of the pull requests to include in the result. + */ + state?: ('closed' | 'merged' | 'open')[] + /** + * Source repository ref of the pull requests. + */ + source_repo_ref?: string + /** + * Source branch of the pull requests. + */ + source_branch?: string + /** + * Target branch of the pull requests. + */ + target_branch?: string + /** + * The substring by which the pull requests are filtered. + */ + query?: string + /** + * List of principal IDs who created pull requests. + */ + created_by?: number[] + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The data by which the pull requests are sorted. + */ + sort?: 'created' | 'edited' | 'merged' | 'number' | 'updated' + /** + * The result should contain only entries created before this timestamp (unix millis). + */ + created_lt?: number + /** + * The result should contain only entries created after this timestamp (unix millis). + */ + created_gt?: number + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListPullReqPathParams { + repo_ref: string +} + +export type ListPullReqProps = Omit< + GetProps, + 'path' +> & + ListPullReqPathParams + +export const ListPullReq = ({ repo_ref, ...props }: ListPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPullReqProps = Omit< + UseGetProps, + 'path' +> & + ListPullReqPathParams + +export const useListPullReq = ({ repo_ref, ...props }: UseListPullReqProps) => + useGet( + (paramsInPath: ListPullReqPathParams) => `/repos/${paramsInPath.repo_ref}/pullreq`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CreatePullReqPathParams { + repo_ref: string +} + +export type CreatePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreatePullReqPathParams + +export const CreatePullReq = ({ repo_ref, ...props }: CreatePullReqProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreatePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CreatePullReqPathParams + +export const useCreatePullReq = ({ repo_ref, ...props }: UseCreatePullReqProps) => + useMutate( + 'POST', + (paramsInPath: CreatePullReqPathParams) => `/repos/${paramsInPath.repo_ref}/pullreq`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface GetPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type GetPullReqProps = Omit, 'path'> & + GetPullReqPathParams + +export const GetPullReq = ({ repo_ref, pullreq_number, ...props }: GetPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetPullReqProps = Omit, 'path'> & + GetPullReqPathParams + +export const useGetPullReq = ({ repo_ref, pullreq_number, ...props }: UseGetPullReqProps) => + useGet( + (paramsInPath: GetPullReqPathParams) => `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface UpdatePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type UpdatePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdatePullReqPathParams + +export const UpdatePullReq = ({ repo_ref, pullreq_number, ...props }: UpdatePullReqProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdatePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdatePullReqPathParams + +export const useUpdatePullReq = ({ repo_ref, pullreq_number, ...props }: UseUpdatePullReqProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdatePullReqPathParams) => `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ListPullReqActivitiesQueryParams { + /** + * The kind of the pull request activity to include in the result. + */ + kind?: ('change-comment' | 'comment' | 'system')[] + /** + * The type of the pull request activity to include in the result. + */ + type?: ( + | 'branch-delete' + | 'branch-update' + | 'code-comment' + | 'comment' + | 'merge' + | 'review-submit' + | 'state-change' + | 'title-change' + )[] + /** + * The result should contain only entries created at and after this timestamp (unix millis). + */ + after?: number + /** + * The result should contain only entries created before this timestamp (unix millis). + */ + before?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListPullReqActivitiesPathParams { + repo_ref: string + pullreq_number: number +} + +export type ListPullReqActivitiesProps = Omit< + GetProps, + 'path' +> & + ListPullReqActivitiesPathParams + +export const ListPullReqActivities = ({ repo_ref, pullreq_number, ...props }: ListPullReqActivitiesProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/activities`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPullReqActivitiesProps = Omit< + UseGetProps< + TypesPullReqActivity[], + UsererrorError, + ListPullReqActivitiesQueryParams, + ListPullReqActivitiesPathParams + >, + 'path' +> & + ListPullReqActivitiesPathParams + +export const useListPullReqActivities = ({ repo_ref, pullreq_number, ...props }: UseListPullReqActivitiesProps) => + useGet( + (paramsInPath: ListPullReqActivitiesPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/activities`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ChecksPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type ChecksPullReqProps = Omit< + GetProps, + 'path' +> & + ChecksPullReqPathParams + +export const ChecksPullReq = ({ repo_ref, pullreq_number, ...props }: ChecksPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/checks`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseChecksPullReqProps = Omit< + UseGetProps, + 'path' +> & + ChecksPullReqPathParams + +export const useChecksPullReq = ({ repo_ref, pullreq_number, ...props }: UseChecksPullReqProps) => + useGet( + (paramsInPath: ChecksPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/checks`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface CodeownersPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type CodeownersPullReqProps = Omit< + GetProps, + 'path' +> & + CodeownersPullReqPathParams + +export const CodeownersPullReq = ({ repo_ref, pullreq_number, ...props }: CodeownersPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/codeowners`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCodeownersPullReqProps = Omit< + UseGetProps, + 'path' +> & + CodeownersPullReqPathParams + +export const useCodeownersPullReq = ({ repo_ref, pullreq_number, ...props }: UseCodeownersPullReqProps) => + useGet( + (paramsInPath: CodeownersPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/codeowners`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface CommentCreatePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type CommentCreatePullReqProps = Omit< + MutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentCreatePullReqRequest, + CommentCreatePullReqPathParams + >, + 'path' | 'verb' +> & + CommentCreatePullReqPathParams + +export const CommentCreatePullReq = ({ repo_ref, pullreq_number, ...props }: CommentCreatePullReqProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/comments`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommentCreatePullReqProps = Omit< + UseMutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentCreatePullReqRequest, + CommentCreatePullReqPathParams + >, + 'path' | 'verb' +> & + CommentCreatePullReqPathParams + +export const useCommentCreatePullReq = ({ repo_ref, pullreq_number, ...props }: UseCommentCreatePullReqProps) => + useMutate< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentCreatePullReqRequest, + CommentCreatePullReqPathParams + >( + 'POST', + (paramsInPath: CommentCreatePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/comments`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface CommentDeletePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type CommentDeletePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CommentDeletePullReqPathParams + +export const CommentDeletePullReq = ({ repo_ref, pullreq_number, ...props }: CommentDeletePullReqProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/comments`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommentDeletePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CommentDeletePullReqPathParams + +export const useCommentDeletePullReq = ({ repo_ref, pullreq_number, ...props }: UseCommentDeletePullReqProps) => + useMutate( + 'DELETE', + (paramsInPath: CommentDeletePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/comments`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface CommentUpdatePullReqPathParams { + repo_ref: string + pullreq_number: number + pullreq_comment_id: number +} + +export type CommentUpdatePullReqProps = Omit< + MutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentUpdatePullReqRequest, + CommentUpdatePullReqPathParams + >, + 'path' | 'verb' +> & + CommentUpdatePullReqPathParams + +export const CommentUpdatePullReq = ({ + repo_ref, + pullreq_number, + pullreq_comment_id, + ...props +}: CommentUpdatePullReqProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/comments/${pullreq_comment_id}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommentUpdatePullReqProps = Omit< + UseMutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentUpdatePullReqRequest, + CommentUpdatePullReqPathParams + >, + 'path' | 'verb' +> & + CommentUpdatePullReqPathParams + +export const useCommentUpdatePullReq = ({ + repo_ref, + pullreq_number, + pullreq_comment_id, + ...props +}: UseCommentUpdatePullReqProps) => + useMutate< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentUpdatePullReqRequest, + CommentUpdatePullReqPathParams + >( + 'PATCH', + (paramsInPath: CommentUpdatePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/comments/${paramsInPath.pullreq_comment_id}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number, pullreq_comment_id }, ...props } + ) + +export interface CommentStatusPullReqPathParams { + repo_ref: string + pullreq_number: number + pullreq_comment_id: number +} + +export type CommentStatusPullReqProps = Omit< + MutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentStatusPullReqRequest, + CommentStatusPullReqPathParams + >, + 'path' | 'verb' +> & + CommentStatusPullReqPathParams + +export const CommentStatusPullReq = ({ + repo_ref, + pullreq_number, + pullreq_comment_id, + ...props +}: CommentStatusPullReqProps) => ( + + verb="PUT" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/comments/${pullreq_comment_id}/status`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommentStatusPullReqProps = Omit< + UseMutateProps< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentStatusPullReqRequest, + CommentStatusPullReqPathParams + >, + 'path' | 'verb' +> & + CommentStatusPullReqPathParams + +export const useCommentStatusPullReq = ({ + repo_ref, + pullreq_number, + pullreq_comment_id, + ...props +}: UseCommentStatusPullReqProps) => + useMutate< + TypesPullReqActivity, + UsererrorError, + void, + OpenapiCommentStatusPullReqRequest, + CommentStatusPullReqPathParams + >( + 'PUT', + (paramsInPath: CommentStatusPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/comments/${paramsInPath.pullreq_comment_id}/status`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number, pullreq_comment_id }, ...props } + ) + +export interface CommentApplySuggestionsPathParams { + repo_ref: string + pullreq_number: number +} + +export type CommentApplySuggestionsProps = Omit< + MutateProps< + PullreqCommentApplySuggestionsOutput, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommentApplySuggestionstRequest, + CommentApplySuggestionsPathParams + >, + 'path' | 'verb' +> & + CommentApplySuggestionsPathParams + +export const CommentApplySuggestions = ({ repo_ref, pullreq_number, ...props }: CommentApplySuggestionsProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/comments/apply-suggestions`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCommentApplySuggestionsProps = Omit< + UseMutateProps< + PullreqCommentApplySuggestionsOutput, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommentApplySuggestionstRequest, + CommentApplySuggestionsPathParams + >, + 'path' | 'verb' +> & + CommentApplySuggestionsPathParams + +export const useCommentApplySuggestions = ({ repo_ref, pullreq_number, ...props }: UseCommentApplySuggestionsProps) => + useMutate< + PullreqCommentApplySuggestionsOutput, + UsererrorError | TypesRulesViolations, + void, + OpenapiCommentApplySuggestionstRequest, + CommentApplySuggestionsPathParams + >( + 'POST', + (paramsInPath: CommentApplySuggestionsPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/comments/apply-suggestions`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ListPullReqCommitsQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListPullReqCommitsPathParams { + repo_ref: string + pullreq_number: number +} + +export type ListPullReqCommitsProps = Omit< + GetProps, + 'path' +> & + ListPullReqCommitsPathParams + +export const ListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: ListPullReqCommitsProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/commits`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPullReqCommitsProps = Omit< + UseGetProps, + 'path' +> & + ListPullReqCommitsPathParams + +export const useListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: UseListPullReqCommitsProps) => + useGet( + (paramsInPath: ListPullReqCommitsPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/commits`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface DiffPullReqQueryParams { + /** + * provide path for diff operation + */ + path?: string[] +} + +export interface DiffPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type DiffPullReqProps = Omit< + GetProps, + 'path' +> & + DiffPullReqPathParams + +export const DiffPullReq = ({ repo_ref, pullreq_number, ...props }: DiffPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/diff`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDiffPullReqProps = Omit< + UseGetProps, + 'path' +> & + DiffPullReqPathParams + +export const useDiffPullReq = ({ repo_ref, pullreq_number, ...props }: UseDiffPullReqProps) => + useGet( + (paramsInPath: DiffPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/diff`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface DiffPullReqPostPathParams { + repo_ref: string + pullreq_number: number +} + +export type DiffPullReqPostProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DiffPullReqPostPathParams + +export const DiffPullReqPost = ({ repo_ref, pullreq_number, ...props }: DiffPullReqPostProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/diff`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDiffPullReqPostProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DiffPullReqPostPathParams + +export const useDiffPullReqPost = ({ repo_ref, pullreq_number, ...props }: UseDiffPullReqPostProps) => + useMutate( + 'POST', + (paramsInPath: DiffPullReqPostPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/diff`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface FileViewListPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type FileViewListPullReqProps = Omit< + GetProps, + 'path' +> & + FileViewListPullReqPathParams + +export const FileViewListPullReq = ({ repo_ref, pullreq_number, ...props }: FileViewListPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/file-views`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFileViewListPullReqProps = Omit< + UseGetProps, + 'path' +> & + FileViewListPullReqPathParams + +export const useFileViewListPullReq = ({ repo_ref, pullreq_number, ...props }: UseFileViewListPullReqProps) => + useGet( + (paramsInPath: FileViewListPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/file-views`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface FileViewAddPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type FileViewAddPullReqProps = Omit< + MutateProps< + TypesPullReqFileView, + UsererrorError, + void, + OpenapiFileViewAddPullReqRequest, + FileViewAddPullReqPathParams + >, + 'path' | 'verb' +> & + FileViewAddPullReqPathParams + +export const FileViewAddPullReq = ({ repo_ref, pullreq_number, ...props }: FileViewAddPullReqProps) => ( + + verb="PUT" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/file-views`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFileViewAddPullReqProps = Omit< + UseMutateProps< + TypesPullReqFileView, + UsererrorError, + void, + OpenapiFileViewAddPullReqRequest, + FileViewAddPullReqPathParams + >, + 'path' | 'verb' +> & + FileViewAddPullReqPathParams + +export const useFileViewAddPullReq = ({ repo_ref, pullreq_number, ...props }: UseFileViewAddPullReqProps) => + useMutate( + 'PUT', + (paramsInPath: FileViewAddPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/file-views`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface FileViewDeletePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type FileViewDeletePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + FileViewDeletePullReqPathParams + +export const FileViewDeletePullReq = ({ repo_ref, pullreq_number, ...props }: FileViewDeletePullReqProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/file-views`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFileViewDeletePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + FileViewDeletePullReqPathParams + +export const useFileViewDeletePullReq = ({ repo_ref, pullreq_number, ...props }: UseFileViewDeletePullReqProps) => + useMutate( + 'DELETE', + (paramsInPath: FileViewDeletePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/file-views`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface MergePullReqOpPathParams { + repo_ref: string + pullreq_number: number +} + +export type MergePullReqOpProps = Omit< + MutateProps< + TypesMergeResponse, + UsererrorError | TypesMergeViolations, + void, + OpenapiMergePullReq, + MergePullReqOpPathParams + >, + 'path' | 'verb' +> & + MergePullReqOpPathParams + +export const MergePullReqOp = ({ repo_ref, pullreq_number, ...props }: MergePullReqOpProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/merge`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMergePullReqOpProps = Omit< + UseMutateProps< + TypesMergeResponse, + UsererrorError | TypesMergeViolations, + void, + OpenapiMergePullReq, + MergePullReqOpPathParams + >, + 'path' | 'verb' +> & + MergePullReqOpPathParams + +export const useMergePullReqOp = ({ repo_ref, pullreq_number, ...props }: UseMergePullReqOpProps) => + useMutate< + TypesMergeResponse, + UsererrorError | TypesMergeViolations, + void, + OpenapiMergePullReq, + MergePullReqOpPathParams + >( + 'POST', + (paramsInPath: MergePullReqOpPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/merge`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface PullReqMetaDataPathParams { + repo_ref: string + pullreq_number: number +} + +export type PullReqMetaDataProps = Omit< + GetProps, + 'path' +> & + PullReqMetaDataPathParams + +export const PullReqMetaData = ({ repo_ref, pullreq_number, ...props }: PullReqMetaDataProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/metadata`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UsePullReqMetaDataProps = Omit< + UseGetProps, + 'path' +> & + PullReqMetaDataPathParams + +export const usePullReqMetaData = ({ repo_ref, pullreq_number, ...props }: UsePullReqMetaDataProps) => + useGet( + (paramsInPath: PullReqMetaDataPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/metadata`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ReviewerListPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type ReviewerListPullReqProps = Omit< + GetProps, + 'path' +> & + ReviewerListPullReqPathParams + +export const ReviewerListPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewerListPullReqProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviewers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseReviewerListPullReqProps = Omit< + UseGetProps, + 'path' +> & + ReviewerListPullReqPathParams + +export const useReviewerListPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewerListPullReqProps) => + useGet( + (paramsInPath: ReviewerListPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviewers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ReviewerAddPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type ReviewerAddPullReqProps = Omit< + MutateProps< + TypesPullReqReviewer, + UsererrorError, + void, + OpenapiReviewerAddPullReqRequest, + ReviewerAddPullReqPathParams + >, + 'path' | 'verb' +> & + ReviewerAddPullReqPathParams + +export const ReviewerAddPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewerAddPullReqProps) => ( + + verb="PUT" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviewers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseReviewerAddPullReqProps = Omit< + UseMutateProps< + TypesPullReqReviewer, + UsererrorError, + void, + OpenapiReviewerAddPullReqRequest, + ReviewerAddPullReqPathParams + >, + 'path' | 'verb' +> & + ReviewerAddPullReqPathParams + +export const useReviewerAddPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewerAddPullReqProps) => + useMutate( + 'PUT', + (paramsInPath: ReviewerAddPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviewers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ReviewerDeletePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type ReviewerDeletePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + ReviewerDeletePullReqPathParams + +export const ReviewerDeletePullReq = ({ repo_ref, pullreq_number, ...props }: ReviewerDeletePullReqProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviewers`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseReviewerDeletePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + ReviewerDeletePullReqPathParams + +export const useReviewerDeletePullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewerDeletePullReqProps) => + useMutate( + 'DELETE', + (paramsInPath: ReviewerDeletePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviewers`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface ReviewSubmitPullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type ReviewSubmitPullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + ReviewSubmitPullReqPathParams + +export const ReviewSubmitPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewSubmitPullReqProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviews`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseReviewSubmitPullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + ReviewSubmitPullReqPathParams + +export const useReviewSubmitPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewSubmitPullReqProps) => + useMutate( + 'POST', + (paramsInPath: ReviewSubmitPullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviews`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface StatePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type StatePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + StatePullReqPathParams + +export const StatePullReq = ({ repo_ref, pullreq_number, ...props }: StatePullReqProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/state`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseStatePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + StatePullReqPathParams + +export const useStatePullReq = ({ repo_ref, pullreq_number, ...props }: UseStatePullReqProps) => + useMutate( + 'POST', + (paramsInPath: StatePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/state`, + { base: getConfig('api/v1'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + +export interface PurgeRepositoryQueryParams { + /** + * The exact time the resource was delete at in epoch format. + */ + deleted_at: number +} + +export interface PurgeRepositoryPathParams { + repo_ref: string +} + +export type PurgeRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> & + PurgeRepositoryPathParams + +export const PurgeRepository = ({ repo_ref, ...props }: PurgeRepositoryProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/purge`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UsePurgeRepositoryProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + PurgeRepositoryPathParams + +export const usePurgeRepository = ({ repo_ref, ...props }: UsePurgeRepositoryProps) => + useMutate( + 'POST', + (paramsInPath: PurgeRepositoryPathParams) => `/repos/${paramsInPath.repo_ref}/purge`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface GetRawQueryParams { + /** + * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. + */ + git_ref?: string +} + +export interface GetRawPathParams { + repo_ref: string + path: string +} + +export type GetRawProps = Omit, 'path'> & + GetRawPathParams + +export const GetRaw = ({ repo_ref, path, ...props }: GetRawProps) => ( + + path={`/repos/${repo_ref}/raw/${path}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetRawProps = Omit, 'path'> & + GetRawPathParams + +export const useGetRaw = ({ repo_ref, path, ...props }: UseGetRawProps) => + useGet( + (paramsInPath: GetRawPathParams) => `/repos/${paramsInPath.repo_ref}/raw/${paramsInPath.path}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, path }, ...props } + ) + +export interface RestoreRepositoryQueryParams { + /** + * The exact time the resource was delete at in epoch format. + */ + deleted_at: number +} + +export interface RestoreRepositoryPathParams { + repo_ref: string +} + +export type RestoreRepositoryProps = Omit< + MutateProps< + RepoRepositoryOutput, + UsererrorError, + RestoreRepositoryQueryParams, + OpenapiRestoreRequest, + RestoreRepositoryPathParams + >, + 'path' | 'verb' +> & + RestoreRepositoryPathParams + +export const RestoreRepository = ({ repo_ref, ...props }: RestoreRepositoryProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/restore`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRestoreRepositoryProps = Omit< + UseMutateProps< + RepoRepositoryOutput, + UsererrorError, + RestoreRepositoryQueryParams, + OpenapiRestoreRequest, + RestoreRepositoryPathParams + >, + 'path' | 'verb' +> & + RestoreRepositoryPathParams + +export const useRestoreRepository = ({ repo_ref, ...props }: UseRestoreRepositoryProps) => + useMutate< + RepoRepositoryOutput, + UsererrorError, + RestoreRepositoryQueryParams, + OpenapiRestoreRequest, + RestoreRepositoryPathParams + >('POST', (paramsInPath: RestoreRepositoryPathParams) => `/repos/${paramsInPath.repo_ref}/restore`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface RuleListQueryParams { + /** + * The substring by which the repository protection rules are filtered. + */ + query?: string + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The field by which the protection rules are sorted. + */ + sort?: 'created_at' | 'identifier' | 'uid' | 'updated_at' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface RuleListPathParams { + repo_ref: string +} + +export type RuleListProps = Omit< + GetProps, + 'path' +> & + RuleListPathParams + +export const RuleList = ({ repo_ref, ...props }: RuleListProps) => ( + + path={`/repos/${repo_ref}/rules`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRuleListProps = Omit< + UseGetProps, + 'path' +> & + RuleListPathParams + +export const useRuleList = ({ repo_ref, ...props }: UseRuleListProps) => + useGet( + (paramsInPath: RuleListPathParams) => `/repos/${paramsInPath.repo_ref}/rules`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface RuleAddPathParams { + repo_ref: string +} + +export interface RuleAddRequestBody { + definition?: OpenapiRuleDefinition + description?: string + identifier?: string + pattern?: ProtectionPattern + state?: EnumRuleState + type?: OpenapiRuleType + uid?: string +} + +export type RuleAddProps = Omit< + MutateProps, + 'path' | 'verb' +> & + RuleAddPathParams + +export const RuleAdd = ({ repo_ref, ...props }: RuleAddProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/rules`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRuleAddProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + RuleAddPathParams + +export const useRuleAdd = ({ repo_ref, ...props }: UseRuleAddProps) => + useMutate( + 'POST', + (paramsInPath: RuleAddPathParams) => `/repos/${paramsInPath.repo_ref}/rules`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface RuleDeletePathParams { + repo_ref: string +} + +export type RuleDeleteProps = Omit< + MutateProps, + 'path' | 'verb' +> & + RuleDeletePathParams + +export const RuleDelete = ({ repo_ref, ...props }: RuleDeleteProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/rules`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRuleDeleteProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + RuleDeletePathParams + +export const useRuleDelete = ({ repo_ref, ...props }: UseRuleDeleteProps) => + useMutate( + 'DELETE', + (paramsInPath: RuleDeletePathParams) => `/repos/${paramsInPath.repo_ref}/rules`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface RuleGetPathParams { + repo_ref: string + rule_identifier: string +} + +export type RuleGetProps = Omit, 'path'> & + RuleGetPathParams + +export const RuleGet = ({ repo_ref, rule_identifier, ...props }: RuleGetProps) => ( + + path={`/repos/${repo_ref}/rules/${rule_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRuleGetProps = Omit, 'path'> & + RuleGetPathParams + +export const useRuleGet = ({ repo_ref, rule_identifier, ...props }: UseRuleGetProps) => + useGet( + (paramsInPath: RuleGetPathParams) => `/repos/${paramsInPath.repo_ref}/rules/${paramsInPath.rule_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, rule_identifier }, ...props } + ) + +export interface RuleUpdatePathParams { + repo_ref: string + rule_identifier: string +} + +export interface RuleUpdateRequestBody { + definition?: OpenapiRuleDefinition + description?: string | null + identifier?: string | null + pattern?: ProtectionPattern + state?: EnumRuleState + type?: OpenapiRuleType + uid?: string | null +} + +export type RuleUpdateProps = Omit< + MutateProps, + 'path' | 'verb' +> & + RuleUpdatePathParams + +export const RuleUpdate = ({ repo_ref, rule_identifier, ...props }: RuleUpdateProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/rules/${rule_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRuleUpdateProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + RuleUpdatePathParams + +export const useRuleUpdate = ({ repo_ref, rule_identifier, ...props }: UseRuleUpdateProps) => + useMutate( + 'PATCH', + (paramsInPath: RuleUpdatePathParams) => `/repos/${paramsInPath.repo_ref}/rules/${paramsInPath.rule_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, rule_identifier }, ...props } + ) + +export interface ListRepositoryServiceAccountsPathParams { + repo_ref: string +} + +export type ListRepositoryServiceAccountsProps = Omit< + GetProps, + 'path' +> & + ListRepositoryServiceAccountsPathParams + +export const ListRepositoryServiceAccounts = ({ repo_ref, ...props }: ListRepositoryServiceAccountsProps) => ( + + path={`/repos/${repo_ref}/service-accounts`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListRepositoryServiceAccountsProps = Omit< + UseGetProps, + 'path' +> & + ListRepositoryServiceAccountsPathParams + +export const useListRepositoryServiceAccounts = ({ repo_ref, ...props }: UseListRepositoryServiceAccountsProps) => + useGet( + (paramsInPath: ListRepositoryServiceAccountsPathParams) => `/repos/${paramsInPath.repo_ref}/service-accounts`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface FindGeneralSettingsPathParams { + repo_ref: string +} + +export type FindGeneralSettingsProps = Omit< + GetProps, + 'path' +> & + FindGeneralSettingsPathParams + +export const FindGeneralSettings = ({ repo_ref, ...props }: FindGeneralSettingsProps) => ( + + path={`/repos/${repo_ref}/settings/general`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindGeneralSettingsProps = Omit< + UseGetProps, + 'path' +> & + FindGeneralSettingsPathParams + +export const useFindGeneralSettings = ({ repo_ref, ...props }: UseFindGeneralSettingsProps) => + useGet( + (paramsInPath: FindGeneralSettingsPathParams) => `/repos/${paramsInPath.repo_ref}/settings/general`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface UpdateGeneralSettingsPathParams { + repo_ref: string +} + +export type UpdateGeneralSettingsProps = Omit< + MutateProps< + ReposettingsGeneralSettings, + UsererrorError, + void, + OpenapiGeneralSettingsRequest, + UpdateGeneralSettingsPathParams + >, + 'path' | 'verb' +> & + UpdateGeneralSettingsPathParams + +export const UpdateGeneralSettings = ({ repo_ref, ...props }: UpdateGeneralSettingsProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/settings/general`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateGeneralSettingsProps = Omit< + UseMutateProps< + ReposettingsGeneralSettings, + UsererrorError, + void, + OpenapiGeneralSettingsRequest, + UpdateGeneralSettingsPathParams + >, + 'path' | 'verb' +> & + UpdateGeneralSettingsPathParams + +export const useUpdateGeneralSettings = ({ repo_ref, ...props }: UseUpdateGeneralSettingsProps) => + useMutate< + ReposettingsGeneralSettings, + UsererrorError, + void, + OpenapiGeneralSettingsRequest, + UpdateGeneralSettingsPathParams + >('PATCH', (paramsInPath: UpdateGeneralSettingsPathParams) => `/repos/${paramsInPath.repo_ref}/settings/general`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface FindSecuritySettingsPathParams { + repo_ref: string +} + +export type FindSecuritySettingsProps = Omit< + GetProps, + 'path' +> & + FindSecuritySettingsPathParams + +export const FindSecuritySettings = ({ repo_ref, ...props }: FindSecuritySettingsProps) => ( + + path={`/repos/${repo_ref}/settings/security`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindSecuritySettingsProps = Omit< + UseGetProps, + 'path' +> & + FindSecuritySettingsPathParams + +export const useFindSecuritySettings = ({ repo_ref, ...props }: UseFindSecuritySettingsProps) => + useGet( + (paramsInPath: FindSecuritySettingsPathParams) => `/repos/${paramsInPath.repo_ref}/settings/security`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface UpdateSecuritySettingsPathParams { + repo_ref: string +} + +export type UpdateSecuritySettingsProps = Omit< + MutateProps< + ReposettingsSecuritySettings, + UsererrorError, + void, + OpenapiSecuritySettingsRequest, + UpdateSecuritySettingsPathParams + >, + 'path' | 'verb' +> & + UpdateSecuritySettingsPathParams + +export const UpdateSecuritySettings = ({ repo_ref, ...props }: UpdateSecuritySettingsProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/settings/security`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateSecuritySettingsProps = Omit< + UseMutateProps< + ReposettingsSecuritySettings, + UsererrorError, + void, + OpenapiSecuritySettingsRequest, + UpdateSecuritySettingsPathParams + >, + 'path' | 'verb' +> & + UpdateSecuritySettingsPathParams + +export const useUpdateSecuritySettings = ({ repo_ref, ...props }: UseUpdateSecuritySettingsProps) => + useMutate< + ReposettingsSecuritySettings, + UsererrorError, + void, + OpenapiSecuritySettingsRequest, + UpdateSecuritySettingsPathParams + >('PATCH', (paramsInPath: UpdateSecuritySettingsPathParams) => `/repos/${paramsInPath.repo_ref}/settings/security`, { + base: getConfig('api/v1'), + pathParams: { repo_ref }, + ...props + }) + +export interface SummaryPathParams { + repo_ref: string +} + +export type SummaryProps = Omit, 'path'> & + SummaryPathParams + +export const Summary = ({ repo_ref, ...props }: SummaryProps) => ( + + path={`/repos/${repo_ref}/summary`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseSummaryProps = Omit< + UseGetProps, + 'path' +> & + SummaryPathParams + +export const useSummary = ({ repo_ref, ...props }: UseSummaryProps) => + useGet( + (paramsInPath: SummaryPathParams) => `/repos/${paramsInPath.repo_ref}/summary`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface ListTagsQueryParams { + /** + * Indicates whether optional commit information should be included in the response. + */ + include_commit?: boolean + /** + * The substring by which the tags are filtered. + */ + query?: string + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The data by which the tags are sorted. + */ + sort?: 'name' | 'date' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListTagsPathParams { + repo_ref: string +} + +export type ListTagsProps = Omit< + GetProps, + 'path' +> & + ListTagsPathParams + +export const ListTags = ({ repo_ref, ...props }: ListTagsProps) => ( + + path={`/repos/${repo_ref}/tags`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListTagsProps = Omit< + UseGetProps, + 'path' +> & + ListTagsPathParams + +export const useListTags = ({ repo_ref, ...props }: UseListTagsProps) => + useGet( + (paramsInPath: ListTagsPathParams) => `/repos/${paramsInPath.repo_ref}/tags`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CreateTagPathParams { + repo_ref: string +} + +export type CreateTagProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreateTagPathParams + +export const CreateTag = ({ repo_ref, ...props }: CreateTagProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/tags`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateTagProps = Omit< + UseMutateProps< + RepoCommitTag, + UsererrorError | TypesRulesViolations, + void, + OpenapiCreateTagRequest, + CreateTagPathParams + >, + 'path' | 'verb' +> & + CreateTagPathParams + +export const useCreateTag = ({ repo_ref, ...props }: UseCreateTagProps) => + useMutate( + 'POST', + (paramsInPath: CreateTagPathParams) => `/repos/${paramsInPath.repo_ref}/tags`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface DeleteTagQueryParams { + /** + * Bypass rule violations if possible. + */ + bypass_rules?: boolean +} + +export interface DeleteTagPathParams { + repo_ref: string +} + +export type DeleteTagProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeleteTagPathParams + +export const DeleteTag = ({ repo_ref, ...props }: DeleteTagProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/tags`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteTagProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeleteTagPathParams + +export const useDeleteTag = ({ repo_ref, ...props }: UseDeleteTagProps) => + useMutate( + 'DELETE', + (paramsInPath: DeleteTagPathParams) => `/repos/${paramsInPath.repo_ref}/tags`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface RepoArtifactUploadPathParams { + repo_ref: string +} + +export type RepoArtifactUploadProps = Omit< + MutateProps, + 'path' | 'verb' +> & + RepoArtifactUploadPathParams + +export const RepoArtifactUpload = ({ repo_ref, ...props }: RepoArtifactUploadProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/uploads`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRepoArtifactUploadProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + RepoArtifactUploadPathParams + +export const useRepoArtifactUpload = ({ repo_ref, ...props }: UseRepoArtifactUploadProps) => + useMutate( + 'POST', + (paramsInPath: RepoArtifactUploadPathParams) => `/repos/${paramsInPath.repo_ref}/uploads`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface RepoArtifactDownloadPathParams { + repo_ref: string + file_ref: string +} + +export type RepoArtifactDownloadProps = Omit< + GetProps, + 'path' +> & + RepoArtifactDownloadPathParams + +export const RepoArtifactDownload = ({ repo_ref, file_ref, ...props }: RepoArtifactDownloadProps) => ( + + path={`/repos/${repo_ref}/uploads/${file_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRepoArtifactDownloadProps = Omit< + UseGetProps, + 'path' +> & + RepoArtifactDownloadPathParams + +export const useRepoArtifactDownload = ({ repo_ref, file_ref, ...props }: UseRepoArtifactDownloadProps) => + useGet( + (paramsInPath: RepoArtifactDownloadPathParams) => + `/repos/${paramsInPath.repo_ref}/uploads/${paramsInPath.file_ref}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, file_ref }, ...props } + ) + +export interface ListWebhooksQueryParams { + /** + * The substring which is used to filter the webhooks by their identifier. + */ + query?: string + /** + * The data by which the webhooks are sorted. + */ + sort?: 'id' | 'uid' | 'display_name' | 'created' | 'updated' + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListWebhooksPathParams { + repo_ref: string +} + +export type ListWebhooksProps = Omit< + GetProps, + 'path' +> & + ListWebhooksPathParams + +export const ListWebhooks = ({ repo_ref, ...props }: ListWebhooksProps) => ( + + path={`/repos/${repo_ref}/webhooks`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListWebhooksProps = Omit< + UseGetProps, + 'path' +> & + ListWebhooksPathParams + +export const useListWebhooks = ({ repo_ref, ...props }: UseListWebhooksProps) => + useGet( + (paramsInPath: ListWebhooksPathParams) => `/repos/${paramsInPath.repo_ref}/webhooks`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface CreateWebhookPathParams { + repo_ref: string +} + +export type CreateWebhookProps = Omit< + MutateProps, + 'path' | 'verb' +> & + CreateWebhookPathParams + +export const CreateWebhook = ({ repo_ref, ...props }: CreateWebhookProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/webhooks`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateWebhookProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + CreateWebhookPathParams + +export const useCreateWebhook = ({ repo_ref, ...props }: UseCreateWebhookProps) => + useMutate( + 'POST', + (paramsInPath: CreateWebhookPathParams) => `/repos/${paramsInPath.repo_ref}/webhooks`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface DeleteWebhookPathParams { + repo_ref: string +} + +export type DeleteWebhookProps = Omit< + MutateProps, + 'path' | 'verb' +> & + DeleteWebhookPathParams + +export const DeleteWebhook = ({ repo_ref, ...props }: DeleteWebhookProps) => ( + + verb="DELETE" + path={`/repos/${repo_ref}/webhooks`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteWebhookProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + DeleteWebhookPathParams + +export const useDeleteWebhook = ({ repo_ref, ...props }: UseDeleteWebhookProps) => + useMutate( + 'DELETE', + (paramsInPath: DeleteWebhookPathParams) => `/repos/${paramsInPath.repo_ref}/webhooks`, + { base: getConfig('api/v1'), pathParams: { repo_ref }, ...props } + ) + +export interface GetWebhookPathParams { + repo_ref: string + webhook_identifier: number +} + +export type GetWebhookProps = Omit, 'path'> & + GetWebhookPathParams + +export const GetWebhook = ({ repo_ref, webhook_identifier, ...props }: GetWebhookProps) => ( + + path={`/repos/${repo_ref}/webhooks/${webhook_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetWebhookProps = Omit< + UseGetProps, + 'path' +> & + GetWebhookPathParams + +export const useGetWebhook = ({ repo_ref, webhook_identifier, ...props }: UseGetWebhookProps) => + useGet( + (paramsInPath: GetWebhookPathParams) => + `/repos/${paramsInPath.repo_ref}/webhooks/${paramsInPath.webhook_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, webhook_identifier }, ...props } + ) + +export interface UpdateWebhookPathParams { + repo_ref: string + webhook_identifier: number +} + +export type UpdateWebhookProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateWebhookPathParams + +export const UpdateWebhook = ({ repo_ref, webhook_identifier, ...props }: UpdateWebhookProps) => ( + + verb="PATCH" + path={`/repos/${repo_ref}/webhooks/${webhook_identifier}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateWebhookProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateWebhookPathParams + +export const useUpdateWebhook = ({ repo_ref, webhook_identifier, ...props }: UseUpdateWebhookProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateWebhookPathParams) => + `/repos/${paramsInPath.repo_ref}/webhooks/${paramsInPath.webhook_identifier}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, webhook_identifier }, ...props } + ) + +export interface ListWebhookExecutionsQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListWebhookExecutionsPathParams { + repo_ref: string + webhook_identifier: number +} + +export type ListWebhookExecutionsProps = Omit< + GetProps, + 'path' +> & + ListWebhookExecutionsPathParams + +export const ListWebhookExecutions = ({ repo_ref, webhook_identifier, ...props }: ListWebhookExecutionsProps) => ( + + path={`/repos/${repo_ref}/webhooks/${webhook_identifier}/executions`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListWebhookExecutionsProps = Omit< + UseGetProps< + TypesWebhookExecution[], + UsererrorError, + ListWebhookExecutionsQueryParams, + ListWebhookExecutionsPathParams + >, + 'path' +> & + ListWebhookExecutionsPathParams + +export const useListWebhookExecutions = ({ repo_ref, webhook_identifier, ...props }: UseListWebhookExecutionsProps) => + useGet( + (paramsInPath: ListWebhookExecutionsPathParams) => + `/repos/${paramsInPath.repo_ref}/webhooks/${paramsInPath.webhook_identifier}/executions`, + { base: getConfig('api/v1'), pathParams: { repo_ref, webhook_identifier }, ...props } + ) + +export interface GetWebhookExecutionQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface GetWebhookExecutionPathParams { + repo_ref: string + webhook_identifier: number + webhook_execution_id: number +} + +export type GetWebhookExecutionProps = Omit< + GetProps, + 'path' +> & + GetWebhookExecutionPathParams + +export const GetWebhookExecution = ({ + repo_ref, + webhook_identifier, + webhook_execution_id, + ...props +}: GetWebhookExecutionProps) => ( + + path={`/repos/${repo_ref}/webhooks/${webhook_identifier}/executions/${webhook_execution_id}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetWebhookExecutionProps = Omit< + UseGetProps, + 'path' +> & + GetWebhookExecutionPathParams + +export const useGetWebhookExecution = ({ + repo_ref, + webhook_identifier, + webhook_execution_id, + ...props +}: UseGetWebhookExecutionProps) => + useGet( + (paramsInPath: GetWebhookExecutionPathParams) => + `/repos/${paramsInPath.repo_ref}/webhooks/${paramsInPath.webhook_identifier}/executions/${paramsInPath.webhook_execution_id}`, + { base: getConfig('api/v1'), pathParams: { repo_ref, webhook_identifier, webhook_execution_id }, ...props } + ) + +export interface ImportRepositoryQueryParams { + /** + * path of parent space (Not needed in standalone). + */ + space_path?: string +} + +export interface ImportRepositoryRequestBody { + description?: string + identifier?: string + parent_ref?: string + pipelines?: ImporterPipelineOption + provider?: ImporterProvider + provider_repo?: string + uid?: string +} + +export type ImportRepositoryProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const ImportRepository = (props: ImportRepositoryProps) => ( + + verb="POST" + path={`/repos/import`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseImportRepositoryProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useImportRepository = (props: UseImportRepositoryProps) => + useMutate( + 'POST', + `/repos/import`, + { base: getConfig('api/v1'), ...props } + ) + +export type ListGitignoreProps = Omit, 'path'> + +export const ListGitignore = (props: ListGitignoreProps) => ( + path={`/resources/gitignore`} base={getConfig('api/v1')} {...props} /> +) + +export type UseListGitignoreProps = Omit, 'path'> + +export const useListGitignore = (props: UseListGitignoreProps) => + useGet(`/resources/gitignore`, { base: getConfig('api/v1'), ...props }) + +export interface ListLicensesResponse { + label?: string + value?: string +} +;[] + +export type ListLicensesProps = Omit, 'path'> + +export const ListLicenses = (props: ListLicensesProps) => ( + + path={`/resources/license`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListLicensesProps = Omit, 'path'> + +export const useListLicenses = (props: UseListLicensesProps) => + useGet(`/resources/license`, { + base: getConfig('api/v1'), + ...props + }) + +export type CreateSecretProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateSecret = (props: CreateSecretProps) => ( + + verb="POST" + path={`/secrets`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateSecretProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreateSecret = (props: UseCreateSecretProps) => + useMutate('POST', `/secrets`, { + base: getConfig('api/v1'), + ...props + }) + +export type DeleteSecretProps = Omit, 'path' | 'verb'> + +export const DeleteSecret = (props: DeleteSecretProps) => ( + + verb="DELETE" + path={`/secrets`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteSecretProps = Omit, 'path' | 'verb'> + +export const useDeleteSecret = (props: UseDeleteSecretProps) => + useMutate('DELETE', `/secrets`, { base: getConfig('api/v1'), ...props }) + +export interface FindSecretPathParams { + secret_ref: string +} + +export type FindSecretProps = Omit, 'path'> & + FindSecretPathParams + +export const FindSecret = ({ secret_ref, ...props }: FindSecretProps) => ( + + path={`/secrets/${secret_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindSecretProps = Omit, 'path'> & + FindSecretPathParams + +export const useFindSecret = ({ secret_ref, ...props }: UseFindSecretProps) => + useGet( + (paramsInPath: FindSecretPathParams) => `/secrets/${paramsInPath.secret_ref}`, + { base: getConfig('api/v1'), pathParams: { secret_ref }, ...props } + ) + +export interface UpdateSecretPathParams { + secret_ref: string +} + +export type UpdateSecretProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateSecretPathParams + +export const UpdateSecret = ({ secret_ref, ...props }: UpdateSecretProps) => ( + + verb="PATCH" + path={`/secrets/${secret_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateSecretProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateSecretPathParams + +export const useUpdateSecret = ({ secret_ref, ...props }: UseUpdateSecretProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateSecretPathParams) => `/secrets/${paramsInPath.secret_ref}`, + { base: getConfig('api/v1'), pathParams: { secret_ref }, ...props } + ) + +export type CreateSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateSpace = (props: CreateSpaceProps) => ( + + verb="POST" + path={`/spaces`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreateSpace = (props: UseCreateSpaceProps) => + useMutate('POST', `/spaces`, { + base: getConfig('api/v1'), + ...props + }) + +export type DeleteSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const DeleteSpace = (props: DeleteSpaceProps) => ( + + verb="DELETE" + path={`/spaces`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useDeleteSpace = (props: UseDeleteSpaceProps) => + useMutate('DELETE', `/spaces`, { + base: getConfig('api/v1'), + ...props + }) + +export interface GetSpacePathParams { + space_ref: string +} + +export type GetSpaceProps = Omit, 'path'> & + GetSpacePathParams + +export const GetSpace = ({ space_ref, ...props }: GetSpaceProps) => ( + + path={`/spaces/${space_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseGetSpaceProps = Omit, 'path'> & + GetSpacePathParams + +export const useGetSpace = ({ space_ref, ...props }: UseGetSpaceProps) => + useGet( + (paramsInPath: GetSpacePathParams) => `/spaces/${paramsInPath.space_ref}`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface UpdateSpacePathParams { + space_ref: string +} + +export type UpdateSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateSpacePathParams + +export const UpdateSpace = ({ space_ref, ...props }: UpdateSpaceProps) => ( + + verb="PATCH" + path={`/spaces/${space_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateSpacePathParams + +export const useUpdateSpace = ({ space_ref, ...props }: UseUpdateSpaceProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateSpacePathParams) => `/spaces/${paramsInPath.space_ref}`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ListConnectorsQueryParams { + /** + * The substring which is used to filter the repositories by their path name. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListConnectorsPathParams { + space_ref: string +} + +export type ListConnectorsProps = Omit< + GetProps, + 'path' +> & + ListConnectorsPathParams + +export const ListConnectors = ({ space_ref, ...props }: ListConnectorsProps) => ( + + path={`/spaces/${space_ref}/connectors`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListConnectorsProps = Omit< + UseGetProps, + 'path' +> & + ListConnectorsPathParams + +export const useListConnectors = ({ space_ref, ...props }: UseListConnectorsProps) => + useGet( + (paramsInPath: ListConnectorsPathParams) => `/spaces/${paramsInPath.space_ref}/connectors`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ExportSpacePathParams { + space_ref: string +} + +export type ExportSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> & + ExportSpacePathParams + +export const ExportSpace = ({ space_ref, ...props }: ExportSpaceProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/export`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseExportSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + ExportSpacePathParams + +export const useExportSpace = ({ space_ref, ...props }: UseExportSpaceProps) => + useMutate( + 'POST', + (paramsInPath: ExportSpacePathParams) => `/spaces/${paramsInPath.space_ref}/export`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ExportProgressSpacePathParams { + space_ref: string +} + +export type ExportProgressSpaceProps = Omit< + GetProps, + 'path' +> & + ExportProgressSpacePathParams + +export const ExportProgressSpace = ({ space_ref, ...props }: ExportProgressSpaceProps) => ( + + path={`/spaces/${space_ref}/export-progress`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseExportProgressSpaceProps = Omit< + UseGetProps, + 'path' +> & + ExportProgressSpacePathParams + +export const useExportProgressSpace = ({ space_ref, ...props }: UseExportProgressSpaceProps) => + useGet( + (paramsInPath: ExportProgressSpacePathParams) => `/spaces/${paramsInPath.space_ref}/export-progress`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface MembershipListQueryParams { + /** + * The substring by which the space members are filtered. + */ + query?: string + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The field by which the space members are sorted. + */ + sort?: 'created' | 'name' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface MembershipListPathParams { + space_ref: string +} + +export type MembershipListProps = Omit< + GetProps, + 'path' +> & + MembershipListPathParams + +export const MembershipList = ({ space_ref, ...props }: MembershipListProps) => ( + + path={`/spaces/${space_ref}/members`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMembershipListProps = Omit< + UseGetProps, + 'path' +> & + MembershipListPathParams + +export const useMembershipList = ({ space_ref, ...props }: UseMembershipListProps) => + useGet( + (paramsInPath: MembershipListPathParams) => `/spaces/${paramsInPath.space_ref}/members`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface MembershipAddPathParams { + space_ref: string +} + +export interface MembershipAddRequestBody { + role?: EnumMembershipRole + user_uid?: string +} + +export type MembershipAddProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MembershipAddPathParams + +export const MembershipAdd = ({ space_ref, ...props }: MembershipAddProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/members`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMembershipAddProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MembershipAddPathParams + +export const useMembershipAdd = ({ space_ref, ...props }: UseMembershipAddProps) => + useMutate( + 'POST', + (paramsInPath: MembershipAddPathParams) => `/spaces/${paramsInPath.space_ref}/members`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface MembershipDeletePathParams { + space_ref: string +} + +export type MembershipDeleteProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MembershipDeletePathParams + +export const MembershipDelete = ({ space_ref, ...props }: MembershipDeleteProps) => ( + + verb="DELETE" + path={`/spaces/${space_ref}/members`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMembershipDeleteProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MembershipDeletePathParams + +export const useMembershipDelete = ({ space_ref, ...props }: UseMembershipDeleteProps) => + useMutate( + 'DELETE', + (paramsInPath: MembershipDeletePathParams) => `/spaces/${paramsInPath.space_ref}/members`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface MembershipUpdatePathParams { + space_ref: string + user_uid: string +} + +export interface MembershipUpdateRequestBody { + role?: EnumMembershipRole +} + +export type MembershipUpdateProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MembershipUpdatePathParams + +export const MembershipUpdate = ({ space_ref, user_uid, ...props }: MembershipUpdateProps) => ( + + verb="PATCH" + path={`/spaces/${space_ref}/members/${user_uid}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMembershipUpdateProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MembershipUpdatePathParams + +export const useMembershipUpdate = ({ space_ref, user_uid, ...props }: UseMembershipUpdateProps) => + useMutate( + 'PATCH', + (paramsInPath: MembershipUpdatePathParams) => `/spaces/${paramsInPath.space_ref}/members/${paramsInPath.user_uid}`, + { base: getConfig('api/v1'), pathParams: { space_ref, user_uid }, ...props } + ) + +export interface MoveSpacePathParams { + space_ref: string +} + +export type MoveSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> & + MoveSpacePathParams + +export const MoveSpace = ({ space_ref, ...props }: MoveSpaceProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/move`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMoveSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + MoveSpacePathParams + +export const useMoveSpace = ({ space_ref, ...props }: UseMoveSpaceProps) => + useMutate( + 'POST', + (paramsInPath: MoveSpacePathParams) => `/spaces/${paramsInPath.space_ref}/move`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface UpdateSpacePublicAccessPathParams { + space_ref: string +} + +export type UpdateSpacePublicAccessProps = Omit< + MutateProps< + SpaceSpaceOutput, + UsererrorError, + void, + OpenapiUpdateSpacePublicAccessRequest, + UpdateSpacePublicAccessPathParams + >, + 'path' | 'verb' +> & + UpdateSpacePublicAccessPathParams + +export const UpdateSpacePublicAccess = ({ space_ref, ...props }: UpdateSpacePublicAccessProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/public-access`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateSpacePublicAccessProps = Omit< + UseMutateProps< + SpaceSpaceOutput, + UsererrorError, + void, + OpenapiUpdateSpacePublicAccessRequest, + UpdateSpacePublicAccessPathParams + >, + 'path' | 'verb' +> & + UpdateSpacePublicAccessPathParams + +export const useUpdateSpacePublicAccess = ({ space_ref, ...props }: UseUpdateSpacePublicAccessProps) => + useMutate< + SpaceSpaceOutput, + UsererrorError, + void, + OpenapiUpdateSpacePublicAccessRequest, + UpdateSpacePublicAccessPathParams + >('POST', (paramsInPath: UpdateSpacePublicAccessPathParams) => `/spaces/${paramsInPath.space_ref}/public-access`, { + base: getConfig('api/v1'), + pathParams: { space_ref }, + ...props + }) + +export interface PurgeSpaceQueryParams { + /** + * The exact time the resource was delete at in epoch format. + */ + deleted_at: number +} + +export interface PurgeSpacePathParams { + space_ref: string +} + +export type PurgeSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> & + PurgeSpacePathParams + +export const PurgeSpace = ({ space_ref, ...props }: PurgeSpaceProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/purge`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UsePurgeSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + PurgeSpacePathParams + +export const usePurgeSpace = ({ space_ref, ...props }: UsePurgeSpaceProps) => + useMutate( + 'POST', + (paramsInPath: PurgeSpacePathParams) => `/spaces/${paramsInPath.space_ref}/purge`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface RestoreSpaceQueryParams { + /** + * The exact time the resource was delete at in epoch format. + */ + deleted_at: number +} + +export interface RestoreSpacePathParams { + space_ref: string +} + +export type RestoreSpaceProps = Omit< + MutateProps< + SpaceSpaceOutput, + UsererrorError, + RestoreSpaceQueryParams, + OpenapiRestoreSpaceRequest, + RestoreSpacePathParams + >, + 'path' | 'verb' +> & + RestoreSpacePathParams + +export const RestoreSpace = ({ space_ref, ...props }: RestoreSpaceProps) => ( + + verb="POST" + path={`/spaces/${space_ref}/restore`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseRestoreSpaceProps = Omit< + UseMutateProps< + SpaceSpaceOutput, + UsererrorError, + RestoreSpaceQueryParams, + OpenapiRestoreSpaceRequest, + RestoreSpacePathParams + >, + 'path' | 'verb' +> & + RestoreSpacePathParams + +export const useRestoreSpace = ({ space_ref, ...props }: UseRestoreSpaceProps) => + useMutate< + SpaceSpaceOutput, + UsererrorError, + RestoreSpaceQueryParams, + OpenapiRestoreSpaceRequest, + RestoreSpacePathParams + >('POST', (paramsInPath: RestoreSpacePathParams) => `/spaces/${paramsInPath.space_ref}/restore`, { + base: getConfig('api/v1'), + pathParams: { space_ref }, + ...props + }) + +export interface ListSecretsQueryParams { + /** + * The substring which is used to filter the repositories by their path name. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListSecretsPathParams { + space_ref: string +} + +export type ListSecretsProps = Omit< + GetProps, + 'path' +> & + ListSecretsPathParams + +export const ListSecrets = ({ space_ref, ...props }: ListSecretsProps) => ( + + path={`/spaces/${space_ref}/secrets`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListSecretsProps = Omit< + UseGetProps, + 'path' +> & + ListSecretsPathParams + +export const useListSecrets = ({ space_ref, ...props }: UseListSecretsProps) => + useGet( + (paramsInPath: ListSecretsPathParams) => `/spaces/${paramsInPath.space_ref}/secrets`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ListServiceAccountsPathParams { + space_ref: string +} + +export type ListServiceAccountsProps = Omit< + GetProps, + 'path' +> & + ListServiceAccountsPathParams + +export const ListServiceAccounts = ({ space_ref, ...props }: ListServiceAccountsProps) => ( + + path={`/spaces/${space_ref}/service-accounts`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListServiceAccountsProps = Omit< + UseGetProps, + 'path' +> & + ListServiceAccountsPathParams + +export const useListServiceAccounts = ({ space_ref, ...props }: UseListServiceAccountsProps) => + useGet( + (paramsInPath: ListServiceAccountsPathParams) => `/spaces/${paramsInPath.space_ref}/service-accounts`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ListSpacesQueryParams { + /** + * The substring which is used to filter the spaces by their path name. + */ + query?: string + /** + * The data by which the spaces are sorted. + */ + sort?: 'identifier' | 'created' | 'updated' + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListSpacesPathParams { + space_ref: string +} + +export type ListSpacesProps = Omit< + GetProps, + 'path' +> & + ListSpacesPathParams + +export const ListSpaces = ({ space_ref, ...props }: ListSpacesProps) => ( + + path={`/spaces/${space_ref}/spaces`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListSpacesProps = Omit< + UseGetProps, + 'path' +> & + ListSpacesPathParams + +export const useListSpaces = ({ space_ref, ...props }: UseListSpacesProps) => + useGet( + (paramsInPath: ListSpacesPathParams) => `/spaces/${paramsInPath.space_ref}/spaces`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ListTemplatesQueryParams { + /** + * The substring which is used to filter the repositories by their path name. + */ + query?: string + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export interface ListTemplatesPathParams { + space_ref: string +} + +export type ListTemplatesProps = Omit< + GetProps, + 'path' +> & + ListTemplatesPathParams + +export const ListTemplates = ({ space_ref, ...props }: ListTemplatesProps) => ( + + path={`/spaces/${space_ref}/templates`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListTemplatesProps = Omit< + UseGetProps, + 'path' +> & + ListTemplatesPathParams + +export const useListTemplates = ({ space_ref, ...props }: UseListTemplatesProps) => + useGet( + (paramsInPath: ListTemplatesPathParams) => `/spaces/${paramsInPath.space_ref}/templates`, + { base: getConfig('api/v1'), pathParams: { space_ref }, ...props } + ) + +export interface ImportSpaceRequestBody { + description?: string + identifier?: string + is_public?: boolean + parent_ref?: string + pipelines?: ImporterPipelineOption + provider?: ImporterProvider + provider_space?: string + uid?: string +} + +export type ImportSpaceProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const ImportSpace = (props: ImportSpaceProps) => ( + + verb="POST" + path={`/spaces/import`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseImportSpaceProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useImportSpace = (props: UseImportSpaceProps) => + useMutate('POST', `/spaces/import`, { + base: getConfig('api/v1'), + ...props + }) + +export type GetSystemConfigProps = Omit, 'path'> + +export const GetSystemConfig = (props: GetSystemConfigProps) => ( + path={`/system/config`} base={getConfig('api/v1')} {...props} /> +) + +export type UseGetSystemConfigProps = Omit, 'path'> + +export const useGetSystemConfig = (props: UseGetSystemConfigProps) => + useGet(`/system/config`, { base: getConfig('api/v1'), ...props }) + +export type CreateTemplateProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateTemplate = (props: CreateTemplateProps) => ( + + verb="POST" + path={`/templates`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateTemplateProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreateTemplate = (props: UseCreateTemplateProps) => + useMutate('POST', `/templates`, { + base: getConfig('api/v1'), + ...props + }) + +export type DeleteTemplateProps = Omit, 'path' | 'verb'> + +export const DeleteTemplate = (props: DeleteTemplateProps) => ( + + verb="DELETE" + path={`/templates`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeleteTemplateProps = Omit, 'path' | 'verb'> + +export const useDeleteTemplate = (props: UseDeleteTemplateProps) => + useMutate('DELETE', `/templates`, { base: getConfig('api/v1'), ...props }) + +export interface FindTemplatePathParams { + template_ref: string +} + +export type FindTemplateProps = Omit, 'path'> & + FindTemplatePathParams + +export const FindTemplate = ({ template_ref, ...props }: FindTemplateProps) => ( + + path={`/templates/${template_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseFindTemplateProps = Omit< + UseGetProps, + 'path' +> & + FindTemplatePathParams + +export const useFindTemplate = ({ template_ref, ...props }: UseFindTemplateProps) => + useGet( + (paramsInPath: FindTemplatePathParams) => `/templates/${paramsInPath.template_ref}`, + { base: getConfig('api/v1'), pathParams: { template_ref }, ...props } + ) + +export interface UpdateTemplatePathParams { + template_ref: string +} + +export type UpdateTemplateProps = Omit< + MutateProps, + 'path' | 'verb' +> & + UpdateTemplatePathParams + +export const UpdateTemplate = ({ template_ref, ...props }: UpdateTemplateProps) => ( + + verb="PATCH" + path={`/templates/${template_ref}`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateTemplateProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + UpdateTemplatePathParams + +export const useUpdateTemplate = ({ template_ref, ...props }: UseUpdateTemplateProps) => + useMutate( + 'PATCH', + (paramsInPath: UpdateTemplatePathParams) => `/templates/${paramsInPath.template_ref}`, + { base: getConfig('api/v1'), pathParams: { template_ref }, ...props } + ) + +export type GetUserProps = Omit, 'path'> + +export const GetUser = (props: GetUserProps) => ( + path={`/user`} base={getConfig('api/v1')} {...props} /> +) + +export type UseGetUserProps = Omit, 'path'> + +export const useGetUser = (props: UseGetUserProps) => + useGet(`/user`, { base: getConfig('api/v1'), ...props }) + +export type UpdateUserProps = Omit, 'path' | 'verb'> + +export const UpdateUser = (props: UpdateUserProps) => ( + + verb="PATCH" + path={`/user`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseUpdateUserProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useUpdateUser = (props: UseUpdateUserProps) => + useMutate('PATCH', `/user`, { + base: getConfig('api/v1'), + ...props + }) + +export interface ListPublicKeyQueryParams { + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number + /** + * The substring which is used to filter the public keys by their path identifier. + */ + query?: string + /** + * The data by which the public keys are sorted. + */ + sort?: 'created' | 'identifier' + /** + * The order of the output. + */ + order?: 'asc' | 'desc' +} + +export type ListPublicKeyProps = Omit< + GetProps, + 'path' +> + +export const ListPublicKey = (props: ListPublicKeyProps) => ( + + path={`/user/keys`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseListPublicKeyProps = Omit< + UseGetProps, + 'path' +> + +export const useListPublicKey = (props: UseListPublicKeyProps) => + useGet(`/user/keys`, { + base: getConfig('api/v1'), + ...props + }) + +export type CreatePublicKeyProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreatePublicKey = (props: CreatePublicKeyProps) => ( + + verb="POST" + path={`/user/keys`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreatePublicKeyProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreatePublicKey = (props: UseCreatePublicKeyProps) => + useMutate('POST', `/user/keys`, { + base: getConfig('api/v1'), + ...props + }) + +export type DeletePublicKeyProps = Omit, 'path' | 'verb'> + +export const DeletePublicKey = (props: DeletePublicKeyProps) => ( + + verb="DELETE" + path={`/user/keys`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseDeletePublicKeyProps = Omit, 'path' | 'verb'> + +export const useDeletePublicKey = (props: UseDeletePublicKeyProps) => + useMutate('DELETE', `/user/keys`, { base: getConfig('api/v1'), ...props }) + +export interface MembershipSpacesQueryParams { + /** + * The substring by which the spaces the users is a member of are filtered. + */ + query?: string + /** + * The order of the output. + */ + order?: 'asc' | 'desc' + /** + * The field by which the spaces the user is a member of are sorted. + */ + sort?: 'created' | 'identifier' | 'uid' + /** + * The page to return. + */ + page?: number + /** + * The maximum number of results to return. + */ + limit?: number +} + +export type MembershipSpacesProps = Omit< + GetProps, + 'path' +> + +export const MembershipSpaces = (props: MembershipSpacesProps) => ( + + path={`/user/memberships`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseMembershipSpacesProps = Omit< + UseGetProps, + 'path' +> + +export const useMembershipSpaces = (props: UseMembershipSpacesProps) => + useGet(`/user/memberships`, { + base: getConfig('api/v1'), + ...props + }) + +export type CreateTokenProps = Omit< + MutateProps, + 'path' | 'verb' +> + +export const CreateToken = (props: CreateTokenProps) => ( + + verb="POST" + path={`/user/token`} + base={getConfig('api/v1')} + {...props} + /> +) + +export type UseCreateTokenProps = Omit< + UseMutateProps, + 'path' | 'verb' +> + +export const useCreateToken = (props: UseCreateTokenProps) => + useMutate('POST', `/user/token`, { + base: getConfig('api/v1'), + ...props + }) diff --git a/web/src/cde/components/CreateGitspace/components/BranchInput/BranchInput.module.scss b/web/src/cde/components/CreateGitspace/components/BranchInput/BranchInput.module.scss index b62dfb7a9..5e27df5fa 100644 --- a/web/src/cde/components/CreateGitspace/components/BranchInput/BranchInput.module.scss +++ b/web/src/cde/components/CreateGitspace/components/BranchInput/BranchInput.module.scss @@ -15,6 +15,7 @@ */ .branchInput { + span[icon='git-repo'], span[icon='git-branch'] { top: 20%; left: 2% !important; diff --git a/web/src/cde/components/CreateGitspace/components/SelectIDE/SelectIDE.tsx b/web/src/cde/components/CreateGitspace/components/SelectIDE/SelectIDE.tsx index dc390a4a7..9eb65db4d 100644 --- a/web/src/cde/components/CreateGitspace/components/SelectIDE/SelectIDE.tsx +++ b/web/src/cde/components/CreateGitspace/components/SelectIDE/SelectIDE.tsx @@ -22,18 +22,22 @@ import { GitspaceSelect } from 'cde/components/GitspaceSelect/GitspaceSelect' import { useStrings, type UseStringsReturn } from 'framework/strings' import { IDEType } from 'cde/constants' import type { OpenapiCreateGitspaceRequest } from 'services/cde' +import { StandaloneIDEType } from 'cde-gitness/constants' import VSCode from '../../../../icons/VSCode.svg?url' -export const getIDESelectItems = (getString: UseStringsReturn['getString']) => [ - { label: getString('cde.ide.desktop'), value: IDEType.VSCODE }, - { label: getString('cde.ide.browser'), value: IDEType.VSCODEWEB } -] +export const getIDESelectItems = (getString: UseStringsReturn['getString'], standalone = false) => { + const ideEnum = standalone ? StandaloneIDEType : IDEType + return [ + { label: getString('cde.ide.desktop'), value: ideEnum.VSCODE }, + { label: getString('cde.ide.browser'), value: ideEnum.VSCODEWEB } + ] +} -export const SelectIDE = () => { +export const SelectIDE = ({ standalone = false }: { standalone?: boolean }) => { const { values, errors, setFieldValue: onChange } = useFormikContext() const { ide } = values const { getString } = useStrings() - const IDESelectItems = getIDESelectItems(getString) + const IDESelectItems = getIDESelectItems(getString, standalone) const IDELabel = IDESelectItems.find(item => item.value === ide)?.label return ( { const urlPattern = new RegExp( @@ -37,17 +38,24 @@ export enum CodeRepoType { Unknown = 'unknown' } -export const getIconByRepoType = ({ repoType }: { repoType?: EnumCodeRepoType }): React.ReactNode => { +export const getIconByRepoType = ({ + repoType, + height = 40 +}: { + repoType?: EnumCodeRepoType | EnumGitspaceCodeRepoType + height?: number +}): React.ReactNode => { switch (repoType) { case CodeRepoType.Github: - return + return case CodeRepoType.Gitlab: - return + return case CodeRepoType.Bitbucket: - return + return default: case CodeRepoType.Unknown: case CodeRepoType.HarnessCode: - return + case 'harness_code': + return } } diff --git a/web/src/cde/constants/index.ts b/web/src/cde/constants/index.ts index 377df2fa2..39ee68820 100644 --- a/web/src/cde/constants/index.ts +++ b/web/src/cde/constants/index.ts @@ -34,7 +34,10 @@ export enum GitspaceStatus { RUNNING = 'running', STOPPED = 'stopped', UNKNOWN = 'unknown', - ERROR = 'error' + ERROR = 'error', + STARTING = 'starting', + STOPPING = 'stopping', + UNINITIALIZED = 'uninitialized' } export enum IDEType { diff --git a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx index 102949c03..31897e12b 100644 --- a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx +++ b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx @@ -49,7 +49,7 @@ import { useGet, useMutate } from 'restful-react' import { Render } from 'react-jsx-match' import { compact, get } from 'lodash-es' import { useModalHook } from 'hooks/useModalHook' -import { String, useStrings } from 'framework/strings' +import { useStrings } from 'framework/strings' import { DEFAULT_BRANCH_NAME, getErrorMessage, @@ -75,6 +75,7 @@ import type { OpenapiCreateRepositoryRequest } from 'services/code' import { useAppContext } from 'AppContext' +import type { TypesRepository } from 'cde-gitness/services' import ImportForm from './ImportForm/ImportForm' import ImportReposForm from './ImportReposForm/ImportReposForm' import Private from '../../icons/private.svg?url' @@ -95,9 +96,9 @@ export interface NewRepoModalButtonProps extends Omit void - newRepoModalOnly?: boolean - notFoundRepoName?: string + onSubmit: (data: TypesRepository & RepoRepositoryOutput & SpaceImportRepositoriesOutput) => void + repoCreationType?: RepoCreationType + customRenderer?: (onChange: (event: any) => void) => React.ReactNode } export const NewRepoModalButton: React.FC = ({ @@ -481,17 +482,15 @@ export const NewRepoModalButton: React.FC = ({ [space] ) - return props?.newRepoModalOnly ? ( - } - onClick={e => { + return props?.repoCreationType ? ( + <> + {props?.customRenderer?.(e => { e.preventDefault() e.stopPropagation() - setRepoOption(repoCreateOptions[0]) + setRepoOption(repoCreateOptions.find(option => option.type === props?.repoCreationType) || repoCreateOptions[0]) setTimeout(() => openModal(), 0) - }} - /> + })} + ) : ( {{repo}} in Gitness' gitspaceCreateSuccess: Gitspace created successfully gitspaceCreateFailed: Gitspace creation failed + subtext: Start Coding, no setup required. Dedicated cloud development environments with your favorite editor + importWarning: + Currently we support only third party public repositories. In order to use a private git repository, please + import the repository into Gitness. unsaved: title: Unsaved Changes message: 'You have unsaved changes, On switching all unsaved changes will be lost' @@ -1189,6 +1200,7 @@ cde: startGitspace: Start Gitspace stopProvising: Stop Provising noData: No Data for Gitspace + gitspaceActivity: Gitspace Activity provisioningGitspace: Provisioning the Gitspace... gitspaceStopped: Gitspace is stopped gitspaceRunning: Gitspace is running @@ -1198,7 +1210,9 @@ cde: logsFailed: Gitspace logs api failed noLogsFound: No gitspace logs found wrongIdentifier: Invalid gitspace id or project params - fetchingDetails: Fetching Gitspace Details .... + fetchingDetails: Fetching Gitspace Events .... + containerLogs: Container Logs + containerLogsSubText: Logs showing activity inside container repository: repo: Repository selectRepository: Select Repository diff --git a/web/src/layouts/menu/DefaultMenu.tsx b/web/src/layouts/menu/DefaultMenu.tsx index 0321e1835..874f99b1f 100644 --- a/web/src/layouts/menu/DefaultMenu.tsx +++ b/web/src/layouts/menu/DefaultMenu.tsx @@ -172,6 +172,17 @@ export const DefaultMenu: React.FC = () => { + {__ENABLE_GITSPACE__ && ( + + + + )} +