TimePeriod

Struct TimePeriod 

Source
pub struct TimePeriod {
Show 18 fields pub name: String, pub alias: Option<String>, pub friday: Option<String>, pub monday: Option<String>, pub saturday: Option<String>, pub sunday: Option<String>, pub thursday: Option<String>, pub tuesday: Option<String>, pub wednesday: Option<String>, pub zone: Option<TimeZone>, pub host_check_periods: Option<ConfigRefMap<HostRef>>, pub host_notification_periods: Option<ConfigRefMap<HostRef>>, pub id: Option<u64>, pub object_locked: Option<bool>, pub ref_: Option<String>, pub servicecheck_check_periods: Option<ConfigRefMap<ServiceCheckRef>>, pub servicecheck_notification_periods: Option<ConfigRefMap<ServiceCheckRef>>, pub uncommitted: Option<bool>,
}
Expand description

Represents a Time Period in Opsview.

Time periods are used within Opsview Monitor for one of two purposes; determining when a super::Host or super::ServiceCheck is being actively monitored, and determining when notifications should be sent.

For example, if a Host only needs to be monitored during office hours, then an administrator can create a Time Period called ‘Working Hours’ that is 9am-5pm, Monday to Friday, and then ‘apply’ this TimePeriod to the Host via a field called the ‘Check Period’, i.e. ‘What *period *of time should I actively *check *this Host’. Service Checks can be configured to have a fixed Time Period or to inherit the check period from the Host. This will apply to all Service Checks whether the Service Checks are applied individually via the ‘Service Checks’ tab or in bulk via the addition of a Host template.

There are seven days within the TimePeriod, Sunday through to Saturday. In each day, the hours can be defined in an ‘HH:MM’ format, and comma-separated for multiple ranges. For example, ‘00:00-24:00’ means ‘all day’, ‘09:00-17:00’ means ‘9am to 5pm’, ‘00:00-09:00,17:00-23:59’ means ’not 9-5pm’, and so forth.

An important point to note is the hours defined do not go over the midnight boundary, for example “22:00-02:00” is not valid - instead use ‘22:00-23:59’ on the first day, and ‘00:00-02:00’ on the following day.

This struct represents the structure of a time period entity as used in the Opsview API.

§Example

use opsview::config::TimePeriod;
use opsview::prelude::*;

let time_period = TimePeriod::builder()
   .name("MyTimePeriod")
   .alias("My Time Period Alias")
   .monday("00:00-09:00,17:00-24:00")
   .tuesday("00:00-09:00,17:00-24:00")
   .wednesday("00:00-09:00,17:00-24:00")
   .thursday("00:00-09:00,17:00-24:00")
   .friday("00:00-09:00,17:00-24:00")
   .saturday("00:00-09:00,17:00-24:00")
   .sunday("00:00-09:00,17:00-24:00")
   .build()
   .unwrap();

assert_eq!(time_period.name, "MyTimePeriod".to_string());
assert_eq!(time_period.alias, Some("My Time Period Alias".to_string()));
assert_eq!(time_period.monday, Some("00:00-09:00,17:00-24:00".to_string()));

Fields§

§name: String

The name of the TimePeriod.

§alias: Option<String>

Optional alias for the TimePeriod.

§friday: Option<String>

Optional string representing the TimePeriod for Friday.

Example: "00:00-09:00,17:00-24:00"

§monday: Option<String>

Optional string representing the TimePeriod for Monday.

Example: "00:00-09:00,17:00-24:00"

§saturday: Option<String>

Optional string representing the TimePeriod for Saturday.

Example: "00:00-09:00,17:00-24:00"

§sunday: Option<String>

Optional string representing the TimePeriod for Sunday.

Example: "00:00-09:00,17:00-24:00"

§thursday: Option<String>

Optional string representing the TimePeriod for Thursday.

Example: "00:00-09:00,17:00-24:00"

§tuesday: Option<String>

Optional string representing the TimePeriod for Tuesday.

Example: "00:00-09:00,17:00-24:00"

§wednesday: Option<String>

Optional string representing the TimePeriod for Wednesday.

Example: "00:00-09:00,17:00-24:00"

§zone: Option<TimeZone>

Optional TimeZone in which the TimePeriod is defined.

