Struct rivet_group::client::Client
source · [−]pub struct Client<C, M, R = Standard> { /* private fields */ }
Expand description
An ergonomic service client for GroupService
.
This client allows ergonomic access to a GroupService
-shaped service.
Each method corresponds to an endpoint defined in the service’s Smithy model,
and the request and response shapes are auto-generated from that same model.
Constructing a Client
To construct a client, you need a few different things:
- A
Config
that specifies additional configuration required by the service. - A connector (
C
) that specifies how HTTP requests are translated into HTTP responses. This will typically be an HTTP client (likehyper
), though you can also substitute in your own, like a mock mock connector for testing. - A “middleware” (
M
) that modifies requests prior to them being sent to the request. Most commonly, middleware will decide what endpoint the requests should be sent to, as well as perform authentication and authorization of requests (such as SigV4). You can also have middleware that performs request/response tracing, throttling, or other middleware-like tasks. - A retry policy (
R
) that dictates the behavior for requests that fail and should (potentially) be retried. The default type is generally what you want, as it implements a well-vetted retry policy implemented inRetryMode::Standard
.
To construct a client, you will generally want to call
Client::with_config
, which takes a aws_smithy_client::Client
(a
Smithy client that isn’t specialized to a particular service),
and a Config
. Both of these are constructed using
the builder pattern where you first construct a Builder
type,
then configure it with the necessary parameters, and then call
build
to construct the finalized output type. The
aws_smithy_client::Client
builder is re-exported in this crate as
Builder
for convenience.
In most circumstances, you will want to use the following pattern to construct a client:
use rivet_group::{Builder, Client, Config};
let raw_client =
Builder::dyn_https()
.middleware(/* discussed below */)
.build();
let config = Config::builder().build();
let client = Client::with_config(raw_client, config);
For the middleware, you’ll want to use whatever matches the routing, authentication and authorization required by the target service. For example, for the standard AWS SDK which uses SigV4-signed requests, the middleware looks like this:
use aws_endpoint::AwsEndpointStage;
use aws_http::auth::CredentialsStage;
use aws_http::recursion_detection::RecursionDetectionStage;
use aws_http::user_agent::UserAgentStage;
use aws_sig_auth::middleware::SigV4SigningStage;
use aws_sig_auth::signer::SigV4Signer;
use aws_smithy_client::retry::Config as RetryConfig;
use aws_smithy_http_tower::map_request::{AsyncMapRequestLayer, MapRequestLayer};
use std::fmt::Debug;
use tower::layer::util::{Identity, Stack};
use tower::ServiceBuilder;
type AwsMiddlewareStack = Stack<
MapRequestLayer<RecursionDetectionStage>,
Stack<
MapRequestLayer<SigV4SigningStage>,
Stack<
AsyncMapRequestLayer<CredentialsStage>,
Stack<
MapRequestLayer<UserAgentStage>,
Stack<MapRequestLayer<AwsEndpointStage>, Identity>,
>,
>,
>,
>;
/// AWS Middleware Stack
///
/// This implements the middleware stack for this service. It will:
/// 1. Load credentials asynchronously into the property bag
/// 2. Sign the request with SigV4
/// 3. Resolve an Endpoint for the request
/// 4. Add a user agent to the request
#[derive(Debug, Default, Clone)]
#[non_exhaustive]
pub struct AwsMiddleware;
impl AwsMiddleware {
/// Create a new `AwsMiddleware` stack
///
/// Note: `AwsMiddleware` holds no state.
pub fn new() -> Self {
AwsMiddleware::default()
}
}
// define the middleware stack in a non-generic location to reduce code bloat.
fn base() -> ServiceBuilder<AwsMiddlewareStack> {
let credential_provider = AsyncMapRequestLayer::for_mapper(CredentialsStage::new());
let signer = MapRequestLayer::for_mapper(SigV4SigningStage::new(SigV4Signer::new()));
let endpoint_resolver = MapRequestLayer::for_mapper(AwsEndpointStage);
let user_agent = MapRequestLayer::for_mapper(UserAgentStage::new());
let recursion_detection = MapRequestLayer::for_mapper(RecursionDetectionStage::new());
// These layers can be considered as occurring in order, that is:
// 1. Resolve an endpoint
// 2. Add a user agent
// 3. Acquire credentials
// 4. Sign with credentials
// (5. Dispatch over the wire)
ServiceBuilder::new()
.layer(endpoint_resolver)
.layer(user_agent)
.layer(credential_provider)
.layer(signer)
.layer(recursion_detection)
}
impl<S> tower::Layer<S> for AwsMiddleware {
type Service = <AwsMiddlewareStack as tower::Layer<S>>::Service;
fn layer(&self, inner: S) -> Self::Service {
base().service(inner)
}
}
Using a Client
Once you have a client set up, you can access the service’s endpoints
by calling the appropriate method on Client
. Each such method
returns a request builder for that endpoint, with methods for setting
the various fields of the request. Once your request is complete, use
the send
method to send the request. send
returns a future, which
you then have to .await
to get the service’s response.
Implementations
sourceimpl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C>,
R: NewRequestPolicy,
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C>,
R: NewRequestPolicy,
sourcepub fn complete_group_avatar_upload(&self) -> CompleteGroupAvatarUpload<C, M, R>
pub fn complete_group_avatar_upload(&self) -> CompleteGroupAvatarUpload<C, M, R>
Constructs a fluent builder for the CompleteGroupAvatarUpload
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.upload_id(impl Into<String>)
/set_upload_id(Option<String>)
: A universally unique identifier.
- On success, responds with
CompleteGroupAvatarUploadOutput
- On failure, responds with
SdkError<CompleteGroupAvatarUploadError>
sourcepub fn consume_group_invite(&self) -> ConsumeGroupInvite<C, M, R>
pub fn consume_group_invite(&self) -> ConsumeGroupInvite<C, M, R>
Constructs a fluent builder for the ConsumeGroupInvite
operation.
- The fluent builder is configurable:
group_invite_code(impl Into<String>)
/set_group_invite_code(Option<String>)
: Provided byrivet.api.group#CreateGroupInviteOutput$code
.
- On success, responds with
ConsumeGroupInviteOutput
with field(s):error(Option<GroupInviteErrorCode>)
: Denotes the status of a group invite code when consuming.group_id(Option<String>)
: A universally unique identifier.
- On failure, responds with
SdkError<ConsumeGroupInviteError>
sourcepub fn create_group(&self) -> CreateGroup<C, M, R>
pub fn create_group(&self) -> CreateGroup<C, M, R>
Constructs a fluent builder for the CreateGroup
operation.
- The fluent builder is configurable:
display_name(impl Into<String>)
/set_display_name(Option<String>)
: Represent a resource’s readable display name.
- On success, responds with
CreateGroupOutput
with field(s):group_id(Option<String>)
: A universally unique identifier.
- On failure, responds with
SdkError<CreateGroupError>
sourcepub fn create_group_invite(&self) -> CreateGroupInvite<C, M, R>
pub fn create_group_invite(&self) -> CreateGroupInvite<C, M, R>
Constructs a fluent builder for the CreateGroupInvite
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.ttl(i64)
/set_ttl(Option<i64>)
: How long until the group invite expires (in milliseconds).use_count(i64)
/set_use_count(Option<i64>)
: How many times the group invite can be used.
- On success, responds with
CreateGroupInviteOutput
with field(s):code(Option<String>)
: The code that will be passed torivet.api.group#ConsumeGroupInvite
to join a group.
- On failure, responds with
SdkError<CreateGroupInviteError>
sourcepub fn create_group_join_request(&self) -> CreateGroupJoinRequest<C, M, R>
pub fn create_group_join_request(&self) -> CreateGroupJoinRequest<C, M, R>
Constructs a fluent builder for the CreateGroupJoinRequest
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.
- On success, responds with
CreateGroupJoinRequestOutput
- On failure, responds with
SdkError<CreateGroupJoinRequestError>
sourcepub fn get_group_profile(&self) -> GetGroupProfile<C, M, R>
pub fn get_group_profile(&self) -> GetGroupProfile<C, M, R>
Constructs a fluent builder for the GetGroupProfile
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.watch_index(impl Into<String>)
/set_watch_index(Option<String>)
: A query parameter denoting the requests watch index.
- On success, responds with
GetGroupProfileOutput
with field(s):group(Option<GroupProfile>)
: A list of group profiles.watch(Option<WatchResponse>)
: Provided by watchable endpoints used in blocking loops.
- On failure, responds with
SdkError<GetGroupProfileError>
sourcepub fn get_group_summary(&self) -> GetGroupSummary<C, M, R>
pub fn get_group_summary(&self) -> GetGroupSummary<C, M, R>
Constructs a fluent builder for the GetGroupSummary
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.
- On success, responds with
GetGroupSummaryOutput
with field(s):group(Option<GroupSummary>)
: A group summary.
- On failure, responds with
SdkError<GetGroupSummaryError>
sourcepub fn join_group(&self) -> JoinGroup<C, M, R>
pub fn join_group(&self) -> JoinGroup<C, M, R>
Constructs a fluent builder for the JoinGroup
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.
- On success, responds with
JoinGroupOutput
- On failure, responds with
SdkError<JoinGroupError>
sourcepub fn leave_group(&self) -> LeaveGroup<C, M, R>
pub fn leave_group(&self) -> LeaveGroup<C, M, R>
Constructs a fluent builder for the LeaveGroup
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.
- On success, responds with
LeaveGroupOutput
- On failure, responds with
SdkError<LeaveGroupError>
sourcepub fn list_suggested_groups(&self) -> ListSuggestedGroups<C, M, R>
pub fn list_suggested_groups(&self) -> ListSuggestedGroups<C, M, R>
Constructs a fluent builder for the ListSuggestedGroups
operation.
- The fluent builder is configurable:
watch_index(impl Into<String>)
/set_watch_index(Option<String>)
: A query parameter denoting the requests watch index.
- On success, responds with
ListSuggestedGroupsOutput
with field(s):groups(Option<Vec<GroupSummary>>)
: A list of group summaries.watch(Option<WatchResponse>)
: Provided by watchable endpoints used in blocking loops.
- On failure, responds with
SdkError<ListSuggestedGroupsError>
sourcepub fn prepare_group_avatar_upload(&self) -> PrepareGroupAvatarUpload<C, M, R>
pub fn prepare_group_avatar_upload(&self) -> PrepareGroupAvatarUpload<C, M, R>
Constructs a fluent builder for the PrepareGroupAvatarUpload
operation.
- The fluent builder is configurable:
path(impl Into<String>)
/set_path(Option<String>)
: The path/filename of the group avatar.mime(impl Into<String>)
/set_mime(Option<String>)
: The MIME type of the group avatar.content_length(i64)
/set_content_length(Option<i64>)
: Unsigned 64 bit integer.
- On success, responds with
PrepareGroupAvatarUploadOutput
with field(s):upload_id(Option<String>)
: A universally unique identifier.presigned_request(Option<UploadPresignedRequest>)
: A presigned request used to upload files. Upload your file to the given URL via a PUT request.
- On failure, responds with
SdkError<PrepareGroupAvatarUploadError>
sourcepub fn resolve_group_join_request(&self) -> ResolveGroupJoinRequest<C, M, R>
pub fn resolve_group_join_request(&self) -> ResolveGroupJoinRequest<C, M, R>
Constructs a fluent builder for the ResolveGroupJoinRequest
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.resolution(bool)
/set_resolution(Option<bool>)
: (undocumented)
- On success, responds with
ResolveGroupJoinRequestOutput
- On failure, responds with
SdkError<ResolveGroupJoinRequestError>
sourcepub fn search_groups(&self) -> SearchGroups<C, M, R>
pub fn search_groups(&self) -> SearchGroups<C, M, R>
Constructs a fluent builder for the SearchGroups
operation.
- The fluent builder is configurable:
query(impl Into<String>)
/set_query(Option<String>)
: The query to match group display names against.anchor(impl Into<String>)
/set_anchor(Option<String>)
: How many groups to offset the search by.limit(i32)
/set_limit(Option<i32>)
: Amount of groups to return.
- On success, responds with
SearchGroupsOutput
with field(s):groups(Option<Vec<GroupHandle>>)
: A list of group handles.
- On failure, responds with
SdkError<SearchGroupsError>
sourcepub fn transfer_group_ownership(&self) -> TransferGroupOwnership<C, M, R>
pub fn transfer_group_ownership(&self) -> TransferGroupOwnership<C, M, R>
Constructs a fluent builder for the TransferGroupOwnership
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.new_owner_identity_id(impl Into<String>)
/set_new_owner_identity_id(Option<String>)
: Idnetity to transfer the group to. Must be a member of the group.
- On success, responds with
TransferGroupOwnershipOutput
- On failure, responds with
SdkError<TransferGroupOwnershipError>
sourcepub fn update_group_profile(&self) -> UpdateGroupProfile<C, M, R>
pub fn update_group_profile(&self) -> UpdateGroupProfile<C, M, R>
Constructs a fluent builder for the UpdateGroupProfile
operation.
- The fluent builder is configurable:
group_id(impl Into<String>)
/set_group_id(Option<String>)
: A universally unique identifier.display_name(impl Into<String>)
/set_display_name(Option<String>)
: Represent a resource’s readable display name.bio(impl Into<String>)
/set_bio(Option<String>)
: Detailed information about a profile.publicity(GroupPublicity)
/set_publicity(Option<GroupPublicity>)
: The current publicity value for the given group.
- On success, responds with
UpdateGroupProfileOutput
- On failure, responds with
SdkError<UpdateGroupProfileError>
sourcepub fn validate_group_profile(&self) -> ValidateGroupProfile<C, M, R>
pub fn validate_group_profile(&self) -> ValidateGroupProfile<C, M, R>
Constructs a fluent builder for the ValidateGroupProfile
operation.
- The fluent builder is configurable:
display_name(impl Into<String>)
/set_display_name(Option<String>)
: Represent a resource’s readable display name.bio(impl Into<String>)
/set_bio(Option<String>)
: Detailed information about a profile.publicity(GroupPublicity)
/set_publicity(Option<GroupPublicity>)
: The current publicity value for the given group.
- On success, responds with
ValidateGroupProfileOutput
with field(s):errors(Option<Vec<ValidationError>>)
: A list of validation errors.
- On failure, responds with
SdkError<ValidateGroupProfileError>
Trait Implementations
Auto Trait Implementations
impl<C, M, R = Standard> !RefUnwindSafe for Client<C, M, R>
impl<C, M, R> Send for Client<C, M, R> where
C: Send + Sync,
M: Send + Sync,
R: Send + Sync,
impl<C, M, R> Sync for Client<C, M, R> where
C: Send + Sync,
M: Send + Sync,
R: Send + Sync,
impl<C, M, R> Unpin for Client<C, M, R>
impl<C, M, R = Standard> !UnwindSafe for Client<C, M, R>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more