diff --git a/src/api/ansible-distribution.ts b/src/api/ansible-distribution.ts index 8a06fe3d..c5def02a 100644 --- a/src/api/ansible-distribution.ts +++ b/src/api/ansible-distribution.ts @@ -1,5 +1,19 @@ +import type { GenericDistribution } from './common'; import { PulpAPI } from './pulp'; +/** + * Ansible Distribution Type. + * + * @see https://github.com/pulp/pulp_ansible/blob/0043923641fc7fd3893f8489fd29ff04addc9d71/pulp_ansible/app/serializers.py#L356 + */ +interface AnsibleDistributionType extends Omit< + GenericDistribution, + 'base_url' +> { + readonly client_url: string; + repository_version?: string | null; +} + const base = new PulpAPI(); export const AnsibleDistributionAPI = { @@ -11,3 +25,5 @@ export const AnsibleDistributionAPI = { url: (distro_data) => distro_data.client_url, }; + +export type { AnsibleDistributionType }; diff --git a/src/api/ansible-remote.ts b/src/api/ansible-remote.ts index 98c1ecdc..61f7594a 100644 --- a/src/api/ansible-remote.ts +++ b/src/api/ansible-remote.ts @@ -1,36 +1,22 @@ +import type { AnsibleLastSyncType, GenericRemote } from './common'; import { PulpAPI } from './pulp'; -export class AnsibleRemoteType { - auth_url: string; - ca_cert: string; - client_cert: string; - download_concurrency: number; - name: string; - proxy_url: string; - pulp_href?: string; - rate_limit: number; - requirements_file: string; - tls_validation: boolean; - url: string; - signed_only: boolean; +/** + * Ansible Remote Type. + * + * @see https://github.com/pulp/pulp_ansible/blob/0043923641fc7fd3893f8489fd29ff04addc9d71/pulp_ansible/app/serializers.py#L213 + */ +interface AnsibleRemoteType extends GenericRemote { + requirements_file?: string | null; + auth_url?: string | null; + token?: string | null; sync_dependencies?: boolean; - - // connect_timeout - // headers - // max_retries - // policy - // pulp_created - // pulp_labels - // pulp_last_updated - // sock_connect_timeout - // sock_read_timeout - // total_timeout - - hidden_fields: { - is_set: boolean; - name: string; - }[]; - + signed_only?: boolean; + readonly last_sync_task?: AnsibleLastSyncType | null; + /** + * NOTE: Not part of the Ansible serializer, populated separately. + * This should be broken out into its own type and extend the interface. + */ my_permissions?: string[]; } @@ -90,3 +76,5 @@ export const AnsibleRemoteAPI = { smartUpdate(newValue, oldValue), ), }; + +export type { AnsibleRemoteType }; diff --git a/src/api/ansible-repository.ts b/src/api/ansible-repository.ts index 7a0758a1..5c73681c 100644 --- a/src/api/ansible-repository.ts +++ b/src/api/ansible-repository.ts @@ -1,22 +1,20 @@ +import type { AnsibleLastSyncType, GenericRepository } from './common'; import { PulpAPI } from './pulp'; -import { type LastSyncType } from './response-types/remote'; -export class AnsibleRepositoryType { - description: string; - last_sync_task?: LastSyncType; - latest_version_href?: string; - name: string; +/** + * Ansible Repository Type. + * + * @see https://github.com/pulp/pulp_ansible/blob/0043923641fc7fd3893f8489fd29ff04addc9d71/pulp_ansible/app/serializers.py#L148 + */ +interface AnsibleRepositoryType extends GenericRepository { + last_synced_metadata_time?: string | null; + gpgkey?: string | null; + readonly last_sync_task?: AnsibleLastSyncType | null; private?: boolean; - pulp_created?: string; - pulp_href?: string; - pulp_labels?: Record; - remote?: string; - retain_repo_versions: number; - - // gpgkey - // last_synced_metadata_time - // versions_href - + /** + * NOTE: Not part of the Ansible serializer, populated separately. + * This should be broken out into its own type and extend the interface. + */ my_permissions?: string[]; } @@ -91,3 +89,5 @@ export const AnsibleRepositoryAPI = { update: (id: string, data) => base.http.put(`repositories/ansible/ansible/${id}/`, data), }; + +export type { AnsibleRepositoryType }; diff --git a/src/api/common.ts b/src/api/common.ts new file mode 100644 index 00000000..a5f64b81 --- /dev/null +++ b/src/api/common.ts @@ -0,0 +1,127 @@ +import type { PulpStatus } from './response-types/pulp'; + +/** + * Generic PulpCore Exceptions based on dictionary representation. + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/exceptions/base.py#L37 + */ +interface TaskErrorType { + description: string; + traceback: string | null; + error_code?: string; +} + +/** + * Generic Resource shared across every Pulp resource. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/base.py#L448 + */ +interface GenericResource { + readonly pulp_href?: string; + readonly prn?: string; + readonly pulp_created?: string; + readonly pulp_last_updated?: string; +} + +/** + * Generic Repository shared across Pulp Repository plugins. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/repository.py#L26 + */ +interface GenericRepository extends GenericResource { + pulp_labels?: Record; + readonly versions_href?: string; + readonly latest_version_href?: string; + name: string; + description?: string | null; + retain_repo_versions?: number | null; + retain_checkpoints?: number | null; + remote?: string | null; +} + +/** + * Generic Distribution shared across Pulp Distribution plugins. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/publication.py + */ +interface GenericDistribution extends GenericResource { + base_path: string; + readonly base_url?: string; + content_guard?: string | null; + readonly content_guard_prn?: string | null; + readonly no_content_change_since?: string | null; + hidden?: boolean; + pulp_labels?: Record; + name: string; + repository?: string; + repository_version?: string; +} + +/** + * Generic Publication shared across Pulp Publication plugins. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/publication.py#L23 + */ +interface GenericPublication extends GenericResource { + repository_version?: string; + repository?: string; +} + +/** + * Generic Remote shared across Pulp Remote plugins. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/repository.py#L85 + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/base.py#L612 + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulpcore/app/serializers/base.py#L367 + */ +interface GenericRemote extends GenericResource { + pulp_labels?: Record; + name: string; + url: string; + policy?: string; + readonly hidden_fields?: { name: string; is_set: boolean }[]; + ca_cert?: string | null; + client_cert?: string | null; + client_key?: string | null; + tls_validation?: boolean; + proxy_url?: string | null; + proxy_username?: string | null; + proxy_password?: string | null; + username?: string | null; + password?: string | null; + max_retries?: number | null; + total_timeout?: number | null; + connect_timeout?: number | null; + sock_connect_timeout?: number | null; + sock_read_timeout?: number | null; + headers?: unknown[]; + download_concurrency?: number | null; + rate_limit?: number | null; +} + +/** + * -------------------- + * These are shared Plugin Types outside the PulpCore Generics. + * -------------------- + */ + +/** + * Last Sync Task Type. + * + * @see https://github.com/pulp/pulp_ansible/blob/0043923641fc7fd3893f8489fd29ff04addc9d71/pulp_ansible/app/utils.py#L47 + */ +interface AnsibleLastSyncType { + pk: string; + state: PulpStatus; + pulp_created: string; + finished_at: string | null; + error: TaskErrorType | null; +} + +export type { + TaskErrorType, + GenericRepository, + GenericDistribution, + GenericPublication, + GenericRemote, + AnsibleLastSyncType, +}; diff --git a/src/api/container-distribution.ts b/src/api/container-distribution.ts index 7bd1da77..b1213a15 100644 --- a/src/api/container-distribution.ts +++ b/src/api/container-distribution.ts @@ -1,5 +1,43 @@ +import type { GenericDistribution } from './common'; import { PulpAPI } from './pulp'; +/** + * Container Distribution Type. + * + * @see https://github.com/pulp/pulp_container/blob/b109af03cb7aae3431f7a73204e6a73a8457694c/pulp_container/app/serializers.py#L424 + */ +interface ContainerDistributionType extends Omit< + GenericDistribution, + 'base_url' +> { + readonly registry_path: string; + content_guard?: string; + readonly namespace?: string; + description?: string | null; + repository_version?: string | null; + readonly remote?: string; + private?: boolean; + readonly pulp_domain?: string; +} + +/** + * Container Pull Through Type. + * + * @see https://github.com/pulp/pulp_container/blob/b109af03cb7aae3431f7a73204e6a73a8457694c/pulp_container/app/serializers.py#L520 + */ +interface ContainerPullThroughDistributionType extends Omit< + GenericDistribution, + 'base_url' +> { + remote: string; + readonly namespace?: string; + content_guard?: string; + distributions?: string[]; + description?: string | null; + private?: boolean; + readonly pulp_domain?: string; +} + const base = new PulpAPI(); export const ContainerDistributionAPI = { @@ -17,3 +55,5 @@ export const ContainerPullThroughDistributionAPI = { // We should probably put this into a field on the serializer url: (distro_data) => `${window.location.host}/${distro_data.base_path}/`, }; + +export type { ContainerDistributionType, ContainerPullThroughDistributionType }; diff --git a/src/api/file-distribution.ts b/src/api/file-distribution.ts index ac05996b..179f1505 100644 --- a/src/api/file-distribution.ts +++ b/src/api/file-distribution.ts @@ -1,5 +1,16 @@ +import type { GenericDistribution } from './common'; import { PulpAPI } from './pulp'; +/** + * File Distribution Type. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulp_file/app/serializers.py#L225 + */ +interface FileDistributionType extends GenericDistribution { + publication?: string | null; + checkpoint?: boolean; +} + const base = new PulpAPI(); export const FileDistributionAPI = { @@ -9,3 +20,5 @@ export const FileDistributionAPI = { list: (params?) => base.list(`distributions/file/file/`, params), }; + +export type { FileDistributionType }; diff --git a/src/api/file-publication.ts b/src/api/file-publication.ts index b0bcc6b7..30f7a071 100644 --- a/src/api/file-publication.ts +++ b/src/api/file-publication.ts @@ -1,5 +1,17 @@ +import type { GenericPublication } from './common'; import { PulpAPI } from './pulp'; +/** + * File Publication Type. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulp_file/app/serializers.py#L200 + */ +interface FilePublicationType extends GenericPublication { + readonly distributions: string[]; + manifest?: string | null; + checkpoint?: boolean; +} + const base = new PulpAPI(); export const FilePublicationAPI = { @@ -9,3 +21,5 @@ export const FilePublicationAPI = { list: (params?) => base.list(`publications/file/file/`, params), }; + +export type { FilePublicationType }; diff --git a/src/api/file-remote.ts b/src/api/file-remote.ts index fc8c486e..f5a1d7d2 100644 --- a/src/api/file-remote.ts +++ b/src/api/file-remote.ts @@ -1,34 +1,16 @@ +import type { GenericRemote } from './common'; import { PulpAPI } from './pulp'; -export class FileRemoteType { - ca_cert: string; - client_cert: string; - download_concurrency: number; - name: string; - proxy_url: string; - pulp_href?: string; - rate_limit: number; - tls_validation: boolean; - url: string; - sync_dependencies?: boolean; - - // connect_timeout - // headers - // max_retries - // policy - // prn - // pulp_created - // pulp_labels - // pulp_last_updated - // sock_connect_timeout - // sock_read_timeout - // total_timeout - - hidden_fields: { - is_set: boolean; - name: string; - }[]; - +/** + * File Remote Type. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulp_file/app/serializers.py#L165 + */ +interface FileRemoteType extends GenericRemote { + /** + * NOTE: Not part of the File serializer, populated separately. + * This should be broken out into its own type and extend the interface. + */ my_permissions?: string[]; } @@ -62,3 +44,5 @@ export const FileRemoteAPI = { smartUpdate: (id, newValue: FileRemoteType, oldValue: FileRemoteType) => base.http.put(`remotes/file/file/${id}/`, smartUpdate(newValue, oldValue)), }; + +export type { FileRemoteType }; diff --git a/src/api/file-repository.ts b/src/api/file-repository.ts index 7481c2f3..44fffbeb 100644 --- a/src/api/file-repository.ts +++ b/src/api/file-repository.ts @@ -1,19 +1,28 @@ +import type { GenericRepository } from './common'; import { PulpAPI } from './pulp'; -export class FileRepositoryType { +/** + * Type for syncing metadata set on FileRepository after each sync. + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulp_file/app/tasks/synchronizing.py#L97 + */ +interface FileLastSyncDetailsType { + remote_pk: string; + url: string; + download_policy: string; + mirror: boolean; + most_recent_version: number; + manifest_checksum: string; +} + +/** + * File Repository Type. + * + * @see https://github.com/pulp/pulpcore/blob/934c752dae916857b2005e1fe0ef75496accc082/pulp_file/app/serializers.py#L122 + */ +interface FileRepositoryType extends GenericRepository { autopublish?: boolean; - description: string | null; - latest_version_href?: string; - manifest?: string; - name: string; - prn?: string; - pulp_created?: string; - pulp_href?: string; - pulp_labels: Record; - pulp_last_updated?: string; - remote: string | null; - retain_repo_versions: number; - versions_href?: string; + manifest?: string | null; + readonly last_sync_details?: FileLastSyncDetailsType | null; } const base = new PulpAPI(); @@ -39,3 +48,5 @@ export const FileRepositoryAPI = { update: (id: string, data) => base.http.put(`repositories/file/file/${id}/`, data), }; + +export type { FileRepositoryType }; diff --git a/src/api/rpm-repository.ts b/src/api/rpm-repository.ts index 9e32c898..2dd8f24d 100644 --- a/src/api/rpm-repository.ts +++ b/src/api/rpm-repository.ts @@ -1,7 +1,40 @@ +import type { GenericRepository } from './common'; import { PulpAPI } from './pulp'; +type RPMChecksumType = + | 'unknown' + | 'md5' + | 'sha' + | 'sha1' + | 'sha224' + | 'sha256' + | 'sha384' + | 'sha512'; +type RPMCompressionType = 'zstd' | 'gz' | 'none'; +type RPMLayoutType = 'nested_alphabetically' | 'flat' | 'nested_by_digest'; + +/** + * RPM Repository Type. + * + * @see https://github.com/pulp/pulp_rpm/blob/main/pulp_rpm/app/serializers/repository.py + */ +interface RPMRepositoryType extends GenericRepository { + autopublish?: boolean; + metadata_signing_service?: string | null; + package_signing_service?: string | null; + package_signing_fingerprint?: string | null; + retain_package_versions?: number; + checksum_type?: RPMChecksumType | null; + compression_type?: RPMCompressionType | null; + layout?: RPMLayoutType | null; + repo_config?: Record; + osv_config?: { name: string; releases: unknown }[] | null; +} + const base = new PulpAPI(); export const RPMRepositoryAPI = { list: (params?) => base.list(`repositories/rpm/rpm/`, params), }; + +export type { RPMRepositoryType };