Struct SurgeSdk
Source pub struct SurgeSdk {
pub config: Config,
pub client: Client,
}
Expand description
SDK for interacting with the Surge API.
Encapsulates an HTTP client and configuration for managing domains, publishing projects,
and handling account operations.
Configuration settings for the SDK, including the API endpoint and timeout settings.
The HTTP client used for making API requests, configured with the provided settings.
Creates a new SurgeSdk
instance with the given configuration.
§Arguments
config
- Configuration settings for the SDK.
§Returns
A Result
containing the SurgeSdk
or a SurgeError
if the HTTP client cannot be built.
§Example
use surge_sdk::{Config,SurgeSdk};
let config = Config::new("https://api.surge.sh", "0.1.0").unwrap();
let sdk = SurgeSdk::new(config).unwrap();
Fetches account information.
§Arguments
auth
- Authentication credentials.
§Returns
A Result
containing an AccountResponse
or a SurgeError
.
Lists domains, optionally filtered by a specific domain.
§Arguments
domain
- Optional domain to filter the list.
auth
- Authentication credentials.
§Returns
A Result
containing a ListResponse
or a SurgeError
.
Deletes the account.
§Arguments
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Tears down a domain.
§Arguments
domain
- The domain to tear down.
auth
- Authentication credentials.
§Returns
A Result
containing TeardownResponse
if the operation was successful, or a SurgeError
.
Logs in to the API.
§Arguments
auth
- Authentication credentials.
§Returns
A Result
containing a LoginResponse
or a SurgeError
.
Publishes a project directory to a domain.
Delegates to stream::publish
for tarball creation and streaming.
§Arguments
project_path
- Path to the project directory.
domain
- Target domain for publishing.
auth
- Authentication credentials.
headers
- Optional custom HTTP headers.
argv
- Optional command-line arguments.
§Returns
A Result
containing a stream of Event
s or a SurgeError
.
Publishes a work-in-progress version of a project to a preview domain.
Delegates to stream::publish_wip
for tarball creation and streaming.
§Arguments
project_path
- Path to the project directory.
domain
- Target domain for the preview.
auth
- Authentication credentials.
headers
- Optional custom HTTP headers.
argv
- Optional command-line arguments.
§Returns
A Result
containing a stream of Event
s or a SurgeError
.
Rolls back a domain to a previous revision.
§Arguments
domain
- The domain to roll back.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Rolls forward a domain to a newer revision.
§Arguments
domain
- The domain to roll forward.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Switches a domain to a specific revision (or the latest if none specified).
§Arguments
domain
- The target domain.
revision
- Optional revision to switch to.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Discards a specific revision (or all revisions if none specified) for a domain.
§Arguments
domain
- The target domain.
revision
- Optional revision to discard.
auth
- Authentication credentials.
§Returns
A DiscardResponse
indicating success or a SurgeError
.
Fetches SSL certificate information for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a DCertsResponse
or a SurgeError
.
Fetches metadata for a domain or specific revision.
§Arguments
domain
- The target domain.
revision
- Optional revision to fetch metadata for.
auth
- Authentication credentials.
§Returns
A Result
containing a MetadataResponse
or a SurgeError
.
Fetches the manifest for a domain or specific revision.
§Arguments
domain
- The target domain.
revision
- Optional revision to fetch the manifest for.
auth
- Authentication credentials.
§Returns
A Result
containing a ManifestResponse
or a SurgeError
.
Fetches the file manifest for a domain (alias for manifest
with no revision).
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a serde_json::Value
or a SurgeError
.
Updates configuration settings for a domain.
§Arguments
domain
- The target domain.
settings
- JSON settings to apply.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Fetches DNS records for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a serde_json::Value
or a SurgeError
.
Adds a DNS record for a domain.
§Arguments
domain
- The target domain.
record
- JSON representation of the DNS record.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Removes a DNS record for a domain.
§Arguments
domain
- The target domain.
id
- The ID of the DNS record to remove.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Fetches zone information for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a serde_json::Value
or a SurgeError
.
Adds a zone record for a domain.
§Arguments
domain
- The target domain.
record
- JSON representation of the zone record.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Removes a zone record for a domain.
§Arguments
domain
- The target domain.
id
- The ID of the zone record to remove.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Clears the cache for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Fetches account statistics.
§Arguments
auth
- Authentication credentials.
§Returns
A Result
containing a serde_json::Value
or a SurgeError
.
Fetches analytics data for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a DAnalyticsResponse
or a SurgeError
.
Fetches usage data for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a DAnalyticsResponse
or a SurgeError
.
Fetches audit logs for a domain.
§Arguments
domain
- The target domain.
auth
- Authentication credentials.
§Returns
A Result
containing a DAuditResponse
or a SurgeError
.
Invites collaborators to a domain.
§Arguments
domain
- The target domain.
emails
- JSON array of email addresses to invite.
auth
- Authentication credentials.
§Returns
A bool
indicating success or a SurgeError
.
Revokes collaborator access for a domain.
§Arguments
domain
- The target domain.
emails
- JSON array of email addresses to revoke.
auth
- Authentication credentials.
§Returns
A bool
indicating success or a SurgeError
.
Updates the account plan.
§Arguments
plan
- JSON representation of the plan.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Updates the payment card for the account.
§Arguments
card
- JSON representation of the card details.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Fetches available plans, optionally for a specific domain.
§Arguments
domain
- Optional domain to filter plans.
auth
- Authentication credentials.
§Returns
A Result
containing a PlansResponse
or a SurgeError
.
Uploads an SSL certificate for a domain.
§Arguments
domain
- The target domain.
pem_path
- Path to the PEM certificate file.
auth
- Authentication credentials.
§Returns
A Result
indicating success or a SurgeError
.
Applies authentication to an HTTP request.
§Arguments
req
- The reqwest::RequestBuilder
to modify.
auth
- Authentication credentials (token or username/password).
§Returns
The modified RequestBuilder
with authentication headers.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Instruments this type with the provided
Span
, returning an
Instrumented
wrapper.
Read more
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer.
Read more
Mutably dereferences the given pointer.
Read more
Drops the object pointed to by the given pointer.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.