@@ -8,8 +8,8 @@ use std::iter::Map;
88use reqwest:: { Body , Error } ;
99use serde_json:: { json, Value } ;
1010use tokio:: time:: Instant ;
11- use crate :: models:: models:: { Ancestor , create_page , CreatePage , CreatePageSpace , PageBody , Storage } ;
12- use crate :: pages:: page_service:: create_page;
11+ use crate :: models:: models:: { Ancestor , CreatePage , CreatePageSpace , PageBody , Storage } ;
12+ use crate :: pages:: page_service:: { create_page, get_page } ;
1313
1414
1515#[ tokio:: main]
@@ -21,52 +21,40 @@ async fn main() -> Result<(), Error> {
2121 let token = base64:: encode ( b"admin:admin" ) ;
2222 let conf_url = "http://localhost:8110" ;
2323
24- // CREATE PAGE
25- let req = CreatePage {
26- title : "Rust page 2" . to_string ( ) ,
27- ctype : "page" . to_string ( ) ,
28- space : CreatePageSpace {
29- key : "dev16" . to_string ( ) ,
30- } ,
31- body : PageBody {
32- storage : Storage {
33- representation : "storage" . to_string ( ) ,
34- value : "lorem..." . to_string ( ) ,
35- } ,
36- } ,
37- ancestors : vec ! [ Ancestor {
38- id: 1213317 ,
39- } ] ,
40- } ;
41- let resp = create_page ( & conf_url, & token, req) . await ;
42- println ! ( "{:?}" , resp) ;
24+ // get page
25+ let page = get_page ( conf_url, token, "1213317" . to_string ( ) ) . await ;
26+ println ! ( "{:?}" , page) ;
4327
4428
45- // create several pages
46- // for a in 21..=40 {
47- // let mut to_create: CreatePage = CreatePage {
48- // title: format!("RUST page {a}"),
29+ // CREATE PAGE
30+ // let space_key = "dev16";
31+ // let parent = 1213317;
32+ //
33+ // for a in 40..42 {
34+ // let title = format!("Rust page {a}");
35+ //
36+ // let req = CreatePage {
37+ // title: title.to_string(),
4938 // ctype: "page".to_string(),
5039 // space: CreatePageSpace {
51- // key: "DEV12" .to_string(),
40+ // key: space_key .to_string(),
5241 // },
5342 // body: PageBody {
5443 // storage: Storage {
5544 // representation: "storage".to_string(),
56- // value: rand_string(100 ),
57- // }
45+ // value: helpers::helpers:: rand_string(30).to_string( ),
46+ // },
5847 // },
5948 // ancestors: vec![Ancestor {
60- // id: 1048683
61- // }]
49+ // id: parent,
50+ // }],
6251 // };
63- //
64- // println!("{:?}", serde_json::to_string(&to_create));
65- //
66- // let created = create_page(&conf_url.to_string(), &token,to_create);
67- // let fin = created.await;
52+ // let resp = create_page(&conf_url, &token, req).await;
53+ // println!("{:?}", resp);
6854 // }
6955
56+
57+
7058 let mut end: u128 = start. elapsed ( ) . as_millis ( ) ;
7159 println ! ( "{:?}" , println!( ">>> Action took :: {end} millis" ) ) ;
7260
0 commit comments