Struct rivet_identity::client::Client
source · [−]pub struct Client<C, M, R = Standard> { /* private fields */ }
Expand description
An ergonomic service client for IdentityService
.
This client allows ergonomic access to a IdentityService
-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_identity::{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_game_link(&self) -> CompleteGameLink<C, M, R>
pub fn complete_game_link(&self) -> CompleteGameLink<C, M, R>
Constructs a fluent builder for the CompleteGameLink
operation.
- The fluent builder is configurable:
identity_link_token(impl Into<String>)
/set_identity_link_token(Option<String>)
: A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
- On success, responds with
CompleteGameLinkOutput
with field(s):valid(Option<bool>)
: (undocumented)
- On failure, responds with
SdkError<CompleteGameLinkError>
sourcepub fn complete_identity_avatar_upload(
&self
) -> CompleteIdentityAvatarUpload<C, M, R>
pub fn complete_identity_avatar_upload(
&self
) -> CompleteIdentityAvatarUpload<C, M, R>
Constructs a fluent builder for the CompleteIdentityAvatarUpload
operation.
- The fluent builder is configurable:
upload_id(impl Into<String>)
/set_upload_id(Option<String>)
: A universally unique identifier.
- On success, responds with
CompleteIdentityAvatarUploadOutput
- On failure, responds with
SdkError<CompleteIdentityAvatarUploadError>
sourcepub fn follow_identity(&self) -> FollowIdentity<C, M, R>
pub fn follow_identity(&self) -> FollowIdentity<C, M, R>
Constructs a fluent builder for the FollowIdentity
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.
- On success, responds with
FollowIdentityOutput
- On failure, responds with
SdkError<FollowIdentityError>
sourcepub fn get_game_link(&self) -> GetGameLink<C, M, R>
pub fn get_game_link(&self) -> GetGameLink<C, M, R>
Constructs a fluent builder for the GetGameLink
operation.
- The fluent builder is configurable:
identity_link_token(impl Into<String>)
/set_identity_link_token(Option<String>)
:identity_link_token
returned byPrepareGameLink
.
- On success, responds with
GetGameLinkOutput
with field(s):status(Option<GameLinkStatus>)
: The link status between an identity and a game user.game(Option<GameHandle>)
: A game handle.
- On failure, responds with
SdkError<GetGameLinkError>
sourcepub fn get_identity_profile(&self) -> GetIdentityProfile<C, M, R>
pub fn get_identity_profile(&self) -> GetIdentityProfile<C, M, R>
Constructs a fluent builder for the GetIdentityProfile
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_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
GetIdentityProfileOutput
with field(s):identity(Option<IdentityProfile>)
: An identity profile.watch(Option<WatchResponse>)
: Provided by watchable endpoints used in blocking loops.
- On failure, responds with
SdkError<GetIdentityProfileError>
sourcepub fn get_identity_self_profile(&self) -> GetIdentitySelfProfile<C, M, R>
pub fn get_identity_self_profile(&self) -> GetIdentitySelfProfile<C, M, R>
Constructs a fluent builder for the GetIdentitySelfProfile
operation.
- The fluent builder takes no input, just
send
it. - On success, responds with
GetIdentitySelfProfileOutput
with field(s):identity(Option<IdentityProfile>)
: An identity profile.
- On failure, responds with
SdkError<GetIdentitySelfProfileError>
sourcepub fn list_activities(&self) -> ListActivities<C, M, R>
pub fn list_activities(&self) -> ListActivities<C, M, R>
Constructs a fluent builder for the ListActivities
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
ListActivitiesOutput
with field(s):identities(Option<Vec<IdentityHandle>>)
: A list of identity handles.watch(Option<WatchResponse>)
: Provided by watchable endpoints used in blocking loops.
- On failure, responds with
SdkError<ListActivitiesError>
sourcepub fn list_followers(&self) -> ListFollowers<C, M, R>
pub fn list_followers(&self) -> ListFollowers<C, M, R>
Constructs a fluent builder for the ListFollowers
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.anchor(impl Into<String>)
/set_anchor(Option<String>)
: (undocumented)limit(i32)
/set_limit(Option<i32>)
: Unsigned 32 bit integer.
- On success, responds with
ListFollowersOutput
with field(s):identities(Option<Vec<IdentityHandle>>)
: A list of identity handles.anchor(Option<String>)
: (undocumented)
- On failure, responds with
SdkError<ListFollowersError>
sourcepub fn list_following(&self) -> ListFollowing<C, M, R>
pub fn list_following(&self) -> ListFollowing<C, M, R>
Constructs a fluent builder for the ListFollowing
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.anchor(impl Into<String>)
/set_anchor(Option<String>)
: (undocumented)limit(i32)
/set_limit(Option<i32>)
: Unsigned 32 bit integer.
- On success, responds with
ListFollowingOutput
with field(s):identities(Option<Vec<IdentityHandle>>)
: A list of identity handles.anchor(Option<String>)
: (undocumented)
- On failure, responds with
SdkError<ListFollowingError>
sourcepub fn list_friends(&self) -> ListFriends<C, M, R>
pub fn list_friends(&self) -> ListFriends<C, M, R>
Constructs a fluent builder for the ListFriends
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.anchor(impl Into<String>)
/set_anchor(Option<String>)
: (undocumented)limit(i32)
/set_limit(Option<i32>)
: Unsigned 32 bit integer.
- On success, responds with
ListFriendsOutput
with field(s):identities(Option<Vec<IdentityHandle>>)
: A list of identity handles.anchor(Option<String>)
: (undocumented)
- On failure, responds with
SdkError<ListFriendsError>
sourcepub fn prepare_game_link(&self) -> PrepareGameLink<C, M, R>
pub fn prepare_game_link(&self) -> PrepareGameLink<C, M, R>
Constructs a fluent builder for the PrepareGameLink
operation.
- The fluent builder takes no input, just
send
it. - On success, responds with
PrepareGameLinkOutput
with field(s):identity_link_token(Option<String>)
: Pass this torivet.api.identity#GetGameLink
to get the linking status. Valid for 15 minutes.identity_link_url(Option<String>)
: The URL that the user should visit to link their Rivet account.expire_ts(Option<DateTime>)
: Timestamp (in milliseconds) at which the link will expire.
- On failure, responds with
SdkError<PrepareGameLinkError>
sourcepub fn prepare_identity_avatar_upload(
&self
) -> PrepareIdentityAvatarUpload<C, M, R>
pub fn prepare_identity_avatar_upload(
&self
) -> PrepareIdentityAvatarUpload<C, M, R>
Constructs a fluent builder for the PrepareIdentityAvatarUpload
operation.
- The fluent builder is configurable:
path(impl Into<String>)
/set_path(Option<String>)
: The path/filename of the identity avatar.mime(impl Into<String>)
/set_mime(Option<String>)
: The MIME type of the identity avatar.content_length(i64)
/set_content_length(Option<i64>)
: Unsigned 64 bit integer.
- On success, responds with
PrepareIdentityAvatarUploadOutput
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<PrepareIdentityAvatarUploadError>
sourcepub fn remove_identity_game_activity(
&self
) -> RemoveIdentityGameActivity<C, M, R>
pub fn remove_identity_game_activity(
&self
) -> RemoveIdentityGameActivity<C, M, R>
Constructs a fluent builder for the RemoveIdentityGameActivity
operation.
- The fluent builder takes no input, just
send
it. - On success, responds with
RemoveIdentityGameActivityOutput
- On failure, responds with
SdkError<RemoveIdentityGameActivityError>
sourcepub fn search_identities(&self) -> SearchIdentities<C, M, R>
pub fn search_identities(&self) -> SearchIdentities<C, M, R>
Constructs a fluent builder for the SearchIdentities
operation.
- The fluent builder is configurable:
query(impl Into<String>)
/set_query(Option<String>)
: The query to match identity display names and account numbers against.anchor(impl Into<String>)
/set_anchor(Option<String>)
: How many identities to offset the search by.limit(i32)
/set_limit(Option<i32>)
: Amount of identities to return.
- On success, responds with
SearchIdentitiesOutput
with field(s):identities(Option<Vec<IdentityHandle>>)
: A list of identity handles.anchor(Option<String>)
: The pagination anchor.
- On failure, responds with
SdkError<SearchIdentitiesError>
sourcepub fn set_identity_game_activity(&self) -> SetIdentityGameActivity<C, M, R>
pub fn set_identity_game_activity(&self) -> SetIdentityGameActivity<C, M, R>
Constructs a fluent builder for the SetIdentityGameActivity
operation.
- The fluent builder is configurable:
game_activity(UpdateIdentityGameActivity)
/set_game_activity(Option<UpdateIdentityGameActivity>)
: Information about the identity’s current game. This is information that all other identities can see about what the current identity is doing.
- On success, responds with
SetIdentityGameActivityOutput
- On failure, responds with
SdkError<SetIdentityGameActivityError>
sourcepub fn setup_identity(&self) -> SetupIdentity<C, M, R>
pub fn setup_identity(&self) -> SetupIdentity<C, M, R>
Constructs a fluent builder for the SetupIdentity
operation.
- The fluent builder is configurable:
existing_identity_token(impl Into<String>)
/set_existing_identity_token(Option<String>)
: Token returned from previous call torivet.api.identity#SetupIdentity
. If this token is invalid, a new identity will be returned.
- On success, responds with
SetupIdentityOutput
with field(s):identity_token(Option<String>)
: Token used to authenticate the identity. Should be stored somewhere permanent. Pass this torivet.api.identity#SetupIdentity$existing_identity_token
next timerivet.api.identity#SetupIdentity
is called. Token has a 90 day TTL. This means that ifrivet.api.identity#SetupIdentity
is not called again within 90 days, the token will no longer be valid. If this happens, the user can recover their account through the linking process (seerivet.api.identity#PrepareGameLink
). This token should be stored locally and never sent to a server or another device. If this token is comprimised, anyone with access to this token has control of the identity.identity_token_expire_ts(Option<DateTime>)
: Timestamp (in milliseconds) at which the token expires.identity(Option<IdentityProfile>)
: Information about the identity that was just authenticated.
- On failure, responds with
SdkError<SetupIdentityError>
sourcepub fn signup_for_beta(&self) -> SignupForBeta<C, M, R>
pub fn signup_for_beta(&self) -> SignupForBeta<C, M, R>
Constructs a fluent builder for the SignupForBeta
operation.
- The fluent builder is configurable:
name(impl Into<String>)
/set_name(Option<String>)
: (undocumented)company_name(impl Into<String>)
/set_company_name(Option<String>)
: (undocumented)company_size(impl Into<String>)
/set_company_size(Option<String>)
: (undocumented)preferred_tools(impl Into<String>)
/set_preferred_tools(Option<String>)
: (undocumented)goals(impl Into<String>)
/set_goals(Option<String>)
: (undocumented)
- On success, responds with
SignupForBetaOutput
- On failure, responds with
SdkError<SignupForBetaError>
sourcepub fn unfollow_identity(&self) -> UnfollowIdentity<C, M, R>
pub fn unfollow_identity(&self) -> UnfollowIdentity<C, M, R>
Constructs a fluent builder for the UnfollowIdentity
operation.
- The fluent builder is configurable:
identity_id(impl Into<String>)
/set_identity_id(Option<String>)
: A universally unique identifier.
- On success, responds with
UnfollowIdentityOutput
- On failure, responds with
SdkError<UnfollowIdentityError>
sourcepub fn update_identity_profile(&self) -> UpdateIdentityProfile<C, M, R>
pub fn update_identity_profile(&self) -> UpdateIdentityProfile<C, M, R>
Constructs a fluent builder for the UpdateIdentityProfile
operation.
- The fluent builder is configurable:
display_name(impl Into<String>)
/set_display_name(Option<String>)
: Represent a resource’s readable display name.account_number(i32)
/set_account_number(Option<i32>)
: Identity profile account number (#1234). These are assigned in addition to an identity’s display name in order to allow multiple identities to have the same display name while still providing a unique handle. These are unique to each display name; you can have multiple accounts with different display names and the same account number.bio(impl Into<String>)
/set_bio(Option<String>)
: Detailed information about a profile.
- On success, responds with
UpdateIdentityProfileOutput
- On failure, responds with
SdkError<UpdateIdentityProfileError>
sourcepub fn update_identity_status(&self) -> UpdateIdentityStatus<C, M, R>
pub fn update_identity_status(&self) -> UpdateIdentityStatus<C, M, R>
Constructs a fluent builder for the UpdateIdentityStatus
operation.
- The fluent builder is configurable:
status(IdentityStatus)
/set_status(Option<IdentityStatus>)
: The current status of an identity. This helps players understand if another player is currently playing or has their game in the background.
- On success, responds with
UpdateIdentityStatusOutput
- On failure, responds with
SdkError<UpdateIdentityStatusError>
sourcepub fn validate_identity_profile(&self) -> ValidateIdentityProfile<C, M, R>
pub fn validate_identity_profile(&self) -> ValidateIdentityProfile<C, M, R>
Constructs a fluent builder for the ValidateIdentityProfile
operation.
- The fluent builder is configurable:
display_name(impl Into<String>)
/set_display_name(Option<String>)
: Represent a resource’s readable display name.account_number(i32)
/set_account_number(Option<i32>)
: Identity profile account number (#1234). These are assigned in addition to an identity’s display name in order to allow multiple identities to have the same display name while still providing a unique handle. These are unique to each display name; you can have multiple accounts with different display names and the same account number.bio(impl Into<String>)
/set_bio(Option<String>)
: Detailed information about a profile.
- On success, responds with
ValidateIdentityProfileOutput
with field(s):errors(Option<Vec<ValidationError>>)
: A list of validation errors.
- On failure, responds with
SdkError<ValidateIdentityProfileError>
sourcepub fn watch_events(&self) -> WatchEvents<C, M, R>
pub fn watch_events(&self) -> WatchEvents<C, M, R>
Constructs a fluent builder for the WatchEvents
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
WatchEventsOutput
with field(s):events(Option<Vec<GlobalEvent>>)
: A list of global events. Ordered old to new.watch(Option<WatchResponse>)
: Provided by watchable endpoints used in blocking loops.
- On failure, responds with
SdkError<WatchEventsError>
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