boomack 0.4.1

Client library for Boomack
Documentation
//! The Boomack API Client library.
//!
//! # Overview
//!
//! ## Configuration
//! Module: [`boomack::client::config`](config/)
//!
//! The configuration contains the server URL, the API authorization token,
//! and other parameters for the HTTP requests.
//!
//! * The [`Config`](config/struct.Config.html) struct with methods
//!   for loading configuration values from different sources
//!
//! ## JSON
//! Module: [`boomack::client::json`](json/)
//!
//! JSON specific functions are required for the dynamic or extensible
//! request parts, like e. g. display options.
//!
//! * The [`JsonMap`](json/type.JsonMap.html) type to hold the JSON data
//! * Conversion of your structures into a JSON map with
//!   [`to_json_map`](json/fn.to_json_map.html)  
//!   (Your structure must implement serde serialization)
//! * Setter for manipulation
//!     + [`set_json_bool_value`](json/fn.set_json_bool_value.html)
//!     + [`set_json_num_value`](json/fn.set_json_num_value.html)
//!     + [`set_json_str_value`](json/fn.set_json_str_value.html)
//!     + [`set_json_str_arr_value`](json/fn.set_json_str_arr_value.html)
//!     + [`set_json_arr_value`](json/fn.set_json_arr_value.html)
//!     + [`set_json_obj_value`](json/fn.set_json_obj_value.html)
//! * Pretty printing with [`pprint_json`](json/fn.pprint_json.html)
//!
//! ## Request Building
//! Module: [`boomack::client::api::ClientRequest`](api/struct.ClientRequest.html)
//!
//! In order to send a request to the HTTP API you need to first build a request structure.
//! Every group of request has its own module with functions to create a request.
//! Usually a parameters structure is involved to hold some or all information for the request.
//!
//! * Display Request [`boomack::client::display`](display/)
//!     + [`DisplayParameters`](display/struct.DisplayParameters.html)
//!     + [`display_text_request`](display/fn.display_text_request.html)
//!     + [`display_url_request`](display/fn.display_url_request.html)
//!     + [`display_file_request`](display/fn.display_file_request.html)
//!     + [`display_stdin_request`](display/fn.display_stdin_request.html)
//! * Evaluation Request [`boomack::client::eval`](eval/)
//!     + [`EvalParameters`](eval/struct.EvalParameters.html)
//!     + [`eval_file_request`](eval/fn.eval_file_request.html)
//!     + [`eval_stdin_request`](eval/fn.eval_stdin_request.html)
//!     + [`eval_text_request`](eval/fn.eval_text_request.html)
//! * Panel Management [`boomack::client::panels`](panels/)
//!     + [`get_panel_ids_request`](panels/fn.get_panel_ids_request.html)
//!     + [`get_panel_layout_request`](panels/fn.get_panel_layout_request.html)
//!     + [`set_panel_layout_request`](panels/fn.set_panel_layout_request.html)
//!     + [`delete_panel_request`](panels/fn.delete_panel_request.html)
//! * Preset Management [`boomack::client::presets`](presets/)
//!     + [`get_preset_ids_request`](presets/fn.get_preset_ids_request.html)
//!     + [`get_preset_layout_request`](presets/fn.get_preset_layout_request.html)
//!     + [`set_preset_layout_request`](presets/fn.set_preset_layout_request.html)
//!     + [`delete_preset_request`](presets/fn.delete_preset_request.html)
//! * Media Type Management [`boomack::client::types`](types/)
//!     + [`get_type_ids_request`](types/fn.get_type_ids_request.html)
//!     + [`get_type_layout_request`](types/fn.get_type_layout_request.html)
//!     + [`set_type_layout_request`](types/fn.set_type_layout_request.html)
//!     + [`delete_type_request`](types/fn.delete_type_request.html)
//! * Action Management [`boomack::client::actions`](actions/)
//!     + [`get_action_ids_request`](actions/fn.get_action_ids_request.html)
//!     + [`get_action_layout_request`](actions/fn.get_action_layout_request.html)
//!     + [`set_action_layout_request`](actions/fn.set_action_layout_request.html)
//!     + [`delete_action_request`](actions/fn.delete_action_request.html)
//! * Clearing Request
//!     + [`boomack::client::panels::clear_panel_request`](panels/fn.clear_panel_request.html)
//!     + [`boomack::client::slots::clear_slot_request`](slots/fn.clear_slot_request.html)
//! * Export Request
//!     + [`boomack::client::panels::AllPanelExportParameters`](panels/struct.AllPanelExportParameters.html)
//!     + [`boomack::client::panels::export_all_panels_request`](panels/fn.export_all_panels_request.html)
//!     + [`boomack::client::panels::PanelExportParameters`](panels/struct.PanelExportParameters.html)
//!     + [`boomack::client::panels::export_panel_request`](panels/fn.export_panel_request.html)
//!     + [`boomack::client::slots::SlotExportParameters`](slots/struct.SlotExportParameters.html)
//!     + [`boomack::client::slots::export_slot_request`](slots/fn.export_slot_request.html)
//!
//! ## Sending Request
//! Module: [`boomack::client::api`](api/)
//!
//! After a request was built, it is send to the server.
//! There are two alternative functions available.
//!
//! * [`send_request`](api/fn.send_request.html)
//! * [`send_request_with_retry`](api/fn.send_request_with_retry.html)
//!
//! # Example
//!
//! ```
//! use boomack::client::config::Config;
//! use boomack::client::json::*;
//! use boomack::client::display::{ DisplayParameters, display_text_request };
//! use boomack::client::api::{ ClientRequest, send_request };
//! 
//! fn build_config() -> Config {
//!     let mut cfg = Config::new();
//!     // you can use different sources to set up the configuration
//!     // start with the sources having the highest priority
//!     // then fill gaps left from sources with lower priority
//! 
//!     // explicit configuration values, could come from command line arguments
//!     cfg.client.format = Some(String::from("text/plain"));
//! 
//!     // usually environment variables are next in line
//!     cfg.fill_gaps_with(&Config::from_env());
//! 
//!     // load one or more specific configuration file
//!     //let config_files = vec![String::from("my-config-file.yaml")];
//!     //cfg.load_unknown_config_files(&config_files);
//! 
//!     // load the default config files from user profile and current working directory:
//!     // - boomack[.json|.yaml|.yml] from current working directory
//!     // - .boomack[.json|.yaml|.yml] from user profile
//!     // - boomack-server[.json|.yaml|.yml] from current working directory
//!     // - .boomack-server[.json|.yaml|.yml] from user profile
//!     cfg.load_known_config_files();
//! 
//!     // and at last, load the default media type mappings
//!     cfg.load_default_media_types();
//! 
//!     return cfg;
//! }
//! 
//! fn prepare_request() -> ClientRequest {
//!     // prepare the display options
//!     let mut display_options = JsonMap::new();
//!     set_json_str_value(&mut display_options, "background", "#AAFFCC44");
//!     set_json_bool_value(&mut display_options, "debug", false);
//! 
//!     // prepare display parameters with the display options
//!     let display_params = DisplayParameters {
//!         panel: Some("default"),
//!         slot: None,
//!         content_type: Some("text/markdown"),
//!         title: Some("Example"),
//!         presets: Vec::new(),
//!         options: display_options,
//!     };
//! 
//!     // create the request with some text content
//!     let markdown = r##"
//! # Headline
//! Hello World!
//! 
//! This is an example showing...
//! 
//! * Request Configuration
//! * Display Options
//! * Display Parameters
//! * Sending the Request
//! "##;
//! 
//!     display_text_request(&display_params, markdown)
//! }
//! 
//! fn main() {
//!     // first prepare the configuration for HTTP requests
//!     let cfg = build_config();
//! 
//!     // then build the client request
//!     let mut request = prepare_request();
//! 
//!     // set the accepted response format from the configuration
//!     request.set_header("Accept", cfg.client.get_format());
//! 
//!     // send the request
//!     let result = send_request(&cfg, &request);
//! 
//!     // handle the result
//!     match result {
//!         Ok(response) => {
//!             println!("STATUS: [{}] {}", response.status(), response.status_text());
//!             if response.status() != 204 {
//!                 print!("RESPONSE:\n{}\n", response.into_string().unwrap());
//!             }
//!         },
//!         Err(err) => {
//!             println!("ERROR: {}", err.to_string());
//!         },
//!     };
//! }
//! ```

mod default_types;
pub mod json;
pub mod config;
pub mod api;
pub mod display;
pub mod eval;
pub mod panels;
pub mod slots;
pub mod presets;
pub mod types;
pub mod actions;