Automatic push from FunctionsAPI
This commit is contained in:
parent
65ff980578
commit
61a8ea3bc1
3535
Cargo.lock
generated
Normal file
3535
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
edition = "2024"
|
||||
name = "web"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
fathom-function = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||
pipeline-application = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
|
||||
uuid = { version = "1" }
|
||||
42
README.md
42
README.md
@ -1,2 +1,42 @@
|
||||
# 1cc4119566eb4d6fb7b933718d68ceff
|
||||
# Updates the pipeline facility geolocations
|
||||
|
||||
A function that updates the pipeline facilities with their geolocation based on
|
||||
the pipeline route. Fails if there is no pipeline route.
|
||||
|
||||
## Input
|
||||
|
||||
### Arguments
|
||||
|
||||
- `org_id`: as string which should be a valid `uuid` for the organization
|
||||
- `project_id`: the id of the data project where the pipeline data is found
|
||||
- `pipeline_id`: an `array` of `stings` which should be valid UUIDs for pipelines
|
||||
|
||||
## Creating the function on the platform
|
||||
|
||||
To create this function on the platform using the `cli` set up the port forwarding as shown in README.
|
||||
|
||||
Then run the following command to create the function.
|
||||
|
||||
```bash
|
||||
cargo run functions create \
|
||||
-f functions/facility_locations \
|
||||
-d "Update the facility locations based on the pipeline route and log distance" \
|
||||
-i org_id=string \
|
||||
-i project_id=string \
|
||||
-i pipeline_id=array
|
||||
```
|
||||
|
||||
## Testing the function locally
|
||||
|
||||
You can run and test the function locally by running
|
||||
|
||||
```bash
|
||||
cargo run
|
||||
```
|
||||
|
||||
Then you can check it work with `curl` as follows
|
||||
|
||||
```bash
|
||||
curl -X POST localhost:8080 -v \
|
||||
-d "\"{\\\"pipeline_id\\\": [\\\"01965e16-e594-7841-b337-623f73a08722\\\"]}\""
|
||||
```
|
||||
|
||||
39
src/main.rs
Normal file
39
src/main.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use pipeline_application::application::{Application, Env};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
// There is an issue with the data form component at the moment and its giving back
|
||||
// a null value
|
||||
const DEFAULT_PROJECT_ID: &str = "680b61b0aedd6f9e639d8699";
|
||||
|
||||
#[fathom_function::function]
|
||||
async fn pipeline_route(input: Input) -> Result<Output, String> {
|
||||
let app = Application::new(
|
||||
Env::Dev,
|
||||
input.org_id,
|
||||
input.project_id.as_deref().unwrap_or(DEFAULT_PROJECT_ID),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
for pipeline_id in input.pipeline_id {
|
||||
app.update_assets_with_geo_locations(pipeline_id)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Ok(Output {
|
||||
status: "Success".to_owned(),
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Output {
|
||||
status: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Input {
|
||||
org_id: Uuid,
|
||||
project_id: Option<String>,
|
||||
pipeline_id: Vec<Uuid>,
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user