pub async fn add_geo_bans(
client: &Client,
value: &RecordValue,
areas: &[GeoArea],
) -> Result<AddedGeoBans>Expand description
Bans areas for value, skipping areas that are already banned.
Idempotent: calling it again with the same areas creates nothing and reports them all
as skipped. Not atomic: one POST /api/v1/geo-bans per new area, and on an error midway
the bans already created stay. Calling it again then finishes the job.
§Errors
Error::InvalidInputifvaluewas read without its geo bans (geo_bansisNone), because existing bans could not be skipped.- Any error of
GeoBans::create, e.g.ErrorCode::Forbiddenif the key may not write the zone.
§Examples
use dinio_sdk::ops::{self, ValueSelector};
let catalog = client.geo().catalog().await?;
let areas = [catalog.parse_area("HR")?, catalog.parse_area("Europe")?];
let selector = ValueSelector::Data("192.0.2.10".into());
let (_, value) =
ops::find_value_with_geo_bans(client, zone, "www.example.com", "A", &selector).await?;
let added = ops::add_geo_bans(client, &value, &areas).await?;
println!("{} created, {} already banned", added.created.len(), added.skipped.len());