-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update] conversation reset at current step if csml code change
- Loading branch information
Showing
34 changed files
with
722 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use csml_engine::{create_bot_version}; | ||
use csml_interpreter::data::csml_bot::CsmlBot; | ||
use crate::format_response; | ||
|
||
use lambda_runtime::error::HandlerError; | ||
|
||
pub fn handler(bot: CsmlBot) -> Result<serde_json::Value, HandlerError> { | ||
|
||
let res = create_bot_version(bot); | ||
|
||
match res { | ||
Ok(data) => { | ||
Ok(serde_json::json!( | ||
{ | ||
"isBase64Encoded": false, | ||
"statusCode": 201, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": data, | ||
} | ||
)) | ||
}, | ||
Err(err) => { | ||
let error = format!("EngineError: {:?}", err); | ||
return Ok(format_response(400, serde_json::json!(error))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use csml_engine::{get_bot_by_version_id }; | ||
use crate::format_response; | ||
|
||
use crate::{routes::GetByIdRequest}; | ||
use lambda_runtime::error::HandlerError; | ||
|
||
pub fn handler(body: GetByIdRequest) -> Result<serde_json::Value, HandlerError> { | ||
|
||
let res = get_bot_by_version_id(&body.id, &body.bot_id); | ||
|
||
match res { | ||
Ok(data) => Ok(serde_json::json!( | ||
{ | ||
"isBase64Encoded": false, | ||
"statusCode": 200, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": serde_json::json!(data).to_string() | ||
} | ||
)), | ||
Err(err) => { | ||
let error = format!("EngineError: {:?}", err); | ||
return Ok(format_response(400, serde_json::json!(error))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use csml_engine::{get_bot_by_version_id }; | ||
use crate::format_response; | ||
|
||
use crate::{routes::GetByIdRequest}; | ||
use lambda_runtime::error::HandlerError; | ||
|
||
pub fn handler(body: GetByIdRequest) -> Result<serde_json::Value, HandlerError> { | ||
|
||
let res = get_bot_by_version_id(&body.id, &body.bot_id); | ||
|
||
match res { | ||
Ok(data) => { | ||
match data { | ||
Some(data) => { | ||
Ok(serde_json::json!( | ||
{ | ||
"isBase64Encoded": false, | ||
"statusCode": 200, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": data.flatten() | ||
} | ||
)) | ||
} | ||
None => { | ||
Ok(serde_json::json!({ | ||
"isBase64Encoded": false, | ||
"statusCode": 400, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": "Not found" | ||
})) | ||
} | ||
} | ||
}, | ||
Err(err) => { | ||
let error = format!("EngineError: {:?}", err); | ||
return Ok(format_response(400, serde_json::json!(error))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use csml_engine::{get_bot_versions }; | ||
use crate::format_response; | ||
|
||
use lambda_runtime::error::HandlerError; | ||
use crate::{routes::GetVersionsRequest}; | ||
|
||
|
||
pub fn handler(body: GetVersionsRequest) -> Result<serde_json::Value, HandlerError> { | ||
|
||
let res = get_bot_versions(&body.bot_id, body.limit, body.last_key); | ||
|
||
match res { | ||
Ok(data) => Ok(serde_json::json!( | ||
{ | ||
"isBase64Encoded": false, | ||
"statusCode": 200, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": data | ||
} | ||
)), | ||
Err(err) => { | ||
let error = format!("EngineError: {:?}", err); | ||
return Ok(format_response(400, serde_json::json!(error))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use csml_engine::{get_last_bot_version}; | ||
use crate::format_response; | ||
|
||
use lambda_runtime::error::HandlerError; | ||
|
||
pub fn handler(bot_id: String) -> Result<serde_json::Value, HandlerError> { | ||
|
||
let res = get_last_bot_version(&bot_id); | ||
|
||
match res { | ||
Ok(data) => { | ||
match data { | ||
Some(data) => { | ||
Ok(serde_json::json!( | ||
{ | ||
"isBase64Encoded": false, | ||
"statusCode": 200, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": data.flatten() | ||
} | ||
)) | ||
} | ||
None => { | ||
Ok(serde_json::json!({ | ||
"isBase64Encoded": false, | ||
"statusCode": 400, | ||
"headers": { "Content-Type": "application/json" }, | ||
"body": "Not found" | ||
})) | ||
} | ||
} | ||
|
||
}, | ||
Err(err) => { | ||
let error = format!("EngineError: {:?}", err); | ||
return Ok(format_response(400, serde_json::json!(error))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.