How to use @cumulus/cmr-client - 5 common examples

To help you get started, we’ve selected a few @cumulus/cmr-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nasa / cumulus / packages / api / models / granules.js View on Github external
api: process.env.launchpad_api,
        passphrase: process.env.launchpad_passphrase,
        certificate: process.env.launchpad_certificate
      };
      const token = await launchpad.getLaunchpadToken(config);
      params.token = token;
    } else {
      const secret = await commonAws.secretsManager().getSecretValue({
        SecretId: process.env.cmr_password_secret_name
      }).promise();

      params.username = process.env.cmr_username;
      params.password = secret.SecretString;
    }

    const cmr = new CMR(params);
    const metadata = await cmrjs.getMetadata(granule.cmrLink);

    // Use granule UR to delete from CMR
    await cmr.deleteGranule(metadata.title, granule.collectionId);
    await this.update({ granuleId: granule.granuleId }, { published: false }, ['cmrLink']);
  }
github nasa / cumulus / packages / cmrjs / cmr-utils.js View on Github external
async function publish2CMR(cmrPublishObject, creds) {
  const cmrClient = new CMR(creds);

  // choose xml or json and do the things.
  if (isECHO10File(cmrPublishObject.filename)) {
    return publishECHO10XML2CMR(cmrPublishObject, cmrClient);
  }
  if (isUMMGFile(cmrPublishObject.filename)) {
    return publishUMMGJSON2CMR(cmrPublishObject, cmrClient);
  }

  throw new Error(`invalid cmrPublishObject passed to publis2CMR ${JSON.stringify(cmrPublishObject)}`);
}
github nasa / cumulus / packages / cmrjs / cmr.js View on Github external
constructor(provider, clientId, username, password) {
    deprecate('@cmrjs/CMR', '1.11.3');

    this.provider = provider;
    this.cmrClient = new cmrClient.CMR({
      provider,
      clientId,
      username,
      password
    });
  }
github nasa / cumulus / packages / cmrjs / cmr.js View on Github external
constructor(provider, clientId, type, searchParams, format) {
    deprecate('@cmrjs/CMRSearchConceptQueue', '1.11.3');

    this.cmrClientSearchConceptQueue = new cmrClient.CMRSearchConceptQueue({
      provider,
      clientId,
      type,
      searchParams,
      format
    });
  }
github nasa / cumulus / packages / cmrjs / utils.js View on Github external
json: true,
      body: ummMetadata,
      headers: {
        Accept: 'application/json',
        'Content-type': `application/vnd.nasa.cmr.umm+json;version=${version}`
      }
    });

    if (result.statusCode === 200) {
      return true;
    }
  } catch (e) {
    result = e.response;
  }

  throw new ValidationError(
    `Validation was not successful. UMM metadata Object: ${JSON.stringify(ummMetadata)}`
  );
}

@cumulus/cmr-client

A Node.js client to NASA's Common Metadata Repository (CMR) API.

Apache-2.0
Latest version published 21 days ago

Package Health Score

76 / 100
Full package analysis