Skip to main content

PlatformApiClient

Struct PlatformApiClient 

Source
pub struct PlatformApiClient { /* private fields */ }
Expand description

Client for interacting with the Syncable Platform API

Implementations§

Source§

impl PlatformApiClient

Source

pub fn new() -> Result<Self>

Create a new Platform API client using the default API URL

Uses SYNCABLE_ENV=development to switch to local development server.

Source

pub fn with_url(api_url: impl Into<String>) -> Result<Self>

Create a new Platform API client with a custom API URL

Source

pub fn api_url(&self) -> &str

Get the configured API URL

Source

pub async fn get_current_user(&self) -> Result<UserProfile>

Get the current authenticated user’s profile

Endpoint: GET /api/users/me

Source

pub async fn list_organizations(&self) -> Result<Vec<Organization>>

List organizations the authenticated user belongs to

Endpoint: GET /api/organizations/attended-by-user

Source

pub async fn get_organization(&self, id: &str) -> Result<Organization>

Get an organization by ID

Endpoint: GET /api/organizations/:id

Source

pub async fn list_projects(&self, org_id: &str) -> Result<Vec<Project>>

List projects in an organization

Endpoint: GET /api/projects/organization/:organizationId

Source

pub async fn get_project(&self, id: &str) -> Result<Project>

Get a project by ID

Endpoint: GET /api/projects/:id

Source

pub async fn create_project( &self, org_id: &str, name: &str, description: &str, ) -> Result<Project>

Create a new project in an organization

Endpoint: POST /api/projects

Note: This first fetches the current user to get the creator_id.

Source

pub async fn list_project_repositories( &self, project_id: &str, ) -> Result<ProjectRepositoriesResponse>

List repositories connected to a project

Returns all GitHub/GitLab repositories that have been connected to the project. Use this to get repository info needed for deployment configuration.

Endpoint: GET /api/github/projects/:projectId/repositories

Source

pub async fn list_github_installations( &self, ) -> Result<GitHubInstallationsResponse>

List GitHub App installations for the organization

Returns all GitHub App installations accessible to the authenticated user’s organization. Use this to find which GitHub accounts are connected.

Endpoint: GET /api/github/installations

Source

pub async fn get_github_installation_url( &self, ) -> Result<GitHubInstallationUrlResponse>

Get the URL to install the GitHub App

Returns the URL users should visit to install the Syncable GitHub App. Use this when no installations are found.

Endpoint: GET /api/github/installation/url

Source

pub async fn list_available_repositories( &self, project_id: Option<&str>, search: Option<&str>, page: Option<i32>, ) -> Result<AvailableRepositoriesResponse>

List repositories available for connection

Returns repositories accessible through GitHub App installations, including which ones are already connected to the project.

Endpoint: GET /api/github/repositories/available

Source

pub async fn connect_repository( &self, request: &ConnectRepositoryRequest, ) -> Result<ConnectRepositoryResponse>

Connect a repository to a project

Connects a GitHub repository to a project, allowing deployments from that repo.

Endpoint: POST /api/github/projects/repositories/connect

Source

pub async fn initialize_gitops( &self, project_id: &str, installation_id: Option<i64>, ) -> Result<InitializeGitOpsResponse>

Initialize GitOps repository for a project

Ensures a GitOps infrastructure repository exists for the project. If it doesn’t exist, automatically creates it using the GitHub App installation.

Endpoint: POST /api/projects/:projectId/gitops/initialize

Source

pub async fn list_environments( &self, project_id: &str, ) -> Result<Vec<Environment>>

List environments for a project

Returns all environments (deployment targets) defined for the project.

Endpoint: GET /api/projects/:projectId/environments

Source

pub async fn create_environment( &self, project_id: &str, name: &str, environment_type: &str, cluster_id: Option<&str>, provider_regions: Option<&HashMap<String, String>>, ) -> Result<Environment>

Create a new environment for a project

Creates an environment with the specified type (cluster or cloud). For cluster environments, a cluster_id is required.

Endpoint: POST /api/environments

Note: environment_type should be “cluster” (for K8s) or “cloud” (for Cloud Runner)

Source

pub async fn check_provider_connection( &self, provider: &CloudProvider, project_id: &str, ) -> Result<Option<CloudCredentialStatus>>

Check if a cloud provider is connected to a project

Returns Some(status) if the provider is connected, None if not connected.

SECURITY NOTE: This method only returns connection STATUS, never actual credentials. The agent should never have access to OAuth tokens, API keys, or other secrets.

Uses: GET /api/cloud-credentials?projectId=xxx (lists all, then filters)

Source

pub async fn list_cloud_credentials_for_project( &self, project_id: &str, ) -> Result<Vec<CloudCredentialStatus>>

List all cloud credentials for a project

Returns all connected cloud providers for the project.

SECURITY NOTE: This method only returns connection STATUS, never actual credentials.

Endpoint: GET /api/cloud-credentials?projectId=xxx

Source

pub async fn list_deployment_configs( &self, project_id: &str, ) -> Result<Vec<DeploymentConfig>>

List deployment configurations for a project

Returns all deployment configs associated with the project, including service name, branch, target type, and auto-deploy settings.

Endpoint: GET /api/projects/:projectId/deployment-configs

Source

pub async fn create_deployment_config( &self, request: &CreateDeploymentConfigRequest, ) -> Result<DeploymentConfig>

Create a new deployment configuration

Creates a deployment config for a service. Requires repository integration to be set up first (GitHub/GitLab). The project_id should be included in the request body.

Returns the created/updated deployment config. The API also returns a was_updated flag indicating whether this was an update to an existing config.

Endpoint: POST /api/deployment-configs

Source

pub async fn update_deployment_config_secrets( &self, config_id: &str, secrets: &[DeploymentSecretInput], ) -> Result<()>

Update environment variables / secrets on a deployment config

SECURITY NOTE: This sends secret values over HTTPS to the backend. The backend stores them encrypted. API responses mask secret values.

Endpoint: PUT /api/deployment-configs/:configId/secrets

Source

pub async fn trigger_deployment( &self, request: &TriggerDeploymentRequest, ) -> Result<TriggerDeploymentResponse>

Trigger a deployment using a deployment config

Starts a new deployment for the specified config. Optionally specify a commit SHA to deploy a specific version.

Endpoint: POST /api/deployment-configs/deploy

Source

pub async fn get_deployment_status( &self, task_id: &str, ) -> Result<DeploymentTaskStatus>

Get deployment task status

Returns the current status of a deployment task, including progress percentage, current step, and overall status.

Endpoint: GET /api/deployments/task/:taskId

Source

pub async fn list_deployments( &self, project_id: &str, limit: Option<i32>, ) -> Result<PaginatedDeployments>

List deployments for a project

Returns a paginated list of deployments for the project, sorted by creation time (most recent first).

Endpoint: GET /api/deployments/project/:projectId

Source

pub async fn get_service_logs( &self, service_id: &str, start: Option<&str>, end: Option<&str>, limit: Option<i32>, ) -> Result<GetLogsResponse>

Get container logs for a deployed service

Returns recent logs from the service’s containers. Supports time filtering and line limits for efficient log retrieval.

§Arguments
  • service_id - The service/deployment ID (from list_deployments)
  • start - Optional ISO timestamp to filter logs from
  • end - Optional ISO timestamp to filter logs until
  • limit - Optional max number of log lines (default: 100)

Endpoint: GET /api/deployments/services/:serviceId/logs

Source

pub async fn list_clusters_for_project( &self, project_id: &str, ) -> Result<Vec<ClusterEntity>>

List all clusters for a project

Returns all K8s clusters available for deployments in this project.

Endpoint: GET /api/clusters/project/:projectId

Source

pub async fn get_cluster( &self, cluster_id: &str, ) -> Result<Option<ClusterEntity>>

Get a specific cluster by ID

Returns cluster details or None if not found.

Endpoint: GET /api/clusters/:clusterId

Source

pub async fn list_registries_for_project( &self, project_id: &str, ) -> Result<Vec<ArtifactRegistry>>

List all artifact registries for a project

Returns all container registries available for image storage in this project.

Endpoint: GET /api/projects/:projectId/artifact-registries

Source

pub async fn list_ready_registries_for_project( &self, project_id: &str, ) -> Result<Vec<ArtifactRegistry>>

List only ready artifact registries for a project

Returns registries that are ready to receive image pushes. Use this for deployment wizard to show only usable registries.

Endpoint: GET /api/projects/:projectId/artifact-registries/ready

Source

pub async fn create_registry( &self, project_id: &str, request: &CreateRegistryRequest, ) -> Result<CreateRegistryResponse>

Provision a new artifact registry

Starts async provisioning via Backstage scaffolder. Returns task ID for polling status.

Endpoint: POST /api/projects/:projectId/artifact-registries

Source

pub async fn get_registry_task_status( &self, task_id: &str, ) -> Result<RegistryTaskStatus>

Get registry provisioning task status

Poll this endpoint to check provisioning progress.

Endpoint: GET /api/artifact-registries/task/:taskId

Source

pub async fn get_hetzner_options( &self, project_id: &str, ) -> Result<HetznerOptionsData>

Get Hetzner options (locations and server types) with real-time data

Uses the /api/v1/cloud-runner/hetzner/options endpoint which returns both locations and server types in one call. This is the same endpoint used by the frontend for Hetzner infrastructure selection.

Endpoint: GET /api/v1/cloud-runner/hetzner/options?projectId=:projectId

Source

pub async fn get_hetzner_locations( &self, project_id: &str, ) -> Result<Vec<LocationWithAvailability>>

Get Hetzner locations with real-time availability information

Returns all Hetzner locations with the server types currently available at each location. Uses the customer’s Hetzner API token stored in their cloud credentials to query the Hetzner API.

This enables dynamic resource selection instead of relying on hardcoded values.

Endpoint: GET /api/deployments/availability/locations?projectId=:projectId

Source

pub async fn get_hetzner_server_types( &self, project_id: &str, preferred_location: Option<&str>, ) -> Result<Vec<ServerTypeSummary>>

Get Hetzner server types with pricing and availability

Returns all non-deprecated Hetzner server types sorted by monthly price, with availability information showing which locations have capacity.

Use this to dynamically populate server type selection UI and enable smart resource recommendations based on real pricing data.

Endpoint: GET /api/deployments/availability/server-types?projectId=:projectId&preferredLocation=:location

Source

pub async fn check_hetzner_availability( &self, project_id: &str, location: &str, server_type: &str, ) -> Result<AvailabilityCheckResult>

Check if a specific server type is available at a location

Returns availability status with:

  • Whether the server type is available
  • Reason if unavailable (capacity vs unsupported)
  • Alternative locations where it IS available

Use this before deployment to detect capacity issues early and suggest alternatives.

Endpoint: GET /api/deployments/availability/check?projectId=:projectId&location=:location&serverType=:serverType

Source

pub async fn list_project_networks( &self, project_id: &str, ) -> Result<Vec<CloudRunnerNetwork>>

List all cloud runner networks for a project

Returns VPCs, subnets, Azure Container App Environments, GCP VPC Connectors, etc. Use this to discover private networking infrastructure provisioned for the project.

Endpoint: GET /api/v1/cloud-runner/projects/:projectId/networks

Source

pub async fn check_connection(&self) -> Result<()>

Check if the API is reachable (quick health check)

Uses a shorter timeout (5s) for quick connectivity verification. This method does NOT require authentication.

Returns Ok(()) if API is reachable, Err(ConnectionFailed) otherwise.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,