Skip to content

Commit a60ae17

Browse files
committed
feat: add RenameServer
1 parent 7b926e8 commit a60ae17

File tree

7 files changed

+60
-2
lines changed

7 files changed

+60
-2
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,14 @@ client.v1
9696
.then((response) => {
9797
console.log("ClaimServer Response:", response);
9898
});
99+
100+
client.v1
101+
.RenameServer({
102+
data: {
103+
serverName: "Shinigami-PC localhost",
104+
},
105+
})
106+
.then(() => {
107+
// response will be an empty string if valid
108+
});
99109
```

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ export type {
3535
VerifyAuthenticationTokenRequest,
3636
VerifyAuthenticationTokenResponse,
3737
WrongPasswordErrorResponse,
38+
RenameServerRequest,
39+
RenameServerResponse,
40+
ServerClaimedErrorResponse,
3841
} from "./v1/index.js";

src/v1/ClaimServer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export type ClaimServerRequest = ApiRequest<
55
"ClaimServer",
66
{
77
/**
8-
* New name of the Dedicated Server.
8+
* New name of the Dedicated Server.
99
*/
1010
serverName: string;
1111
/**
12-
* Admin Password to set on the Dedicated Server, in plaintext.
12+
* Admin Password to set on the Dedicated Server, in plaintext.
1313
*/
1414
adminPassword: string;
1515
}

src/v1/RenameServer.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { ApiRequest } from "./common.js";
2+
import { buildApiRequest } from "./common.js";
3+
4+
export type RenameServerRequest = ApiRequest<
5+
"RenameServer",
6+
{
7+
/**
8+
* New name of the Dedicated Server.
9+
*/
10+
serverName: string;
11+
}
12+
>;
13+
14+
export type RenameServerResponse = string;
15+
16+
export const buildRenameServer = buildApiRequest<
17+
RenameServerRequest,
18+
RenameServerResponse
19+
>("v1", {
20+
function: "RenameServer",
21+
});

src/v1/error.ts

+4
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ export interface WrongPasswordErrorResponse extends ErrorResponse {
3636
export interface ServerClaimedErrorResponse extends ErrorResponse {
3737
errorCode: "server_claimed";
3838
}
39+
40+
export interface ServerNotClaimedErrorResponse extends ErrorResponse {
41+
errorCode: "server_not_claimed";
42+
}

src/v1/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { buildHealthCheck } from "./HealthCheck.js";
77
import { buildPasswordlessLogin } from "./PasswordlessLogin.js";
88
import { buildPasswordLogin } from "./PasswordLogin.js";
99
import { buildQueryServerState } from "./QueryServerState.js";
10+
import { buildRenameServer } from "./RenameServer.js";
1011
import { buildVerifyAuthenticationToken } from "./VerifyAuthenticationToken.js";
1112

1213
export function buildV1(options: InternalClientOptions) {
@@ -65,6 +66,14 @@ export function buildV1(options: InternalClientOptions) {
6566
* The client should drop InitialAdmin privileges after that and use returned AuthenticationToken instead, and update it's cached server game state by calling QueryServerState.
6667
*/
6768
ClaimServer: buildClaimServer(options),
69+
/**
70+
* Renames the Dedicated Server once it has been claimed.
71+
*
72+
* Requires Admin privileges.
73+
*
74+
* Function does not return any data on success.
75+
*/
76+
RenameServer: buildRenameServer(options),
6877
};
6978
}
7079

@@ -78,4 +87,5 @@ export type * from "./HealthCheck.js";
7887
export type * from "./PasswordlessLogin.js";
7988
export type * from "./PasswordLogin.js";
8089
export type * from "./QueryServerState.js";
90+
export type * from "./RenameServer.js";
8191
export type * from "./VerifyAuthenticationToken.js";

test.js

+10
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ client.v1
7777
.then((response) => {
7878
console.log("ClaimServer Response:", response);
7979
});
80+
81+
client.v1
82+
.RenameServer({
83+
data: {
84+
serverName: "Shinigami-PC localhost",
85+
},
86+
})
87+
.then((response) => {
88+
console.log("RenameServer Response:", typeof response);
89+
});

0 commit comments

Comments
 (0)