pub struct SinkholeLists<'a> { /* private fields */ }Expand description
Sinkhole list routes, from Client::sinkhole_lists.
Rules are in SinkholeRoles, links to client identities
in SinkholeLinks. With a personal key you see and change
only your own lists (all of them as an Admin). A zone key has no access: every route
answers ErrorCode::Forbidden.
Lists have an optional, non-unique name; to find one by name, see
ops::find_sinkhole_list.
§Examples
A blacklist for one client:
use dinio_sdk::models::{NewSinkholeList, NewSinkholeRole, SinkholeListType, SinkholeRoleType};
let identity = client.client_identities().get("203.0.113.10").await?;
let created = client
.sinkhole_lists()
.create(&NewSinkholeList {
list_type: SinkholeListType::Blacklist,
name: Some("ads".into()),
is_shared: None,
link_to: vec![identity.uuid],
})
.await?;
client
.sinkhole_roles()
.create(&NewSinkholeRole {
list_id: created.list.uuid,
sinkhole_type: SinkholeRoleType::Wildcard,
pattern: "*.ads.example".into(),
})
.await?;Implementations§
Source§impl<'a> SinkholeLists<'a>
impl<'a> SinkholeLists<'a>
Sourcepub async fn list(&self, shared: bool) -> Result<Vec<SinkholeList>>
pub async fn list(&self, shared: bool) -> Result<Vec<SinkholeList>>
The caller’s lists, or with shared every shared list on the platform (any owner);
all at once (Core does not paginate them). Rules are not included.
GET /api/v1/sinkhole-lists[?shared=true]
Sourcepub async fn get(&self, uuid: Uuid, with_roles: bool) -> Result<SinkholeList>
pub async fn get(&self, uuid: Uuid, with_roles: bool) -> Result<SinkholeList>
One list; with with_roles, its roles are filled in.
Owner or Admin only, also for a shared list.
GET /api/v1/sinkhole-lists/:uuid[?include=roles]
§Errors
ErrorCode::NotFoundif there is no such list.ErrorCode::Forbiddenif it belongs to another user.
Sourcepub async fn create(
&self,
list: &NewSinkholeList,
) -> Result<CreatedSinkholeList>
pub async fn create( &self, list: &NewSinkholeList, ) -> Result<CreatedSinkholeList>
Creates an empty list owned by the caller, linked to the identities in
link_to in the same transaction.
POST /api/v1/sinkhole-lists
§Errors
Nothing is created if:
ErrorCode::NotFound: an identity inlink_todoes not exist;ErrorCode::Forbidden: one belongs to another user;ErrorCode::Validation: the name is empty or longer than 100 characters.
Sourcepub async fn update(
&self,
uuid: Uuid,
patch: &SinkholeListPatch,
) -> Result<SinkholeList>
pub async fn update( &self, uuid: Uuid, patch: &SinkholeListPatch, ) -> Result<SinkholeList>
Changes whether a list is shared and/or its name. Owner or Admin only.
PATCH /api/v1/sinkhole-lists/:uuid
§Errors
Error::InvalidInputifpatchchanges nothing.ErrorCode::NotFoundif there is no such list.ErrorCode::Forbiddenif it belongs to another user.ErrorCode::Validationfor an empty or too long name.
Sourcepub async fn delete(&self, uuid: Uuid) -> Result<()>
pub async fn delete(&self, uuid: Uuid) -> Result<()>
Deletes a list with its rules and every link to it, including other users’ links to a shared list. Owner or Admin only.
DELETE /api/v1/sinkhole-lists/:uuid
§Errors
ErrorCode::NotFoundif there is no such list.ErrorCode::Forbiddenif it belongs to another user.