pub struct Redirects<'a> { /* private fields */ }Expand description
HTTP(S) redirects by host name, from Client::redirects.
A redirect lives on a host name inside a zone, and access to it is access to that zone: the zone’s key, a member of the zone, or an Admin. Creating one makes Core add the DNS records that point the name at the platform; deleting it removes them.
Implementations§
Source§impl<'a> Redirects<'a>
impl<'a> Redirects<'a>
Sourcepub async fn list(
&self,
zone_id: Option<Uuid>,
page: PageRequest,
) -> Result<Page<Redirect>>
pub async fn list( &self, zone_id: Option<Uuid>, page: PageRequest, ) -> Result<Page<Redirect>>
One page of the redirects of zone_id, or of every zone the caller can access when
None (a zone key: its zone; an Admin: all). Without certificate status; read one
redirect with get for that.
GET /api/v1/redirects[?zone_id=...]
§Errors
ErrorCode::Forbidden if the caller has no access to
zone_id.
Sourcepub async fn get(&self, name: &str) -> Result<Redirect>
pub async fn get(&self, name: &str) -> Result<Redirect>
One redirect by host name, with its certificate status for tls = Auto.
GET /api/v1/redirects/:name
§Errors
ErrorCode::NotFound if there is no such redirect.
Sourcepub async fn create(&self, redirect: &NewRedirect) -> Result<Redirect>
pub async fn create(&self, redirect: &NewRedirect) -> Result<Redirect>
Creates a redirect and the DNS records that point its name at the platform; Relay
starts answering HTTP(S) requests for the name. With tls = Auto
Core starts issuing a certificate right away. Returns it with the name normalized.
POST /api/v1/redirects
§Errors
ErrorCode::Conflictif the name already has a redirect, is not inside the zone, belongs to a more specific hosted zone or is delegated away, already has A/AAAA/CNAME records of the user’s own, or (Auto) is covered by another certificate.ApiError::detailslists the reasons.ErrorCode::Validationfor a bad name, code or URL.
§Examples
use dinio_sdk::models::{NewRedirect, RedirectTls};
use dinio_sdk::ops;
let zone = ops::find_zone_for_host(client, "go.example.com").await?;
let redirect = NewRedirect {
zone_id: zone.uuid,
name: "go.example.com".into(),
code: 302,
location: "https://example.com/landing".into(),
tls: Some(RedirectTls::Auto),
};
client.redirects().create(&redirect).await?;Sourcepub async fn update(
&self,
name: &str,
patch: &RedirectPatch,
) -> Result<Redirect>
pub async fn update( &self, name: &str, patch: &RedirectPatch, ) -> Result<Redirect>
Changes a redirect’s code, target and/or certificate source; fields left None stay
as they are. Its DNS records do not change.
PATCH /api/v1/redirects/:name
§Errors
ErrorCode::NotFoundif there is no such redirect.ErrorCode::Validationfor a bad code or URL.ErrorCode::Conflictwhen switching toAutowhile another certificate covers the name.