Argo CD API Client
    Preparing search index...

    Class ApplicationResource

    Methods for Argo CD applications.

    Applications represent deployed GitOps workloads managed by Argo CD.

    Index

    Methods

    • Returns all containers across every pod of an application, flattened into a single array. Each entry includes podName as a back-reference. Delegates to pods internally.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdPodsParams = {}

        Optional filters forwarded to pods: namespace, resourceName, appNamespace.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdContainer[]>

      Flat array of containers with name, image, ready, restartCount, state, and podName.

      const containers = await argocd.applications.containers('guestbook');
      containers.forEach(c => {
      console.log(`${c.podName} / ${c.name}${c.image} (ready: ${c.ready})`);
      });
      // Get logs for the first container
      const [c] = await argocd.applications.containers('guestbook');
      const logs = await argocd.applications.logs('guestbook', { podName: c.podName, container: c.name });
    • Creates a new Argo CD application.

      Parameters

      • application: ArgoCdApplication

        Application manifest. At minimum metadata.name and spec are required.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The created application as stored by Argo CD.

      const app = await argocd.applications.create({
      metadata: { name: 'guestbook' },
      spec: {
      project: 'default',
      source: { repoURL: 'https://github.com/acme/guestbook.git', path: 'helm', targetRevision: 'HEAD' },
      destination: { server: 'https://kubernetes.default.svc', namespace: 'guestbook' },
      },
      });
    • Deletes an application by name.

      Parameters

      • name: string

        Application name.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<Record<string, never>>

      Empty object on success.

      await argocd.applications.deleteByName('guestbook');
      
    • Deletes a specific managed Kubernetes resource from an application. Use this to remove individual resources (e.g. a stuck Pod or a Deployment) without syncing.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdDeleteResourceParams = {}

        Resource selector: kind, resourceName, version are required by the API.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<Record<string, never>>

    • Returns only the managed resources whose live state differs from the normalized target state — i.e. resources that are out of sync. Compares liveState vs normalizedLiveState strings.

      Parameters

      Returns Promise<ArgoCdManagedResource[]>

      Array of out-of-sync resources (empty if fully synced).

      const diffs = await argocd.applications.diff('guestbook');
      if (diffs.length > 0) {
      console.warn('Out of sync:', diffs.map(r => `${r.kind}/${r.name}`));
      }
    • Returns Kubernetes events for an application or a specific resource within it. Useful for diagnosing crash loops, image pull failures, OOM kills, and scheduling issues.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdEventsParams = {}

        Optional filters: resourceName, resourceNamespace, resourceUID, appNamespace.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdEvent[]>

      Array of events, each with reason, message, type ('Normal' | 'Warning'), count, firstTimestamp, lastTimestamp, involvedObject, and source.

      // All events for the app
      const events = await argocd.applications.events('guestbook');
      const warnings = events.filter(e => e.type === 'Warning');
      // Events for a specific pod
      const events = await argocd.applications.events('guestbook', {
      resourceName: 'api-abc123',
      resourceNamespace: 'default',
      });
    • Gets a single application by name.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdApplicationGetParams = {}

        Optional: appNamespace, project, refresh ('normal' | 'hard').

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The full application object including spec and status.

      const app = await argocd.applications.get('guestbook');
      console.log(app.status?.health?.status); // 'Healthy'
      // Force hard refresh before returning
      const app = await argocd.applications.get('guestbook', { refresh: 'hard' });
    • Returns the current health status of an application without loading the full object. Internally calls get and extracts status.health.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdApplicationGetParams = {}

        Optional: appNamespace, project, refresh.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplicationHealth>

      { status, message? } — status is one of 'Healthy', 'Degraded', 'Progressing', 'Suspended', 'Missing', 'Unknown'.

      const { status, message } = await argocd.applications.health('guestbook');
      if (status === 'Degraded') {
      console.warn('App degraded:', message);
      }
    • Returns the deduplicated list of container images currently running across all resources of an application. Data sourced from resourceTree node images fields.

      Parameters

      • name: string

        Application name.

      • params: { appNamespace?: string } = {}

        Optional appNamespace for multi-namespace installs.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<string[]>

      Array of unique image references (e.g. ['my-app:v2.1.0', 'nginx:1.25']).

      const images = await argocd.applications.images('guestbook');
      console.log(images); // ['my-app:v2.1.0', 'redis:7', 'nginx:1.25']
    • Lists Argo CD applications, optionally filtered by project, label selector, repo, or namespace.

      Parameters

      • params: ArgoCdApplicationListParams = {}

        Optional filters: project, selector, repo, appNamespace, etc.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplicationList>

      Paginated list of applications.

      // All apps in a project
      const { items } = await argocd.applications.list({ project: ['default'] });
      console.log(items.map(a => a.metadata?.name));
      // Filter by label selector
      const { items } = await argocd.applications.list({ selector: 'env=prod' });
    • Fetches pod logs for an application. The server streams NDJSON; this method buffers and returns it as an array. Use params.follow: false (default) for a bounded response.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdApplicationLogsParams = {}

        Log options: podName, container, namespace, tailLines, sinceSeconds, filter, etc.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdLogEntry[]>

      Array of log entries, each with content, timestamp, podName, and container.

      const logs = await argocd.applications.logs('guestbook', {
      container: 'api',
      tailLines: 100,
      });
      logs.forEach(l => console.log(l.content));
    • Returns the managed Kubernetes resources for an application, including their live and target manifests as JSON strings (liveState, targetState, normalizedLiveState).

      Parameters

      • name: string

        Application name.

      • params: ArgoCdManagedResourcesParams = {}

        Optional filters: kind, group, namespace, resourceName, version, appNamespace.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdManagedResource[]>

      Array of managed resources (empty array if none).

      // All managed resources
      const resources = await argocd.applications.managedResources('guestbook');
      // Only Deployments
      const deployments = await argocd.applications.managedResources('guestbook', { kind: 'Deployment' });
    • Returns the Kubernetes nodes that host this application's pods, with OS and container runtime metadata sourced from the resourceTree host list (NodeSystemInfo).

      Parameters

      • name: string

        Application name.

      • params: { appNamespace?: string } = {}

        Optional appNamespace for multi-namespace installs.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdNode[]>

      Array of nodes, each with osImage, operatingSystem, architecture, kernelVersion, containerRuntimeVersion, and kubeletVersion.

      const nodes = await argocd.applications.nodes('guestbook');
      nodes.forEach(n => {
      console.log(n.name, n.osImage, n.architecture);
      // 'node-1' 'Ubuntu 22.04 LTS' 'amd64'
      });
    • Applies a JSON merge patch to an application. Prefer this over update for partial changes.

      Parameters

      • name: string

        Application name.

      • patch: unknown

        Partial application object to merge. Only provided fields are changed.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The patched application.

      // Change only the sync policy
      const app = await argocd.applications.patch('guestbook', {
      spec: { syncPolicy: { automated: { prune: true, selfHeal: true } } },
      });
    • Returns the live pods for an application, parsed from the managed-resources liveState manifests. Each pod includes its phase, node assignment, container specs, and container statuses.

      Parameters

      • name: string

        Application name.

      • params: ArgoCdPodsParams = {}

        Optional filters: namespace, resourceName, appNamespace.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdPod[]>

      Array of pods, each with containers (including ready and restartCount).

      const pods = await argocd.applications.pods('guestbook');
      pods.forEach(p => {
      console.log(p.name, p.phase); // 'api-abc123' 'Running'
      console.log(p.containers[0].restartCount); // 0
      });
      // Filter by namespace
      const pods = await argocd.applications.pods('guestbook', { namespace: 'production' });
    • Triggers a normal refresh and returns the updated application. Convenience wrapper for get(name, { refresh: 'normal' }). Use get(name, { refresh: 'hard' }) for a hard refresh.

      Parameters

      • name: string

        Application name.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The refreshed application.

      const app = await argocd.applications.refresh('guestbook');
      console.log(app.status?.sync?.status); // 'Synced'
    • Returns the live Kubernetes resource tree for an application — all nodes (Deployments, ReplicaSets, Pods, Services…) with health, status, and parent references.

      Parameters

      • name: string

        Application name.

      • params: { appNamespace?: string } = {}

        Optional appNamespace for multi-namespace installs.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdResourceTree>

      Tree with nodes, orphanedNodes, and hosts.

      const tree = await argocd.applications.resourceTree('guestbook');
      const pods = tree.nodes?.filter(n => n.kind === 'Pod');
    • Rolls back an application to a previous deployment by history ID.

      Parameters

      • name: string

        Application name.

      • body: { dryRun?: boolean; id?: number; prune?: boolean } = {}

        Rollback options.

        • OptionaldryRun?: boolean

          Simulate without applying changes.

        • Optionalid?: number

          History ID to roll back to (from app.status.history).

        • Optionalprune?: boolean

          Whether to delete resources not present in the target revision.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The application after rollback is initiated.

      await argocd.applications.rollback('guestbook', { id: 3 });
      
    • Triggers a sync for an application, reconciling live state with the desired Git state.

      Parameters

      • name: string

        Application name.

      • body: Record<string, unknown> = {}

        Optional sync options: revision, prune, dryRun, resources, etc.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The application after sync is initiated.

      // Sync to HEAD
      await argocd.applications.sync('guestbook');
      // Sync to a specific revision with prune
      await argocd.applications.sync('guestbook', { revision: 'v2.1.0', prune: true });
    • Terminates a running sync operation for an application.

      Parameters

      • name: string
      • Optionalsignal: AbortSignal

      Returns Promise<Record<string, never>>

    • Replaces an application (full PUT). Use patch for partial updates.

      Parameters

      • name: string

        Application name.

      • application: ArgoCdApplication

        Complete application manifest to replace the current one.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the request.

      Returns Promise<ArgoCdApplication>

      The updated application.

      const updated = await argocd.applications.update('guestbook', {
      metadata: { name: 'guestbook' },
      spec: { /* full spec */ },
      });