1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*use actix_web::{web, HttpRequest, HttpResponse};
use actix_web::web::Data;
use ant_core::data::Wallet;
use log::debug;
use crate::controller::get_store_type;
use crate::error::pointer_error::PointerError;
use crate::model::pnr::{PnrZone, PnrRecord};
use crate::service::pnr_service::PnrService;
#[utoipa::path(
post,
path = "/anttp-0/pnr/mutable",
request_body(
content = PnrZone
),
responses(
(status = CREATED, description = "PNR zone created successfully", body = PnrZone),
(status = BAD_REQUEST, description = "PNR zone body was invalid")
),
params(
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
)]
pub async fn post_mutable_pnr(
pnr_service: Data<PnrService>,
evm_wallet_data: Data<Wallet>,
pnr_zone: web::Json<PnrZone>,
request: HttpRequest,
) -> Result<HttpResponse, PointerError> {
debug!("Creating new mutable PNR zone");
Ok(HttpResponse::Created().json(
pnr_service.create_mutable_pnr(pnr_zone.into_inner(), evm_wallet_data.get_ref().clone(), get_store_type(&request)).await?
))
}
#[utoipa::path(
post,
path = "/anttp-0/pnr/immutable",
request_body(
content = PnrZone
),
responses(
(status = CREATED, description = "Immutable PNR zone created successfully", body = PnrZone),
(status = BAD_REQUEST, description = "PNR zone body was invalid")
),
params(
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
)]
pub async fn post_immutable_pnr(
pnr_service: Data<PnrService>,
evm_wallet_data: Data<Wallet>,
pnr_zone: web::Json<PnrZone>,
request: HttpRequest,
) -> Result<HttpResponse, PointerError> {
debug!("Creating new immutable PNR zone");
Ok(HttpResponse::Created().json(
pnr_service.create_immutable_pnr(pnr_zone.into_inner(), evm_wallet_data.get_ref().clone(), get_store_type(&request)).await?
))
}
#[utoipa::path(
put,
path = "/anttp-0/pnr/{name}",
params(
("name", description = "PNR name"),
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
request_body(
content = PnrZone
),
responses(
(status = OK, description = "PNR zone updated successfully", body = PnrZone),
(status = BAD_REQUEST, description = "PNR zone body was invalid")
),
)]
pub async fn put_pnr(
path: web::Path<String>,
pnr_service: Data<PnrService>,
evm_wallet_data: Data<Wallet>,
pnr_zone: web::Json<PnrZone>,
request: HttpRequest,
) -> Result<HttpResponse, PointerError> {
let name = path.into_inner();
debug!("Updating PNR zone");
Ok(HttpResponse::Ok().json(
pnr_service.update_pnr(name, pnr_zone.into_inner(), evm_wallet_data.get_ref().clone(), get_store_type(&request)).await?
))
}
#[utoipa::path(
patch,
path = "/anttp-0/pnr/{name}",
params(
("name", description = "PNR name"),
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
request_body(
content = PnrZone
),
responses(
(status = OK, description = "PNR zone records appended/replaced successfully", body = PnrZone),
(status = BAD_REQUEST, description = "PNR zone body was invalid")
),
)]
pub async fn patch_pnr(
path: web::Path<String>,
pnr_service: Data<PnrService>,
evm_wallet_data: Data<Wallet>,
pnr_zone: web::Json<PnrZone>,
request: HttpRequest,
) -> Result<HttpResponse, PointerError> {
let name = path.into_inner();
debug!("Appending PNR records to zone");
Ok(HttpResponse::Ok().json(
pnr_service.append_pnr(name, pnr_zone.into_inner(), evm_wallet_data.get_ref().clone(), get_store_type(&request)).await?
))
}
#[utoipa::path(
get,
path = "/anttp-0/pnr/{name}",
params(
("name", description = "PNR name"),
),
responses(
(status = OK, description = "PNR zone retrieved successfully", body = PnrZone),
(status = NOT_FOUND, description = "PNR zone not found")
),
)]
pub async fn get_pnr(
path: web::Path<String>,
pnr_service: Data<PnrService>,
) -> Result<HttpResponse, PointerError> {
let name = path.into_inner();
debug!("Getting PNR zone");
Ok(HttpResponse::Ok().json(
pnr_service.get_pnr(name).await?
))
}
#[utoipa::path(
put,
path = "/anttp-0/pnr/{name}/{record}",
params(
("name", description = "PNR zone name"),
("record", description = "PNR record key"),
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
request_body(
content = PnrRecord
),
responses(
(status = OK, description = "PNR record added/updated successfully", body = PnrZone),
(status = BAD_REQUEST, description = "PNR record body was invalid")
),
)]
pub async fn put_pnr_record(
path: web::Path<(String, String)>,
pnr_service: Data<PnrService>,
evm_wallet_data: Data<Wallet>,
pnr_record: web::Json<PnrRecord>,
request: HttpRequest,
) -> Result<HttpResponse, PointerError> {
let (name, record_key) = path.into_inner();
debug!("Updating PNR record {} in zone {}", record_key, name);
Ok(HttpResponse::Ok().json(
pnr_service.update_pnr_record(name, record_key, pnr_record.into_inner(), evm_wallet_data.get_ref().clone(), get_store_type(&request)).await?
))
}*/