Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions fern/definition/cloud/games/tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ service:
game_id:
type: uuid
response: CreateCloudTokenResponse
createServiceToken:
path: /games/{game_id}/tokens/service
method: POST
docs: Creates a new game service token.
path-parameters:
game_id:
type: uuid
response: CreateCloudTokenResponse

types:
CreateCloudTokenResponse:
Expand All @@ -30,9 +22,4 @@ types:
Slightly modified to include a description prefix and use Protobufs of
JSON.
type: string
CreateServiceTokenResponse:
properties:
token:
docs: |-
A JSON Web Token.
type: string

22 changes: 22 additions & 0 deletions fern/definition/games/environments/tokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

service:
auth: true
base-path: /games/{game_id}/environments/{environment_id}
path-parameters:
game_id: uuid
environment_id: uuid
endpoints:
createServiceToken:
path: /tokens/service
method: POST
docs: Creates a new environment service token.
response: CreateServiceTokenResponse

types:
CreateServiceTokenResponse:
properties:
token:
docs: |-
A JSON Web Token.
type: string
18 changes: 9 additions & 9 deletions fern/definition/servers/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ imports:

service:
auth: true
base-path: /games/{game_id}/servers
base-path: /games/{game_id}/environments/{environment_id}/servers
path-parameters:
game_id: uuid
environment_id: uuid
endpoints:
get:
path: /{server_id}
Expand Down Expand Up @@ -68,17 +69,16 @@ types:
properties:
datacenter: uuid
tags: unknown
runtime: CreateServerRuntimeRequest
network: CreateServerNetworkRequest
resources: commons.Resources
lifecycle: optional<commons.Lifecycle>

CreateServerRuntimeRequest:
properties:
image: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>
network: CreateServerNetworkRequest
resources: commons.Resources
kill_timeout:
docs: >-
The duration to wait for in milliseconds before killing the server.
This should be set to a safe default, and can be overridden during a
DELETE request if needed.
type: optional<long>

CreateServerNetworkRequest:
properties:
Expand Down
3 changes: 2 additions & 1 deletion fern/definition/servers/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ imports:

service:
auth: true
base-path: /games/{game_id}/builds
base-path: /games/{game_id}/environments/{environment_id}/builds
path-parameters:
game_id: uuid
environment_id: uuid
endpoints:
getBuild:
path: /{build_id}
Expand Down
20 changes: 14 additions & 6 deletions fern/definition/servers/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ types:
Server:
properties:
id: uuid
game: uuid
environment: uuid
datacenter: uuid
cluster: uuid
tags: unknown
runtime: Runtime
network: Network
resources: Resources
lifecycle: Lifecycle
created_at: long
started_at: optional<long>
destroyed_at: optional<long>

Runtime:
properties:
image: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>
network: Network
resources: Resources

Lifecycle:
properties:
kill_timeout:
docs: >-
The duration to wait for in milliseconds before killing the server.
This should be set to a safe default, and can be overridden during a
DELETE request if needed.
type: optional<long>
created_at: long
started_at: optional<long>
destroyed_at: optional<long>

Resources:
properties:
Expand Down
3 changes: 2 additions & 1 deletion fern/definition/servers/logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ imports:

service:
auth: true
base-path: /games/{game_id}/servers
base-path: /games/{game_id}/environments/{environment_id}/servers
path-parameters:
game_id: uuid
environment_id: uuid
endpoints:
getServerLogs:
path: /{server_id}/logs
Expand Down
24 changes: 12 additions & 12 deletions lib/claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,16 @@ pub mod ent {
}

