Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: account plan subscriptions and space usage API sugar #1171

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Nov 20, 2023

This PR allows you to get a list of subscriptions for your account plan, and also get the current per space usage (I've not exposed the full report yet since we don't have any UI that would use it).

e.g.

Getting subscriptions list:

const account = Object.values(client.accounts())[0]
const subs = await account.plan.subscriptions()
for (const sub of subs.ok) {
  console.log(`ID: ${sub.subscription}`)
  console.log(`Consumers: ${sub.consumers.join(', ')}`)
  console.log(`Provider: ${sub.provider}`)
}

Getting usage:

const space = client.spaces()[0]
const usage = await space.usage.get()
console.log(`${space.did()}: ${usage.ok} bytes`)

So, you no longer have to invoke capabilities directly like this:
https://github.com/web3-storage/w3cli/blob/ca21f6736fb8c2180d3634f40931b91e4f0bb964/index.js#L553-L571

@alanshaw alanshaw requested review from gobengo, Gozala and travis and removed request for gobengo and Gozala November 20, 2023 16:39
*/
constructor(did, meta = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes API. Should we either:

  • support the old constructor signature too
  • make this a major version bump
  • note the breaking change but dont do more than minor (as is)

Any is fine, just noting the API change here

@alanshaw alanshaw changed the title feat: account plan subscriptions and space usage API sugar feat!: account plan subscriptions and space usage API sugar Nov 21, 2023
@alanshaw alanshaw merged commit 0bc589b into main Nov 22, 2023
5 checks passed
@alanshaw alanshaw deleted the feat/account-subs-space-usage-sugar branch November 22, 2023 11:39
gobengo pushed a commit that referenced this pull request Nov 28, 2023
This PR allows you to get a list of subscriptions for your account plan,
and also get the current per space usage (I've not exposed the full
report yet since we don't have any UI that would use it).

e.g.

Getting subscriptions list:

```js
const account = Object.values(client.accounts())[0]
const subs = await account.plan.subscriptions()
for (const sub of subs.ok) {
  console.log(`ID: ${sub.subscription}`)
  console.log(`Consumers: ${sub.consumers.join(', ')}`)
  console.log(`Provider: ${sub.provider}`)
}
```

Getting usage:

```js
const space = client.spaces()[0]
const usage = await space.usage.get()
console.log(`${space.did()}: ${usage.ok} bytes`)
```

So, you no longer have to invoke capabilities directly like this:

https://github.com/web3-storage/w3cli/blob/ca21f6736fb8c2180d3634f40931b91e4f0bb964/index.js#L553-L571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants