Skip to content

Commit

Permalink
fix(ds): update auth endpoints (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Aug 13, 2024
1 parent 387ee6b commit 11416c4
Show file tree
Hide file tree
Showing 184 changed files with 3,795 additions and 4,002 deletions.
9 changes: 9 additions & 0 deletions errors/builds/build-not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "BUILDS_BUILD_NOT_FOUND"
description = "Build not found."
http_status = 400
---

# Build Not Found

Build not found for given ID.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ imports:

service:
auth: true
base-path: /servers
base-path: /games/{game_id}/servers
path-parameters:
game_id: uuid
endpoints:
get:
path: /{server_id}
Expand Down Expand Up @@ -102,9 +104,7 @@ types:
type: commons.Server

DestroyServerResponse:
properties:
server_id:
type: uuid
properties: {}

ListServersResponse:
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
commons: ../common.yml
uploadCommons: ../upload/common.yml
cloudCommons: ../cloud/common.yml
commons: ../../common.yml
uploadCommons: ../../upload/common.yml
cloudCommons: ../../cloud/common.yml

service:
auth: true
base-path: /servers
base-path: /games/{game_id}/builds
path-parameters:
game_id: uuid
endpoints:
listBuilds:
path: /builds
path: ""
method: GET
docs: >-
Lists all builds of the game associated with the token used. Can be
Expand All @@ -23,19 +25,19 @@ service:
response: ListBuildsResponse

prepareBuild:
path: /builds
path: /prepare
method: POST
docs: Creates a new game build for the given game.
request:
body: CreateBuildRequest
response: CreateBuildResponse

completeBuild:
path: /uploads/{upload_id}/complete
path: /{build_id}/complete
method: POST
docs: Marks an upload as complete.
path-parameters:
upload_id:
build_id:
type: uuid

types:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
commons: ../common.yml
uploadCommons: ../upload/common.yml
cloudCommons: ../cloud/common.yml
commons: ../../common.yml

service:
auth: true
base-path: /servers
base-path: /games/{game_id}/servers
path-parameters:
game_id: uuid
endpoints:
getServerLogs:
path: /{server_id}/logs
Expand Down
88 changes: 45 additions & 43 deletions lib/convert/src/impls/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use rivet_operation::prelude::*;
use crate::{ApiFrom, ApiInto, ApiTryFrom, ApiTryInto};
use serde_json::{json, to_value};

impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
impl ApiTryFrom<backend::ds::Server> for models::GamesServersServer {
type Error = GlobalError;
fn api_try_from(value: backend::ds::Server) -> GlobalResult<models::ServersServer> {
Ok(models::ServersServer {
fn api_try_from(value: backend::ds::Server) -> GlobalResult<models::GamesServersServer> {
Ok(models::GamesServersServer {
cluster_id: unwrap!(value.cluster_id).as_uuid(),
create_ts: value.create_ts,
start_ts: value.start_ts,
Expand All @@ -24,7 +24,7 @@ impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
arguments: Some(value.args),
environment: Some(value.environment),
image_id: unwrap!(value.image_id).as_uuid(),
network: Box::new(models::ServersNetwork {
network: Box::new(models::GamesServersNetwork {
mode: Some(
unwrap!(backend::ds::NetworkMode::from_i32(value.network_mode)).api_into(),
),
Expand All @@ -38,46 +38,46 @@ impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
}
}

impl ApiFrom<models::ServersResources> for backend::ds::ServerResources {
fn api_from(value: models::ServersResources) -> backend::ds::ServerResources {
impl ApiFrom<models::GamesServersResources> for backend::ds::ServerResources {
fn api_from(value: models::GamesServersResources) -> backend::ds::ServerResources {
backend::ds::ServerResources {
cpu_millicores: value.cpu,
memory_mib: value.memory,
}
}
}

impl ApiFrom<backend::ds::ServerResources> for models::ServersResources {
fn api_from(value: backend::ds::ServerResources) -> models::ServersResources {
models::ServersResources {
impl ApiFrom<backend::ds::ServerResources> for models::GamesServersResources {
fn api_from(value: backend::ds::ServerResources) -> models::GamesServersResources {
models::GamesServersResources {
cpu: value.cpu_millicores,
memory: value.memory_mib,
}
}
}

impl ApiFrom<models::ServersNetworkMode> for backend::ds::NetworkMode {
fn api_from(value: models::ServersNetworkMode) -> backend::ds::NetworkMode {
impl ApiFrom<models::GamesServersNetworkMode> for backend::ds::NetworkMode {
fn api_from(value: models::GamesServersNetworkMode) -> backend::ds::NetworkMode {
match value {
models::ServersNetworkMode::Bridge => backend::ds::NetworkMode::Bridge,
models::ServersNetworkMode::Host => backend::ds::NetworkMode::Host,
models::GamesServersNetworkMode::Bridge => backend::ds::NetworkMode::Bridge,
models::GamesServersNetworkMode::Host => backend::ds::NetworkMode::Host,
}
}
}

impl ApiFrom<backend::ds::NetworkMode> for models::ServersNetworkMode {
fn api_from(value: backend::ds::NetworkMode) -> models::ServersNetworkMode {
impl ApiFrom<backend::ds::NetworkMode> for models::GamesServersNetworkMode {
fn api_from(value: backend::ds::NetworkMode) -> models::GamesServersNetworkMode {
match value {
backend::ds::NetworkMode::Bridge => models::ServersNetworkMode::Bridge,
backend::ds::NetworkMode::Host => models::ServersNetworkMode::Host,
backend::ds::NetworkMode::Bridge => models::GamesServersNetworkMode::Bridge,
backend::ds::NetworkMode::Host => models::GamesServersNetworkMode::Host,
}
}
}

impl ApiTryFrom<backend::ds::Port> for models::ServersPort {
impl ApiTryFrom<backend::ds::Port> for models::GamesServersPort {
type Error = GlobalError;

fn api_try_from(value: backend::ds::Port) -> GlobalResult<models::ServersPort> {
fn api_try_from(value: backend::ds::Port) -> GlobalResult<models::GamesServersPort> {
let protocol = match unwrap!(&value.routing) {
backend::ds::port::Routing::GameGuard(x) => {
unwrap!(backend::ds::GameGuardProtocol::from_i32(x.protocol)).api_into()
Expand All @@ -87,7 +87,7 @@ impl ApiTryFrom<backend::ds::Port> for models::ServersPort {
}
};

let routing = models::ServersPortRouting {
let routing = models::GamesServersPortRouting {
game_guard: if let Some(backend::ds::port::Routing::GameGuard(_)) = &value.routing {
Some(json!({}))
} else {
Expand All @@ -100,7 +100,7 @@ impl ApiTryFrom<backend::ds::Port> for models::ServersPort {
},
};

Ok(models::ServersPort {
Ok(models::GamesServersPort {
protocol,
internal_port: value.internal_port,
public_hostname: value.public_hostname,
Expand All @@ -110,46 +110,48 @@ impl ApiTryFrom<backend::ds::Port> for models::ServersPort {
}
}

impl ApiFrom<models::ServersPortProtocol> for backend::ds::GameGuardProtocol {
fn api_from(value: models::ServersPortProtocol) -> backend::ds::GameGuardProtocol {
impl ApiFrom<models::GamesServersPortProtocol> for backend::ds::GameGuardProtocol {
fn api_from(value: models::GamesServersPortProtocol) -> backend::ds::GameGuardProtocol {
match value {
models::ServersPortProtocol::Udp => backend::ds::GameGuardProtocol::Udp,
models::ServersPortProtocol::Tcp => backend::ds::GameGuardProtocol::Tcp,
models::ServersPortProtocol::Http => backend::ds::GameGuardProtocol::Http,
models::ServersPortProtocol::Https => backend::ds::GameGuardProtocol::Https,
models::ServersPortProtocol::TcpTls => backend::ds::GameGuardProtocol::TcpTls,
models::GamesServersPortProtocol::Udp => backend::ds::GameGuardProtocol::Udp,
models::GamesServersPortProtocol::Tcp => backend::ds::GameGuardProtocol::Tcp,
models::GamesServersPortProtocol::Http => backend::ds::GameGuardProtocol::Http,
models::GamesServersPortProtocol::Https => backend::ds::GameGuardProtocol::Https,
models::GamesServersPortProtocol::TcpTls => backend::ds::GameGuardProtocol::TcpTls,
}
}
}

impl ApiFrom<backend::ds::GameGuardProtocol> for models::ServersPortProtocol {
fn api_from(value: backend::ds::GameGuardProtocol) -> models::ServersPortProtocol {
impl ApiFrom<backend::ds::GameGuardProtocol> for models::GamesServersPortProtocol {
fn api_from(value: backend::ds::GameGuardProtocol) -> models::GamesServersPortProtocol {
match value {
backend::ds::GameGuardProtocol::Udp => models::ServersPortProtocol::Udp,
backend::ds::GameGuardProtocol::Tcp => models::ServersPortProtocol::Tcp,
backend::ds::GameGuardProtocol::Http => models::ServersPortProtocol::Http,
backend::ds::GameGuardProtocol::Https => models::ServersPortProtocol::Https,
backend::ds::GameGuardProtocol::TcpTls => models::ServersPortProtocol::TcpTls,
backend::ds::GameGuardProtocol::Udp => models::GamesServersPortProtocol::Udp,
backend::ds::GameGuardProtocol::Tcp => models::GamesServersPortProtocol::Tcp,
backend::ds::GameGuardProtocol::Http => models::GamesServersPortProtocol::Http,
backend::ds::GameGuardProtocol::Https => models::GamesServersPortProtocol::Https,
backend::ds::GameGuardProtocol::TcpTls => models::GamesServersPortProtocol::TcpTls,
}
}
}

impl ApiTryFrom<models::ServersPortProtocol> for backend::ds::HostProtocol {
impl ApiTryFrom<models::GamesServersPortProtocol> for backend::ds::HostProtocol {
type Error = GlobalError;
fn api_try_from(value: models::ServersPortProtocol) -> GlobalResult<backend::ds::HostProtocol> {
fn api_try_from(
value: models::GamesServersPortProtocol,
) -> GlobalResult<backend::ds::HostProtocol> {
Ok(match value {
models::ServersPortProtocol::Udp => backend::ds::HostProtocol::HostUdp,
models::ServersPortProtocol::Tcp => backend::ds::HostProtocol::HostTcp,
models::GamesServersPortProtocol::Udp => backend::ds::HostProtocol::HostUdp,
models::GamesServersPortProtocol::Tcp => backend::ds::HostProtocol::HostTcp,
_ => bail_with!(SERVERS_UNSUPPORTED_HOST_PROTOCOL),
})
}
}

impl ApiFrom<backend::ds::HostProtocol> for models::ServersPortProtocol {
fn api_from(value: backend::ds::HostProtocol) -> models::ServersPortProtocol {
impl ApiFrom<backend::ds::HostProtocol> for models::GamesServersPortProtocol {
fn api_from(value: backend::ds::HostProtocol) -> models::GamesServersPortProtocol {
match value {
backend::ds::HostProtocol::HostUdp => models::ServersPortProtocol::Udp,
backend::ds::HostProtocol::HostTcp => models::ServersPortProtocol::Tcp,
backend::ds::HostProtocol::HostUdp => models::GamesServersPortProtocol::Udp,
backend::ds::HostProtocol::HostTcp => models::GamesServersPortProtocol::Tcp,
}
}
}
2 changes: 1 addition & 1 deletion scripts/openapi/gen_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ docker run --rm \
if [ "$FERN_GROUP" == "full" ]; then
# Fix OpenAPI bug (https://github.com/OpenAPITools/openapi-generator/issues/14171)
sed -i 's/CloudGamesLogStream/crate::models::CloudGamesLogStream/' "$GEN_PATH_RUST/src/apis/cloud_games_matchmaker_api.rs"
sed -i 's/ServersLogStream/crate::models::ServersLogStream/' "$GEN_PATH_RUST/src/apis/servers_logs_api.rs"
sed -i 's/GamesServersLogStream/crate::models::GamesServersLogStream/' "$GEN_PATH_RUST/src/apis/games_servers_logs_api.rs"
sed -i 's/AdminClustersPoolType/crate::models::AdminClustersPoolType/' "$GEN_PATH_RUST/src/apis/admin_clusters_servers_api.rs"

# Create variant specifically for the CLI
Expand Down
6 changes: 3 additions & 3 deletions sdks/full/go/client/client.go

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

30 changes: 30 additions & 0 deletions sdks/full/go/games/client/client.go

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

File renamed without changes.
Loading

0 comments on commit 11416c4

Please sign in to comment.