@cumulus/cmr-client
A Node.js client to read from, write to, and delete from NASA's Common Metadata Repository (CMR) API.
API
Classes
- CMR
A class to simplify requests to the CMR
- CMRSearchConceptQueue
A class to efficiently list all of the concepts (collections/granules) from
CMR search, without loading them all into memory at once. Handles paging.
CMR
A class to simplify requests to the CMR
Kind: global class
new CMR(params)
The constructor for the CMR class
Param | Type | Description |
---|
params | Object | |
params.provider | string | the CMR provider id |
params.clientId | string | the CMR clientId |
params.username | string | CMR username |
params.password | string | CMR password |
Example
const { CMR } = require('@cumulus/cmr-client');
const cmrClient = new CMR({
provider: 'my-provider',
clientId: 'my-clientId',
username: 'my-username',
password: 'my-password'
});
cmrClient.getToken() ⇒ Promise.<string>
The method for getting the token
Kind: instance method of CMR
Returns: Promise.<string>
- the token
Return object containing CMR request headers
Kind: instance method of CMR
Returns: Object
- CMR headers object
Param | Type | Description |
---|
params | Object | |
[params.token] | string | CMR request token |
[params.ummgVersion] | string | UMMG metadata version string or null if echo10 metadata |
cmrClient.ingestCollection(xml) ⇒ Promise.<Object>
Adds a collection record to the CMR
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Description |
---|
xml | string | the collection XML document |
cmrClient.ingestGranule(xml) ⇒ Promise.<Object>
Adds a granule record to the CMR
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Description |
---|
xml | string | the granule XML document |
cmrClient.ingestUMMGranule(ummgMetadata) ⇒ Promise.<Object>
Adds/Updates UMMG json metadata in the CMR
Kind: instance method of CMR
Returns: Promise.<Object>
- to the CMR response object.
Param | Type | Description |
---|
ummgMetadata | Object | UMMG metadata object |
cmrClient.deleteCollection(datasetID) ⇒ Promise.<Object>
Deletes a collection record from the CMR
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Description |
---|
datasetID | string | the collection unique id |
cmrClient.deleteGranule(granuleUR) ⇒ Promise.<Object>
Deletes a granule record from the CMR
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Description |
---|
granuleUR | string | the granule unique id |
cmrClient.searchCollections(params, [format]) ⇒ Promise.<Object>
Search in collections
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Default | Description |
---|
params | string | | the search parameters |
[format] | string | "json" | format of the response |
cmrClient.searchGranules(params, [format]) ⇒ Promise.<Object>
Search in granules
Kind: instance method of CMR
Returns: Promise.<Object>
- the CMR response
Param | Type | Default | Description |
---|
params | string | | the search parameters |
[format] | string | "'json'" | format of the response |
CMRSearchConceptQueue
A class to efficiently list all of the concepts (collections/granules) from
CMR search, without loading them all into memory at once. Handles paging.
Kind: global class
new CMRSearchConceptQueue(params)
The constructor for the CMRSearchConceptQueue class
Param | Type | Default | Description |
---|
params | Object | | |
params.provider | string | | the CMR provider id |
params.clientId | string | | the CMR clientId |
params.type | string | | the type of search 'granule' or 'collection' |
[params.searchParams] | string | "{}" | the search parameters |
params.format | string | | the result format |
Example
const { CMRSearchConceptQueue } = require('@cumulus/cmr-client');
const cmrSearchConceptQueue = new CMRSearchConceptQueue({
provider: 'my-provider',
clientId: 'my-clientId',
type: 'granule',
searchParams: {},
format: 'json'
});
cmrSearchConceptQueue.peek() ⇒ Promise.<Object>
View the next item in the queue
This does not remove the object from the queue. When there are no more
items in the queue, returns 'null'.
Kind: instance method of CMRSearchConceptQueue
Returns: Promise.<Object>
- an item from the CMR search
cmrSearchConceptQueue.shift() ⇒ Promise.<Object>
Remove the next item from the queue
When there are no more items in the queue, returns null
.
Kind: instance method of CMRSearchConceptQueue
Returns: Promise.<Object>
- an item from the CMR search
CMR Docs
CMR REST API endpoint documentation is here:
What is Cumulus?
Cumulus is a cloud-based data ingest, archive, distribution and management prototype for NASA's future Earth science data streams.
Cumulus Documentation
Test
Test with npm run test
.
Contributing
See Cumulus README
Generated automatically using npm run build-docs