Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/api/ansible-distribution.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -11,3 +25,5 @@ export const AnsibleDistributionAPI = {

url: (distro_data) => distro_data.client_url,
};

export type { AnsibleDistributionType };
48 changes: 18 additions & 30 deletions src/api/ansible-remote.ts
Original file line number Diff line number Diff line change
@@ -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[];
}

Expand Down Expand Up @@ -90,3 +76,5 @@ export const AnsibleRemoteAPI = {
smartUpdate(newValue, oldValue),
),
};

export type { AnsibleRemoteType };
32 changes: 16 additions & 16 deletions src/api/ansible-repository.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>;
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[];
}

Expand Down Expand Up @@ -91,3 +89,5 @@ export const AnsibleRepositoryAPI = {
update: (id: string, data) =>
base.http.put(`repositories/ansible/ansible/${id}/`, data),
};

export type { AnsibleRepositoryType };
127 changes: 127 additions & 0 deletions src/api/common.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>;
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<string, string>;
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<string, string>;
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,
};
40 changes: 40 additions & 0 deletions src/api/container-distribution.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 };
13 changes: 13 additions & 0 deletions src/api/file-distribution.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -9,3 +20,5 @@ export const FileDistributionAPI = {

list: (params?) => base.list(`distributions/file/file/`, params),
};

export type { FileDistributionType };
14 changes: 14 additions & 0 deletions src/api/file-publication.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -9,3 +21,5 @@ export const FilePublicationAPI = {

list: (params?) => base.list(`publications/file/file/`, params),
};

export type { FilePublicationType };
Loading