#[derive(Clone, Debug)]
pub struct GameService {
pub game_id: Uuid,
pub struct EnvService {
pub env_id: Uuid,
}

impl TryFrom<&schema::entitlement::GameService> for GameService {
impl TryFrom<&schema::entitlement::EnvService> for EnvService {
type Error = GlobalError;

fn try_from(value: &schema::entitlement::GameService) -> GlobalResult<Self> {
Ok(GameService {
game_id: unwrap!(value.game_id).as_uuid(),
fn try_from(value: &schema::entitlement::EnvService) -> GlobalResult<Self> {
Ok(EnvService {
env_id: unwrap!(value.env_id).as_uuid(),
})
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ pub trait ClaimsDecode {
fn as_access_token(&self) -> GlobalResult<ent::AccessToken>;
fn as_provisioned_server(&self) -> GlobalResult<ent::ProvisionedServer>;
fn as_opengb_db(&self) -> GlobalResult<ent::OpenGbDb>;
fn as_game_service(&self) -> GlobalResult<ent::GameService>;
fn as_env_service(&self) -> GlobalResult<ent::EnvService>;
}

impl ClaimsDecode for schema::Claims {
Expand Down Expand Up @@ -702,18 +702,18 @@ impl ClaimsDecode for schema::Claims {
.and_then(std::convert::identity)
}

fn as_game_service(&self) -> GlobalResult<ent::GameService> {
fn as_env_service(&self) -> GlobalResult<ent::EnvService> {
self.entitlements
.iter()
.find_map(|ent| match &ent.kind {
Some(schema::entitlement::Kind::GameService(ent)) => {
Some(ent::GameService::try_from(ent))
Some(schema::entitlement::Kind::EnvService(ent)) => {
Some(ent::EnvService::try_from(ent))
}
_ => None,
})
.ok_or(err_code!(
CLAIMS_MISSING_ENTITLEMENT,
entitlements = "GameService"
entitlements = "EnvService"
))
.and_then(std::convert::identity)
}
Expand Down Expand Up @@ -745,7 +745,7 @@ impl EntitlementTag for schema::Entitlement {
schema::entitlement::Kind::AccessToken(_) => 16,
schema::entitlement::Kind::ProvisionedServer(_) => 17,
schema::entitlement::Kind::OpengbDb(_) => 18,
schema::entitlement::Kind::GameService(_) => 19,
schema::entitlement::Kind::EnvService(_) => 19,
})
}
}
Expand Down
18 changes: 11 additions & 7 deletions lib/convert/src/impls/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
fn api_try_from(value: backend::ds::Server) -> GlobalResult<models::ServersServer> {
Ok(models::ServersServer {
id: unwrap!(value.server_id).as_uuid(),
environment: unwrap!(value.env_id).as_uuid(),
datacenter: unwrap!(value.datacenter_id).as_uuid(),
cluster: unwrap!(value.cluster_id).as_uuid(),
created_at: value.create_ts,
started_at: value.start_ts,
datacenter: unwrap!(value.datacenter_id).as_uuid(),
destroyed_at: value.destroy_ts,
game: unwrap!(value.game_id).as_uuid(),
kill_timeout: Some(value.kill_timeout_ms),
tags: Some(to_value(value.tags).unwrap()),
resources: Box::new(unwrap!(value.resources).api_into()),
arguments: Some(value.args),
environment: Some(value.environment),
image: unwrap!(value.image_id).as_uuid(),
runtime: Box::new(models::ServersRuntime {
image: unwrap!(value.image_id).as_uuid(),
arguments: Some(value.args),
environment: Some(value.environment),
}),
network: Box::new(models::ServersNetwork {
mode: Some(
unwrap!(backend::ds::NetworkMode::from_i32(value.network_mode)).api_into(),
Expand All @@ -35,6 +35,10 @@ impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
.map(|(s, p)| Ok((s, p.api_try_into()?)))
.collect::<GlobalResult<HashMap<_, _>>>()?,
}),
lifecycle: Box::new(models::ServersLifecycle {
kill_timeout: Some(value.kill_timeout_ms),
}),
resources: Box::new(unwrap!(value.resources).api_into()),
})
}
}
Expand Down
1 change: 1 addition & 0 deletions proto/backend/build.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum BuildCompression {
message Build {
rivet.common.Uuid build_id = 1;
rivet.common.Uuid game_id = 2;
rivet.common.Uuid env_id = 10;
rivet.common.Uuid upload_id = 3;
string display_name = 4;
string image_tag = 6;
Expand Down
7 changes: 3 additions & 4 deletions proto/claims.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ message Entitlement {
string db_name = 2;
}

message GameService {
// The game ID that the server will be running.
rivet.common.Uuid game_id = 1;
message EnvService {
rivet.common.Uuid env_id = 1;
}

oneof kind {
Expand All @@ -142,7 +141,7 @@ message Entitlement {
AccessToken access_token = 16;
ProvisionedServer provisioned_server = 17;
OpenGbDb opengb_db = 18;
GameService game_service = 19;
EnvService env_service = 19;
}

reserved 13;
Expand Down
3 changes: 3 additions & 0 deletions sdks/full/go/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 0 additions & 78 deletions sdks/full/go/cloud/games/tokens/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading