pub struct PlatformApiClient { /* private fields */ }Expand description
Client for interacting with the Syncable Platform API
Implementations§
Source§impl PlatformApiClient
impl PlatformApiClient
Sourcepub fn new() -> Result<Self>
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.
Sourcepub fn with_url(api_url: impl Into<String>) -> Result<Self>
pub fn with_url(api_url: impl Into<String>) -> Result<Self>
Create a new Platform API client with a custom API URL
Sourcepub async fn get_current_user(&self) -> Result<UserProfile>
pub async fn get_current_user(&self) -> Result<UserProfile>
Get the current authenticated user’s profile
Endpoint: GET /api/users/me
Sourcepub async fn list_organizations(&self) -> Result<Vec<Organization>>
pub async fn list_organizations(&self) -> Result<Vec<Organization>>
List organizations the authenticated user belongs to
Endpoint: GET /api/organizations/attended-by-user
Sourcepub async fn get_organization(&self, id: &str) -> Result<Organization>
pub async fn get_organization(&self, id: &str) -> Result<Organization>
Get an organization by ID
Endpoint: GET /api/organizations/:id
Sourcepub async fn list_projects(&self, org_id: &str) -> Result<Vec<Project>>
pub async fn list_projects(&self, org_id: &str) -> Result<Vec<Project>>
List projects in an organization
Endpoint: GET /api/projects/organization/:organizationId
Sourcepub async fn get_project(&self, id: &str) -> Result<Project>
pub async fn get_project(&self, id: &str) -> Result<Project>
Get a project by ID
Endpoint: GET /api/projects/:id
Sourcepub async fn create_project(
&self,
org_id: &str,
name: &str,
description: &str,
) -> Result<Project>
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.
Sourcepub async fn list_project_repositories(
&self,
project_id: &str,
) -> Result<ProjectRepositoriesResponse>
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
Sourcepub async fn list_github_installations(
&self,
) -> Result<GitHubInstallationsResponse>
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
Sourcepub async fn get_github_installation_url(
&self,
) -> Result<GitHubInstallationUrlResponse>
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
Sourcepub async fn list_available_repositories(
&self,
project_id: Option<&str>,
search: Option<&str>,
page: Option<i32>,
) -> Result<AvailableRepositoriesResponse>
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
Sourcepub async fn connect_repository(
&self,
request: &ConnectRepositoryRequest,
) -> Result<ConnectRepositoryResponse>
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
Sourcepub async fn initialize_gitops(
&self,
project_id: &str,
installation_id: Option<i64>,
) -> Result<InitializeGitOpsResponse>
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
Sourcepub async fn list_environments(
&self,
project_id: &str,
) -> Result<Vec<Environment>>
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
Sourcepub async fn create_environment(
&self,
project_id: &str,
name: &str,
environment_type: &str,
cluster_id: Option<&str>,
) -> Result<Environment>
pub async fn create_environment( &self, project_id: &str, name: &str, environment_type: &str, cluster_id: Option<&str>, ) -> 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)
Sourcepub async fn check_provider_connection(
&self,
provider: &CloudProvider,
project_id: &str,
) -> Result<Option<CloudCredentialStatus>>
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)
Sourcepub async fn list_cloud_credentials_for_project(
&self,
project_id: &str,
) -> Result<Vec<CloudCredentialStatus>>
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
Sourcepub async fn list_deployment_configs(
&self,
project_id: &str,
) -> Result<Vec<DeploymentConfig>>
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
Sourcepub async fn create_deployment_config(
&self,
request: &CreateDeploymentConfigRequest,
) -> Result<DeploymentConfig>
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
Sourcepub async fn trigger_deployment(
&self,
request: &TriggerDeploymentRequest,
) -> Result<TriggerDeploymentResponse>
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
Sourcepub async fn get_deployment_status(
&self,
task_id: &str,
) -> Result<DeploymentTaskStatus>
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
Sourcepub async fn list_deployments(
&self,
project_id: &str,
limit: Option<i32>,
) -> Result<PaginatedDeployments>
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
Sourcepub async fn get_service_logs(
&self,
service_id: &str,
start: Option<&str>,
end: Option<&str>,
limit: Option<i32>,
) -> Result<GetLogsResponse>
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 fromend- Optional ISO timestamp to filter logs untillimit- Optional max number of log lines (default: 100)
Endpoint: GET /api/deployments/services/:serviceId/logs
Sourcepub async fn list_clusters_for_project(
&self,
project_id: &str,
) -> Result<Vec<ClusterEntity>>
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
Sourcepub async fn get_cluster(
&self,
cluster_id: &str,
) -> Result<Option<ClusterEntity>>
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
Sourcepub async fn list_registries_for_project(
&self,
project_id: &str,
) -> Result<Vec<ArtifactRegistry>>
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
Sourcepub async fn list_ready_registries_for_project(
&self,
project_id: &str,
) -> Result<Vec<ArtifactRegistry>>
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
Sourcepub async fn create_registry(
&self,
project_id: &str,
request: &CreateRegistryRequest,
) -> Result<CreateRegistryResponse>
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
Sourcepub async fn get_registry_task_status(
&self,
task_id: &str,
) -> Result<RegistryTaskStatus>
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
Sourcepub async fn check_connection(&self) -> Result<()>
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§
impl Freeze for PlatformApiClient
impl !RefUnwindSafe for PlatformApiClient
impl Send for PlatformApiClient
impl Sync for PlatformApiClient
impl Unpin for PlatformApiClient
impl !UnwindSafe for PlatformApiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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