Skip to content

Commit 2b55880

Browse files
committed
Add v2/status
1 parent 5b5999f commit 2b55880

File tree

3 files changed

+318
-1
lines changed

3 files changed

+318
-1
lines changed

Packages/ton-api/Sources/Generated/Client.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,57 @@ public struct Client: APIProtocol {
3636
)
3737
}
3838
private var converter: Converter { client.converter }
39+
/// Status
40+
///
41+
/// - Remark: HTTP `GET /v2/status`.
42+
/// - Remark: Generated from `#/paths//v2/status/get(status)`.
43+
public func status(_ input: Operations.status.Input) async throws -> Operations.status.Output {
44+
try await client.send(
45+
input: input,
46+
forOperation: Operations.status.id,
47+
serializer: { input in
48+
let path = try converter.renderedPath(template: "/v2/status", parameters: [])
49+
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
50+
suppressMutabilityWarning(&request)
51+
converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept)
52+
return (request, nil)
53+
},
54+
deserializer: { response, responseBody in
55+
switch response.status.code {
56+
case 200:
57+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
58+
let body: Operations.status.Output.Ok.Body
59+
if try contentType == nil
60+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
61+
{
62+
body = try await converter.getResponseBodyAsJSON(
63+
Components.Schemas.ServiceStatus.self,
64+
from: responseBody,
65+
transforming: { value in .json(value) }
66+
)
67+
} else {
68+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
69+
}
70+
return .ok(.init(body: body))
71+
default:
72+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
73+
let body: Components.Responses._Error.Body
74+
if try contentType == nil
75+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
76+
{
77+
body = try await converter.getResponseBodyAsJSON(
78+
Components.Responses._Error.Body.jsonPayload.self,
79+
from: responseBody,
80+
transforming: { value in .json(value) }
81+
)
82+
} else {
83+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
84+
}
85+
return .`default`(statusCode: response.status.code, .init(body: body))
86+
}
87+
}
88+
)
89+
}
3990
/// Get blockchain block data
4091
///
4192
/// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`.

