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
Configthat 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§
Source§impl<C, M, R> Client<C, M, R>
impl<C, M, R> Client<C, M, R>
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
ConsumeGroupInviteOutputwith field(s):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
CreateGroupOutputwith 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
CreateGroupInviteOutputwith field(s):code(Option<String>): The code that will be passed torivet.api.group#ConsumeGroupInviteto 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_invite(&self) -> GetGroupInvite<C, M, R>
pub fn get_group_invite(&self) -> GetGroupInvite<C, M, R>
Constructs a fluent builder for the GetGroupInvite 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
GetGroupInviteOutputwith field(s):group(Option<GroupHandle>): A group handle.
- On failure, responds with
SdkError<GetGroupInviteError>
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
GetGroupProfileOutputwith 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
GetGroupSummaryOutputwith 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
ListSuggestedGroupsOutputwith 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
PrepareGroupAvatarUploadOutputwith 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
SearchGroupsOutputwith 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
ValidateGroupProfileOutputwith 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> Freeze for Client<C, M, R>
impl<C, M, R = Standard> !RefUnwindSafe for Client<C, M, R>
impl<C, M, R> Send for Client<C, M, R>
impl<C, M, R> Sync for Client<C, M, R>
impl<C, M, R> Unpin for Client<C, M, R>
impl<C, M, R = Standard> !UnwindSafe for Client<C, M, R>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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