fix(client): update request handling and typings for current smartrequest and OpenAPI output
This commit is contained in:
+12
-6
@@ -1,14 +1,20 @@
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
import * as hetznerOpenapiSpec from './openapi.spec.js';
|
||||
|
||||
type TJsonRequestBody<TPathMethod> = TPathMethod extends { requestBody?: infer TRequestBody }
|
||||
? NonNullable<TRequestBody> extends { content: { 'application/json': infer TJsonBody } }
|
||||
? TJsonBody
|
||||
: never
|
||||
: never;
|
||||
|
||||
// datacenters
|
||||
export type TDatacenters = hetznerOpenapiSpec.paths['/datacenters']['get']['responses']['200']['content']['application/json'];
|
||||
|
||||
// servers
|
||||
export type IServer = hetznerOpenapiSpec.paths['/servers/{id}']['get']['responses']['200']['content']['application/json']['server'];
|
||||
export type IServer = NonNullable<hetznerOpenapiSpec.paths['/servers/{id}']['get']['responses']['200']['content']['application/json']['server']>;
|
||||
export type TServersGetRequestBody = {};
|
||||
export type TServersGetResponseBody = hetznerOpenapiSpec.paths['/servers']['get']['responses']['200']['content']['application/json'];
|
||||
export type TServerCreateRequestBody = hetznerOpenapiSpec.paths['/servers']['post']['requestBody']['content']['application/json'];
|
||||
export type TServerCreateRequestBody = TJsonRequestBody<hetznerOpenapiSpec.paths['/servers']['post']>;
|
||||
export type TServerCreateResponseBody = hetznerOpenapiSpec.paths['/servers']['post']['responses']['201']['content']['application/json'];
|
||||
export type TServerDeleteRequestBody = hetznerOpenapiSpec.paths['/servers/{id}']['delete'];
|
||||
|
||||
@@ -44,17 +50,17 @@ export type THetznerCloudServerName =
|
||||
export type THetznerCloudLocationName = 'fsn1' | 'nbg1' | 'hel1' | 'ash' | 'hil';
|
||||
|
||||
// volumes
|
||||
export type IVolume = hetznerOpenapiSpec.paths['/volumes/{id}']['get']['responses']['200']['content']['application/json']['volume'];
|
||||
export type IVolume = NonNullable<hetznerOpenapiSpec.paths['/volumes/{id}']['get']['responses']['200']['content']['application/json']['volume']>;
|
||||
export type TVolumeGetRequestBody = {};
|
||||
export type TVolumeGetResponseBody = hetznerOpenapiSpec.paths['/volumes']['get']['responses']['200']['content']['application/json'];
|
||||
export type TVolumeCreateRequestBody = hetznerOpenapiSpec.paths['/volumes']['post']['requestBody']['content']['application/json'];
|
||||
export type TVolumeCreateRequestBody = TJsonRequestBody<hetznerOpenapiSpec.paths['/volumes']['post']>;
|
||||
export type TVolumeCreateResponseBody = hetznerOpenapiSpec.paths['/volumes']['post']['responses']['201']['content']['application/json'];
|
||||
export type TVolumeDeleteRequestBody = hetznerOpenapiSpec.paths['/volumes/{id}']['delete'];
|
||||
|
||||
// firewalls
|
||||
export type IFirewall = hetznerOpenapiSpec.paths['/firewalls/{id}']['get']['responses']['200']['content']['application/json']['firewall'];
|
||||
export type IFirewall = NonNullable<hetznerOpenapiSpec.paths['/firewalls/{id}']['get']['responses']['200']['content']['application/json']['firewall']>;
|
||||
export type TFirewallsGetRequestBody = {};
|
||||
export type TFirewallsGetResponseBody = hetznerOpenapiSpec.paths['/firewalls']['get']['responses']['200']['content']['application/json'];
|
||||
export type TFirewallCreateRequestBody = hetznerOpenapiSpec.paths['/firewalls']['post']['requestBody']['content']['application/json'];
|
||||
export type TFirewallCreateRequestBody = TJsonRequestBody<hetznerOpenapiSpec.paths['/firewalls']['post']>;
|
||||
export type TFirewallCreateResponseBody = hetznerOpenapiSpec.paths['/firewalls']['post']['responses']['201']['content']['application/json'];
|
||||
export type TFirewallDeleteRequestBody = hetznerOpenapiSpec.paths['/firewalls/{id}']['delete'];
|
||||
|
||||
Reference in New Issue
Block a user