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: StringThe 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
impl Clone for TimePeriod
Source§fn clone(&self) -> TimePeriod
fn clone(&self) -> TimePeriod
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConfigObject for TimePeriod
impl ConfigObject for TimePeriod
Source§fn config_path() -> Option<String>
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
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.
type Builder = TimePeriodBuilder
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.
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§impl Debug for TimePeriod
impl Debug for TimePeriod
Source§impl Default for TimePeriod
impl Default for TimePeriod
Source§impl<'de> Deserialize<'de> for TimePeriod
impl<'de> Deserialize<'de> for TimePeriod
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>,
Source§impl From<TimePeriod> for TimePeriodRef
impl From<TimePeriod> for TimePeriodRef
Source§fn from(timeperiod: TimePeriod) -> Self
fn from(timeperiod: TimePeriod) -> Self
Creates a TimePeriodRef object from a TimePeriod object.
§Arguments
timeperiod- TheTimePeriodobject from which to create theTimePeriodRefobject.
§Returns
A TimePeriodRef object.
Source§impl PartialEq for TimePeriod
impl PartialEq for TimePeriod
Source§impl Persistent for TimePeriod
impl Persistent for TimePeriod
fn name_regex(&self) -> Option<String>
fn validated_name(&self, name: &str) -> Result<String, OpsviewConfigError>
fn set_name(&mut self, new_name: &str) -> Result<String, OpsviewConfigError>
fn clear_readonly(&mut self)
Source§fn clone_new_name(
original: &Self,
new_name: &str,
) -> Result<Self, OpsviewConfigError>
fn clone_new_name( original: &Self, new_name: &str, ) -> Result<Self, OpsviewConfigError>
Source§async fn exists(
&self,
client: &OpsviewClient,
) -> Result<bool, OpsviewClientError>
async fn exists( &self, client: &OpsviewClient, ) -> Result<bool, OpsviewClientError>
Source§async fn fetch(
&self,
client: &OpsviewClient,
params: Option<Params>,
) -> Result<Self, OpsviewClientError>
async fn fetch( &self, client: &OpsviewClient, params: Option<Params>, ) -> Result<Self, OpsviewClientError>
Source§async fn remove(
&self,
client: &OpsviewClient,
) -> Result<Value, OpsviewClientError>
async fn remove( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>
Source§async fn create(
&self,
client: &OpsviewClient,
) -> Result<Value, OpsviewClientError>
async fn create( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>
Source§async fn update(
&self,
client: &OpsviewClient,
) -> Result<Value, OpsviewClientError>
async fn update( &self, client: &OpsviewClient, ) -> Result<Value, OpsviewClientError>
Source§impl Serialize for TimePeriod
impl Serialize for TimePeriod
impl Eq for TimePeriod
impl StructuralPartialEq for TimePeriod
Auto Trait Implementations§
impl Freeze for TimePeriod
impl RefUnwindSafe for TimePeriod
impl Send for TimePeriod
impl Sync for TimePeriod
impl Unpin for TimePeriod
impl UnwindSafe for TimePeriod
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,
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.