Packages/ton-api/Sources/Generated/Types.swift

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import struct Foundation.Date
1111
#endif
1212
/// A type that performs HTTP operations defined by the OpenAPI document.
1313
public protocol APIProtocol: Sendable {
14+
/// Status
15+
///
16+
/// - Remark: HTTP `GET /v2/status`.
17+
/// - Remark: Generated from `#/paths//v2/status/get(status)`.
18+
func status(_ input: Operations.status.Input) async throws -> Operations.status.Output
1419
/// Get blockchain block data
1520
///
1621
/// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`.
@@ -515,6 +520,13 @@ public protocol APIProtocol: Sendable {
515520
}
516521
/// Convenience overloads for operation inputs.
517522
extension APIProtocol {
523+
/// Status
524+
///
525+
/// - Remark: HTTP `GET /v2/status`.
526+
/// - Remark: Generated from `#/paths//v2/status/get(status)`.
527+
public func status(headers: Operations.status.Input.Headers = .init()) async throws -> Operations.status.Output {
528+
try await status(Operations.status.Input(headers: headers))
529+
}
518530
/// Get blockchain block data
519531
///
520532
/// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`.
@@ -1622,6 +1634,85 @@ public enum Components {
16221634
case minted
16231635
}
16241636
}
1637+
/// - Remark: Generated from `#/components/schemas/ServiceStatus`.
1638+
public struct ServiceStatus: Codable, Hashable, Sendable {
1639+
/// - Remark: Generated from `#/components/schemas/ServiceStatus/rest_online`.
1640+
public var rest_online: Swift.Bool
1641+
/// - Remark: Generated from `#/components/schemas/ServiceStatus/indexing_latency`.
1642+
public var indexing_latency: Swift.Int
1643+
/// Creates a new `ServiceStatus`.
1644+
///
1645+
/// - Parameters:
1646+
/// - rest_online:
1647+
/// - indexing_latency:
1648+
public init(rest_online: Swift.Bool, indexing_latency: Swift.Int) {
1649+
self.rest_online = rest_online
1650+
self.indexing_latency = indexing_latency
1651+
}
1652+
public enum CodingKeys: String, CodingKey {
1653+
case rest_online
1654+
case indexing_latency
1655+
}
1656+
}
1657+
/// - Remark: Generated from `#/components/schemas/ReducedBlock`.
1658+
public struct ReducedBlock: Codable, Hashable, Sendable {
1659+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/workchain_id`.
1660+
public var workchain_id: Swift.Int32
1661+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/shard`.
1662+
public var shard: Swift.String
1663+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/seqno`.
1664+
public var seqno: Swift.Int32
1665+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/master_ref`.
1666+
public var master_ref: Swift.String?
1667+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/tx_quantity`.
1668+
public var tx_quantity: Swift.Int
1669+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/utime`.
1670+
public var utime: Swift.Int64
1671+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/shards_blocks`.
1672+
public var shards_blocks: [Swift.String]
1673+
/// - Remark: Generated from `#/components/schemas/ReducedBlock/parent`.
1674+
public var parent: [Swift.String]
1675+
/// Creates a new `ReducedBlock`.
1676+
///
1677+
/// - Parameters:
1678+
/// - workchain_id:
1679+
/// - shard:
1680+
/// - seqno:
1681+
/// - master_ref:
1682+
/// - tx_quantity:
1683+
/// - utime:
1684+
/// - shards_blocks:
1685+
/// - parent:
1686+
public init(
1687+
workchain_id: Swift.Int32,
1688+
shard: Swift.String,
1689+
seqno: Swift.Int32,
1690+
master_ref: Swift.String? = nil,
1691+
tx_quantity: Swift.Int,
1692+
utime: Swift.Int64,
1693+
shards_blocks: [Swift.String],
1694+
parent: [Swift.String]
1695+
) {
1696+
self.workchain_id = workchain_id
1697+
self.shard = shard
1698+
self.seqno = seqno
1699+
self.master_ref = master_ref
1700+
self.tx_quantity = tx_quantity
1701+
self.utime = utime
1702+
self.shards_blocks = shards_blocks
1703+
self.parent = parent
1704+
}
1705+
public enum CodingKeys: String, CodingKey {
1706+
case workchain_id
1707+
case shard
1708+
case seqno
1709+
case master_ref
1710+
case tx_quantity
1711+
case utime
1712+
case shards_blocks
1713+
case parent
1714+
}
1715+
}
16251716
/// - Remark: Generated from `#/components/schemas/BlockchainBlock`.
16261717
public struct BlockchainBlock: Codable, Hashable, Sendable {
16271718
/// - Remark: Generated from `#/components/schemas/BlockchainBlock/tx_quantity`.
@@ -8163,6 +8254,113 @@ public enum Components {
81638254
}
81648255
/// API operations, with input and output types, generated from `#/paths` in the OpenAPI document.
81658256
public enum Operations {
8257+
/// Status
8258+
///
8259+
/// - Remark: HTTP `GET /v2/status`.
8260+
/// - Remark: Generated from `#/paths//v2/status/get(status)`.
8261+
public enum status {
8262+
public static let id: Swift.String = "status"
8263+
public struct Input: Sendable, Hashable {
8264+
/// - Remark: Generated from `#/paths/v2/status/GET/header`.
8265+
public struct Headers: Sendable, Hashable {
8266+
public var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.status.AcceptableContentType>]
8267+
/// Creates a new `Headers`.
8268+
///
8269+
/// - Parameters:
8270+
/// - accept:
8271+
public init(
8272+
accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.status.AcceptableContentType>] =
8273+
.defaultValues()
8274+
) { self.accept = accept }
8275+
}
8276+
public var headers: Operations.status.Input.Headers
8277+
/// Creates a new `Input`.
8278+
///
8279+
/// - Parameters:
8280+
/// - headers:
8281+
public init(headers: Operations.status.Input.Headers = .init()) { self.headers = headers }
8282+
}
8283+
@frozen public enum Output: Sendable, Hashable {
8284+
public struct Ok: Sendable, Hashable {
8285+
/// - Remark: Generated from `#/paths/v2/status/GET/responses/200/content`.
8286+
@frozen public enum Body: Sendable, Hashable {
8287+
/// - Remark: Generated from `#/paths/v2/status/GET/responses/200/content/application\/json`.
8288+
case json(Components.Schemas.ServiceStatus)
8289+
/// The associated value of the enum case if `self` is `.json`.
8290+
///
8291+
/// - Throws: An error if `self` is not `.json`.
8292+
/// - SeeAlso: `.json`.
8293+
public var json: Components.Schemas.ServiceStatus {
8294+
get throws {
8295+
switch self {
8296+
case let .json(body): return body
8297+
}
8298+
}
8299+
}
8300+
}
8301+
/// Received HTTP response body
8302+
public var body: Operations.status.Output.Ok.Body
8303+
/// Creates a new `Ok`.
8304+
///
8305+
/// - Parameters:
8306+
/// - body: Received HTTP response body
8307+
public init(body: Operations.status.Output.Ok.Body) { self.body = body }
8308+
}
8309+
/// status
8310+
///
8311+
/// - Remark: Generated from `#/paths//v2/status/get(status)/responses/200`.
8312+
///
8313+
/// HTTP response code: `200 ok`.
8314+
case ok(Operations.status.Output.Ok)
8315+
/// The associated value of the enum case if `self` is `.ok`.
8316+
///
8317+
/// - Throws: An error if `self` is not `.ok`.
8318+
/// - SeeAlso: `.ok`.
8319+
public var ok: Operations.status.Output.Ok {
8320+
get throws {
8321+
switch self {
8322+
case let .ok(response): return response
8323+
default: try throwUnexpectedResponseStatus(expectedStatus: "ok", response: self)
8324+
}
8325+
}
8326+
}
8327+
/// Some error during request processing
8328+
///
8329+
/// - Remark: Generated from `#/paths//v2/status/get(status)/responses/default`.
8330+
///
8331+
/// HTTP response code: `default`.
8332+
case `default`(statusCode: Swift.Int, Components.Responses._Error)
8333+
/// The associated value of the enum case if `self` is `.`default``.
8334+
///
8335+
/// - Throws: An error if `self` is not `.`default``.
8336+
/// - SeeAlso: `.`default``.
8337+
public var `default`: Components.Responses._Error {
8338+
get throws {
8339+
switch self {
8340+
case let .`default`(_, response): return response
8341+
default: try throwUnexpectedResponseStatus(expectedStatus: "default", response: self)
8342+
}
8343+
}
8344+
}
8345+
}
8346+
@frozen public enum AcceptableContentType: AcceptableProtocol {
8347+
case json
8348+
case other(Swift.String)
8349+
public init?(rawValue: Swift.String) {
8350+
switch rawValue.lowercased() {
8351+
case "application/json": self = .json
8352+
default: self = .other(rawValue)
8353+
}
8354+
}
8355+
public var rawValue: Swift.String {
8356+
switch self {
8357+
case let .other(string): return string
8358+
case .json: return "application/json"
8359+
}
8360+
}
8361+
public static var allCases: [Self] { [.json] }
8362+
}
8363+
}
81668364
/// Get blockchain block data
81678365
///
81688366
/// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`.

Packages/ton-api/openapi_generation/openapi.yml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ servers:
1111
- url: "https://testnet.tonapi.io"
1212
- url: "http://localhost:8081"
1313
paths:
14+
/v2/status:
15+
get:
16+
description: Status
17+
operationId: status
18+
tags:
19+
- Blockchain
20+
responses:
21+
'200':
22+
description: status
23+
content:
24+
application/json:
25+
schema:
26+
$ref: '#/components/schemas/ServiceStatus'
27+
'default':
28+
$ref: '#/components/responses/Error'
1429
/v2/blockchain/blocks/{block_id}:
1530
get:
1631
description: Get blockchain block data
@@ -2894,7 +2909,60 @@ components:
28942909
$ref: '#/components/schemas/BlockCurrencyCollection'
28952910
minted:
28962911
$ref: '#/components/schemas/BlockCurrencyCollection'
2897-
2912+
ServiceStatus:
2913+
type: object
2914+
required:
2915+
- indexing_latency
2916+
- rest_online
2917+
properties:
2918+
rest_online:
2919+
type: boolean
2920+
default: true
2921+
indexing_latency:
2922+
type: integer
2923+
example: 100
2924+
ReducedBlock:
2925+
type: object
2926+
required:
2927+
- workchain_id
2928+
- shard
2929+
- seqno
2930+
- tx_quantity
2931+
- utime
2932+
- shards_blocks
2933+
- parent
2934+
properties:
2935+
workchain_id:
2936+
type: integer
2937+
example: 0
2938+
format: int32
2939+
shard:
2940+
type: string
2941+
example: 8000000000000000
2942+
seqno:
2943+
type: integer
2944+
example: 21734019
2945+
format: int32
2946+
master_ref:
2947+
type: string
2948+
example: (-1,4234234,8000000000000000)
2949+
tx_quantity:
2950+
type: integer
2951+
example: 130
2952+
utime:
2953+
type: integer
2954+
format: int64
2955+
example: 23814011000000
2956+
shards_blocks:
2957+
type: array
2958+
items:
2959+
type: string
2960+
example: [ (0,4234235,8000000000000000) ]
2961+
parent:
2962+
type: array
2963+
items:
2964+
type: string
2965+
example: [ (0,21734018,8000000000000000) ]
28982966
BlockchainBlock:
28992967
type: object
29002968
required:

0 commit comments

Comments
 (0)