Skip to content

Commit

Permalink
Merge pull request #174 from textileio/andrew/add-bucket-list-api
Browse files Browse the repository at this point in the history
feature(buckets): add bucket.links
  • Loading branch information
andrewxhill authored May 19, 2020
2 parents 0d32ea2 + e354b47 commit 196371d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/buckets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ describe('Buckets...', () => {
expect(list.item?.itemsList).to.have.length(1)
})

it('should list bucket links', async () => {
const rootKey = buck.root?.key || ''

const rep = await client.links(rootKey)
expect(rep.url).to.not.equal('')
expect(rep.ipns).to.not.equal('')
})

it('should remove an entire bucket', async () => {
const rootKey = buck.root?.key || ''
const rep = await client.listPath(rootKey, 'dir1/file1.jpg')
Expand Down
13 changes: 13 additions & 0 deletions src/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ export class Buckets {
return res.toObject().rootsList
}

/**
* Returns a list of bucket links.
* @param key Unique (IPNS compatible) identifier key for a bucket.
* @param ctx Context object containing web-gRPC headers and settings.
*/
async links(key: string, ctx?: Context) {
logger.debug('link request')
const req = new pb.LinksRequest()
req.setKey(key)
const res: pb.LinksReply = await this.unary(API.Links, req, ctx)
return res.toObject()
}

/**
* Returns information about a bucket path.
* @param key Unique (IPNS compatible) identifier key for a bucket.
Expand Down

0 comments on commit 196371d

Please sign in to comment.