MCPcopy Create free account
hub / github.com/api3dao/airnode / fetchDeployment

Function fetchDeployment

packages/airnode-deployer/src/infrastructure/index.ts:589–616  ·  view source on GitHub ↗
(cloudProviderType: CloudProvider['type'], deploymentId: string, versionId?: string)

Source from the content-addressed store, hash-verified

587}
588
589async function fetchDeployment(cloudProviderType: CloudProvider['type'], deploymentId: string, versionId?: string) {
590 // We need to call `fetchDeployments` even if we want just one deployment due to the way the deployment ID is build
591 // For that reason we keep the `deploymentId` paramater in `fetchDeployments` that allows to return early if the deployment is found
592 const goDeployemnts = await go(() => fetchDeployments(cloudProviderType, deploymentId));
593
594 if (!goDeployemnts.success) {
595 throw new Error(
596 `Failed to fetch info about '${deploymentId}' from ${cloudProviderType.toUpperCase()}: ${goDeployemnts.error}`
597 );
598 }
599
600 if (goDeployemnts.data.length === 0) {
601 throw new Error(`No deployment with ID '${deploymentId}' found`);
602 }
603
604 const deployment = goDeployemnts.data[0];
605 let requestedVersion: DeploymentVersion | undefined;
606
607 if (versionId) {
608 requestedVersion = deployment.versions.find((version) => version.id === versionId);
609 if (!requestedVersion) {
610 throw new Error(`No deployment with ID '${deploymentId}' and version '${versionId}' found`);
611 }
612 }
613
614 const version = requestedVersion ?? sortBy(deployment.versions, 'timestamp').reverse()[0];
615 return { deployment, version };
616}
617
618async function downloadDeploymentFiles(
619 cloudProviderType: CloudProvider['type'],

Callers 4

removeAirnodeFunction · 0.85
deploymentInfoFunction · 0.85
fetchFilesFunction · 0.85
saveDeploymentFilesFunction · 0.85

Calls 1

fetchDeploymentsFunction · 0.85

Tested by

no test coverage detected