Skip to content

Commit

Permalink
feat: Add components subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
KokaKiwi committed Jan 31, 2025
1 parent 7b4ac7c commit 73c413e
Show file tree
Hide file tree
Showing 25 changed files with 481 additions and 115 deletions.
101 changes: 101 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ json_pretty = "0.1.2"
lazy_static = "1.5.0"
libflate = "2.1.0"
log = "0.4.22"
miette = "7.4.0"
openssl = "0.10.68"
pin-project = "1.1.7"
progenitor = "0.9.0"
Expand Down
133 changes: 78 additions & 55 deletions crates/api-client/openapi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.1",
"info": {
"title": "Edgee API",
"title": "Edgee endpoints",
"version": "1"
},
"servers": [
Expand Down Expand Up @@ -1563,6 +1563,43 @@
}
}
}
},
"post": {
"operationId": "createComponent",
"summary": "Create a Component",
"description": "Create a Component.",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ComponentCreateInput"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "The created Component",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Component"
}
}
}
},
"4XX": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/v1/components/{id}": {
Expand Down Expand Up @@ -1820,53 +1857,6 @@
}
}
}
},
"post": {
"operationId": "createComponent",
"summary": "Create a Component",
"description": "Create a Component.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ComponentCreateInput"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "The created Component",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Component"
}
}
}
},
"4XX": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/v1/invitations": {
Expand Down Expand Up @@ -2111,7 +2101,7 @@
}
}
},
"/v1/projects/{id}/debug/data-collection/incoming": {
"/v1/projects/{id}/incoming_data_collection_events": {
"get": {
"operationId": "getIncomingDataCollectionEvents",
"summary": "List all Incoming Data Collection Events",
Expand Down Expand Up @@ -2176,7 +2166,7 @@
}
}
},
"/v1/projects/{id}/debug/data-collection/outgoing/{event_id}": {
"/v1/projects/{id}/outgoing_data_collection_events/{event_id}": {
"get": {
"operationId": "getOutgoingDataCollectionEvents",
"summary": "List all Outgoing Data Collection Events",
Expand Down Expand Up @@ -2248,6 +2238,24 @@
}
}
}
},
"/v1/upload/presign": {
"get": {
"operationId": "getUploadPresignedUrl",
"summary": "Get Upload Presigned URL",
"responses": {
"200": {
"description": "An Upload Presigned URL",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UploadPresign"
}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -3102,6 +3110,10 @@
"description": {
"type": "string",
"description": "Description of the component."
},
"organization_id": {
"type": "string",
"description": "Unique identifier for the organization the component belongs to"
}
},
"required": [
Expand Down Expand Up @@ -3287,10 +3299,6 @@
"description": "Slug of the user",
"readOnly": true
},
"role": {
"type": "string",
"readOnly": true
},
"avatar_url": {
"type": "string",
"description": "Avatar of the user",
Expand All @@ -3311,7 +3319,11 @@
"readOnly": true
}
},
"required": ["object", "id", "email", "name", "slug", "role", "created_at", "updated_at"]
"required": [
"id",
"email",
"name"
]
},
"OrganizationUser": {
"type": "object",
Expand Down Expand Up @@ -3495,6 +3507,17 @@
}
}
},
"UploadPresign": {
"type": "object",
"properties": {
"upload_url": {
"type": "string"
}
},
"required": [
"upload_url"
]
},
"ErrorResponse": {
"type": "object",
"description": "An error response from the API. More info [here]('/docs/api-reference/errors')",
Expand Down
10 changes: 10 additions & 0 deletions crates/api-client/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ impl Credentials {
file.write_all(content.as_bytes())
.context("Could not write credentials data")
}

pub fn check_api_token(&self) -> Result<()> {
let Some(_api_token) = self.api_token.as_deref() else {
anyhow::bail!("Not logged in");
};

// TODO: Check API token is valid using the API

Ok(())
}
}

impl<'a, S: State> ConnectBuilder<'a, S> {
Expand Down
1 change: 1 addition & 0 deletions crates/api-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod auth;
mod upload;

pub const PROD_BASEURL: &str = "https://api.edgee.app";

Expand Down
Loading

0 comments on commit 73c413e

Please sign in to comment.