Default: Some(TimeZone{ name: "SYSTEM".to_string(), ref_: "/rest/config/timezone/1".to_string() }).

§host_check_periods: Option<ConfigRefMap<HostRef>>

ConfigRefMap of HostRef objects associated with this TimePeriod for their checks.

§host_notification_periods: Option<ConfigRefMap<HostRef>>

ConfigRefMap of HostRef objects associated with this TimePeriod for their notifications.

§id: Option<u64>

The unique identifier of the TimePeriod.

§object_locked: Option<bool>

Optional boolean indicating whether the TimePeriod is locked.

§ref_: Option<String>

A reference string unique to this TimePeriod.

§servicecheck_check_periods: Option<ConfigRefMap<ServiceCheckRef>>

ConfigRefMap of ServiceCheckRef objects associated with this TimePeriod for their checks.

§servicecheck_notification_periods: Option<ConfigRefMap<ServiceCheckRef>>

ConfigRefMap of ServiceCheckRef objects associated with this TimePeriod for their notifications.

§uncommitted: Option<bool>

A boolean indicating whether the TimePeriod is uncommitted.

Trait Implementations§

Source§

impl Clone for TimePeriod

Source§

fn clone(&self) -> TimePeriod

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConfigObject for TimePeriod

Source§

fn builder() -> Self::Builder

Returns a builder for constructing a TimePeriod object.

§Returns

A TimePeriodBuilder object.

Source§

fn config_path() -> Option<String>

Provides the configuration path for a TimePeriod object within the Opsview system.

§Returns

A string representing the API path where time periods are configured.

Source§

fn unique_name(&self) -> String

Returns the unique name of the TimePeriod object.

This name is used to identify the TimePeriod when building the HashMap for an ConfigObjectMap.

§Returns

A string representing the unique name of the TimePeriod.

Source§

type Builder = TimePeriodBuilder

Source§

fn minimal(name: &str) -> Result<Self, OpsviewConfigError>

Source§

impl CreateFromJson for TimePeriod

Enables the creation of a TimePeriod instance from a JSON representation. Typically used when parsing JSON data from the Opsview API.

Source§

fn from_json(json: &str) -> Result<Self, Error>

Deserializes a JSON string into an instance of the implementing type. Read more
Source§

impl Debug for TimePeriod

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimePeriod

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TimePeriod

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<TimePeriod> for TimePeriodRef

Source§

fn from(timeperiod: TimePeriod) -> Self

Creates a TimePeriodRef object from a TimePeriod object.

§Arguments
§Returns

A TimePeriodRef object.

Source§

impl PartialEq for TimePeriod

Source§

fn eq(&self, other: &TimePeriod) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Persistent for TimePeriod

Source§

fn id(&self) -> Option<u64>

Returns the unique identifier.

Source§

fn ref_(&self) -> Option<String>

Returns the reference string if it’s not empty.

Source§

fn name(&self) -> Option<String>

Returns the name if it’s not empty.

Source§

fn name_regex(&self) -> Option<String>

Source§

fn validated_name(&self, name: &str) -> Result<String, OpsviewConfigError>

Source§

fn set_name(&mut self, new_name: &str) -> Result<String, OpsviewConfigError>

Source§

fn clear_readonly(&mut self)

Source§

fn clone_new_name( original: &Self, new_name: &str, ) -> Result<Self, OpsviewConfigError>

Clones an existing object, but with a new name and with read-only fields cleared.
Source§

async fn exists( &self, client: &OpsviewClient, ) -> Result<bool, OpsviewClientError>

Checks whether the object exists in the Opsview Server. Read more
Source§

async fn fetch( &self, client: &OpsviewClient, params: Option<Params>, ) -> Result<Self, OpsviewClientError>

Retrieves the object from the Opsview Server and returns it. Read more
Source§

async fn remove( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>

Removes the object from the Opsview Server. Read more
Source§

async fn create( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>

Creates the object on the Opsview Server if it doesn’t already exist.
Source§

async fn update( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>

Updates the object on the Opsview Server if it exists, creates it if it doesn’t.
Source§

impl Serialize for TimePeriod

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for TimePeriod

Source§

impl StructuralPartialEq for TimePeriod

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,