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

NAS-133688 / 25.04 / convert snapshot_count.py to new API #15448

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/middlewared/middlewared/api/v25_04_0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .pool import * # noqa
from .pool_resilver import * # noqa
from .pool_scrub import * # noqa
from .pool_snapshot_count import * # noqa
from .pool_snapshottask import * # noqa
from .privilege import * # noqa
from .rdma import * # noqa
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from middlewared.api.base import BaseModel


class PoolDatasetSnapshotCountArgs(BaseModel):
dataset: str


class PoolDatasetSnapshotCountResults(BaseModel):
result: int
18 changes: 11 additions & 7 deletions src/middlewared/middlewared/plugins/pool_/snapshot_count.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from middlewared.schema import accepts, returns, Int, Str
from middlewared.api import api_method
from middlewared.api.current import (
PoolDatasetSnapshotCountArgs,
PoolDatasetSnapshotCountResults,
)
from middlewared.service import Service


class PoolDatasetService(Service):

class Config:
namespace = "pool.dataset"

@accepts(Str("dataset"), roles=['DATASET_READ'])
@returns(Int())
@api_method(
PoolDatasetSnapshotCountArgs,
PoolDatasetSnapshotCountResults,
roles=["DATASET_READ"],
)
def snapshot_count(self, dataset):
"""
Returns snapshot count for specified `dataset`.
"""
"""Returns snapshot count for specified `dataset`."""
return self.middleware.call_sync("zfs.snapshot.count", [dataset])[dataset]
Loading