pub struct ChronixResource {
pub measurement: String,
pub namespace: Option<String>,
pub tags: BTreeMap<String, String>,
}Expand description
A Chronix resource subject to authorization.
Fields§
§measurement: StringMeasurement name.
namespace: Option<String>Optional namespace the measurement belongs to.
When set, the Cedar entity for this resource will have the
corresponding Chronix::Namespace as a parent, enabling
namespace-scoped policies such as:
permit(
principal in Chronix::Role::"ns_reader",
action == Chronix::Action::"Read",
resource in Chronix::Namespace::"production"
);Optional tag constraints (for fine-grained access).
Implementations§
Source§impl ChronixResource
impl ChronixResource
Sourcepub fn measurement(name: impl Into<String>) -> Self
pub fn measurement(name: impl Into<String>) -> Self
Create a new resource for a measurement.
Sourcepub fn with_namespace(self, ns: impl Into<String>) -> Self
pub fn with_namespace(self, ns: impl Into<String>) -> Self
Set the namespace this measurement belongs to.
This causes the measurement entity to have the namespace as a
Cedar parent, enabling resource in Chronix::Namespace::"..." policies.
Sourcepub fn with_tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a tag constraint.
Sourcepub fn to_entity(&self) -> Result<Entity, AuthzError>
pub fn to_entity(&self) -> Result<Entity, AuthzError>
Convert to a Cedar entity.
If a namespace is set, the namespace entity is included as a
parent so that resource in Chronix::Namespace::"..." policies
evaluate correctly.
Sourcepub fn namespace_entity(&self) -> Option<Entity>
pub fn namespace_entity(&self) -> Option<Entity>
Build the namespace parent entity (if set).
Call this to include in the Cedar entity set so the authorizer can resolve the parent relationship.
Sourcepub fn to_entity_uid(&self) -> EntityUid
pub fn to_entity_uid(&self) -> EntityUid
Convert to the Cedar entity UID.
Trait Implementations§
Source§impl Clone for ChronixResource
impl Clone for ChronixResource
Source§fn clone(&self) -> ChronixResource
fn clone(&self) -> ChronixResource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChronixResource
impl Debug for ChronixResource
Source§impl<'de> Deserialize<'de> for ChronixResource
impl<'de> Deserialize<'de> for ChronixResource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ChronixResource
Source§impl PartialEq for ChronixResource
impl PartialEq for ChronixResource
Source§impl Serialize for ChronixResource
impl Serialize for ChronixResource
impl StructuralPartialEq for ChronixResource
Auto Trait Implementations§
impl Freeze for ChronixResource
impl RefUnwindSafe for ChronixResource
impl Send for ChronixResource
impl Sync for ChronixResource
impl Unpin for ChronixResource
impl UnsafeUnpin for ChronixResource
impl UnwindSafe for ChronixResource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more