Skip to content

Commit a44af1e

Browse files
author
stlc-bot
committed
Build SDK
Stainless-Generated-From: b490d6d
1 parent 8af8833 commit a44af1e

10 files changed

Lines changed: 382 additions & 70 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package ai.llamaindex.llamacloudadmin.models.quotamanagement
4+
5+
import ai.llamaindex.llamacloudadmin.core.AutoPager
6+
import ai.llamaindex.llamacloudadmin.core.Page
7+
import ai.llamaindex.llamacloudadmin.core.checkRequired
8+
import ai.llamaindex.llamacloudadmin.services.blocking.QuotaManagementService
9+
import java.util.Objects
10+
import java.util.Optional
11+
import kotlin.jvm.optionals.getOrDefault
12+
import kotlin.jvm.optionals.getOrNull
13+
14+
/** @see QuotaManagementService.list */
15+
class QuotaManagementListPage
16+
private constructor(
17+
private val service: QuotaManagementService,
18+
private val params: QuotaManagementListParams,
19+
private val response: QuotaManagementListPageResponse,
20+
) : Page<QuotaConfiguration> {
21+
22+
/**
23+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
24+
*
25+
* @see QuotaManagementListPageResponse.items
26+
*/
27+
override fun items(): List<QuotaConfiguration> =
28+
response._items().getOptional("items").getOrNull() ?: emptyList()
29+
30+
/**
31+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
32+
*
33+
* @see QuotaManagementListPageResponse.pages
34+
*/
35+
fun pages(): Optional<Long> = response._pages().getOptional("pages")
36+
37+
/**
38+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
39+
*
40+
* @see QuotaManagementListPageResponse.page
41+
*/
42+
fun page(): Optional<Long> = response._page().getOptional("page")
43+
44+
override fun hasNextPage(): Boolean {
45+
if (items().isEmpty()) {
46+
return false
47+
}
48+
49+
val pageNumber = page().getOrDefault(1)
50+
val pageCount = pages().getOrNull()
51+
return pageCount == null || pageNumber < pageCount
52+
}
53+
54+
fun nextPageParams(): QuotaManagementListParams {
55+
val pageNumber = params.page().getOrDefault(1)
56+
return params.toBuilder().page(pageNumber + 1).build()
57+
}
58+
59+
override fun nextPage(): QuotaManagementListPage = service.list(nextPageParams())
60+
61+
fun autoPager(): AutoPager<QuotaConfiguration> = AutoPager.from(this)
62+
63+
/** The parameters that were used to request this page. */
64+
fun params(): QuotaManagementListParams = params
65+
66+
/** The response that this page was parsed from. */
67+
fun response(): QuotaManagementListPageResponse = response
68+
69+
fun toBuilder() = Builder().from(this)
70+
71+
companion object {
72+
73+
/**
74+
* Returns a mutable builder for constructing an instance of [QuotaManagementListPage].
75+
*
76+
* The following fields are required:
77+
* ```java
78+
* .service()
79+
* .params()
80+
* .response()
81+
* ```
82+
*/
83+
@JvmStatic fun builder() = Builder()
84+
}
85+
86+
/** A builder for [QuotaManagementListPage]. */
87+
class Builder internal constructor() {
88+
89+
private var service: QuotaManagementService? = null
90+
private var params: QuotaManagementListParams? = null
91+
private var response: QuotaManagementListPageResponse? = null
92+
93+
@JvmSynthetic
94+
internal fun from(quotaManagementListPage: QuotaManagementListPage) = apply {
95+
service = quotaManagementListPage.service
96+
params = quotaManagementListPage.params
97+
response = quotaManagementListPage.response
98+
}
99+
100+
fun service(service: QuotaManagementService) = apply { this.service = service }
101+
102+
/** The parameters that were used to request this page. */
103+
fun params(params: QuotaManagementListParams) = apply { this.params = params }
104+
105+
/** The response that this page was parsed from. */
106+
fun response(response: QuotaManagementListPageResponse) = apply { this.response = response }
107+
108+
/**
109+
* Returns an immutable instance of [QuotaManagementListPage].
110+
*
111+
* Further updates to this [Builder] will not mutate the returned instance.
112+
*
113+
* The following fields are required:
114+
* ```java
115+
* .service()
116+
* .params()
117+
* .response()
118+
* ```
119+
*
120+
* @throws IllegalStateException if any required field is unset.
121+
*/
122+
fun build(): QuotaManagementListPage =
123+
QuotaManagementListPage(
124+
checkRequired("service", service),
125+
checkRequired("params", params),
126+
checkRequired("response", response),
127+
)
128+
}
129+
130+
override fun equals(other: Any?): Boolean {
131+
if (this === other) {
132+
return true
133+
}
134+
135+
return other is QuotaManagementListPage &&
136+
service == other.service &&
137+
params == other.params &&
138+
response == other.response
139+
}
140+
141+
override fun hashCode(): Int = Objects.hash(service, params, response)
142+
143+
override fun toString() =
144+
"QuotaManagementListPage{service=$service, params=$params, response=$response}"
145+
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package ai.llamaindex.llamacloudadmin.models.quotamanagement
4+
5+
import ai.llamaindex.llamacloudadmin.core.AutoPagerAsync
6+
import ai.llamaindex.llamacloudadmin.core.PageAsync
7+
import ai.llamaindex.llamacloudadmin.core.checkRequired
8+
import ai.llamaindex.llamacloudadmin.services.async.QuotaManagementServiceAsync
9+
import java.util.Objects
10+
import java.util.Optional
11+
import java.util.concurrent.CompletableFuture
12+
import java.util.concurrent.Executor
13+
import kotlin.jvm.optionals.getOrDefault
14+
import kotlin.jvm.optionals.getOrNull
15+
16+
/** @see QuotaManagementServiceAsync.list */
17+
class QuotaManagementListPageAsync
18+
private constructor(
19+
private val service: QuotaManagementServiceAsync,
20+
private val streamHandlerExecutor: Executor,
21+
private val params: QuotaManagementListParams,
22+
private val response: QuotaManagementListPageResponse,
23+
) : PageAsync<QuotaConfiguration> {
24+
25+
/**
26+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
27+
*
28+
* @see QuotaManagementListPageResponse.items
29+
*/
30+
override fun items(): List<QuotaConfiguration> =
31+
response._items().getOptional("items").getOrNull() ?: emptyList()
32+
33+
/**
34+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
35+
*
36+
* @see QuotaManagementListPageResponse.pages
37+
*/
38+
fun pages(): Optional<Long> = response._pages().getOptional("pages")
39+
40+
/**
41+
* Delegates to [QuotaManagementListPageResponse], but gracefully handles missing data.
42+
*
43+
* @see QuotaManagementListPageResponse.page
44+
*/
45+
fun page(): Optional<Long> = response._page().getOptional("page")
46+
47+
override fun hasNextPage(): Boolean {
48+
if (items().isEmpty()) {
49+
return false
50+
}
51+
52+
val pageNumber = page().getOrDefault(1)
53+
val pageCount = pages().getOrNull()
54+
return pageCount == null || pageNumber < pageCount
55+
}
56+
57+
fun nextPageParams(): QuotaManagementListParams {
58+
val pageNumber = params.page().getOrDefault(1)
59+
return params.toBuilder().page(pageNumber + 1).build()
60+
}
61+
62+
override fun nextPage(): CompletableFuture<QuotaManagementListPageAsync> =
63+
service.list(nextPageParams())
64+
65+
fun autoPager(): AutoPagerAsync<QuotaConfiguration> =
66+
AutoPagerAsync.from(this, streamHandlerExecutor)
67+
68+
/** The parameters that were used to request this page. */
69+
fun params(): QuotaManagementListParams = params
70+
71+
/** The response that this page was parsed from. */
72+
fun response(): QuotaManagementListPageResponse = response
73+
74+
fun toBuilder() = Builder().from(this)
75+
76+
companion object {
77+
78+
/**
79+
* Returns a mutable builder for constructing an instance of [QuotaManagementListPageAsync].
80+
*
81+
* The following fields are required:
82+
* ```java
83+
* .service()
84+
* .streamHandlerExecutor()
85+
* .params()
86+
* .response()
87+
* ```
88+
*/
89+
@JvmStatic fun builder() = Builder()
90+
}
91+
92+
/** A builder for [QuotaManagementListPageAsync]. */
93+
class Builder internal constructor() {
94+
95+
private var service: QuotaManagementServiceAsync? = null
96+
private var streamHandlerExecutor: Executor? = null
97+
private var params: QuotaManagementListParams? = null
98+
private var response: QuotaManagementListPageResponse? = null
99+
100+
@JvmSynthetic
101+
internal fun from(quotaManagementListPageAsync: QuotaManagementListPageAsync) = apply {
102+
service = quotaManagementListPageAsync.service
103+
streamHandlerExecutor = quotaManagementListPageAsync.streamHandlerExecutor
104+
params = quotaManagementListPageAsync.params
105+
response = quotaManagementListPageAsync.response
106+
}
107+
108+
fun service(service: QuotaManagementServiceAsync) = apply { this.service = service }
109+
110+
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
111+
this.streamHandlerExecutor = streamHandlerExecutor
112+
}
113+
114+
/** The parameters that were used to request this page. */
115+
fun params(params: QuotaManagementListParams) = apply { this.params = params }
116+
117+
/** The response that this page was parsed from. */
118+
fun response(response: QuotaManagementListPageResponse) = apply { this.response = response }
119+
120+
/**
121+
* Returns an immutable instance of [QuotaManagementListPageAsync].
122+
*
123+
* Further updates to this [Builder] will not mutate the returned instance.
124+
*
125+
* The following fields are required:
126+
* ```java
127+
* .service()
128+
* .streamHandlerExecutor()
129+
* .params()
130+
* .response()
131+
* ```
132+
*
133+
* @throws IllegalStateException if any required field is unset.
134+
*/
135+
fun build(): QuotaManagementListPageAsync =
136+
QuotaManagementListPageAsync(
137+
checkRequired("service", service),
138+
checkRequired("streamHandlerExecutor", streamHandlerExecutor),
139+
checkRequired("params", params),
140+
checkRequired("response", response),
141+
)
142+
}
143+
144+
override fun equals(other: Any?): Boolean {
145+
if (this === other) {
146+
return true
147+
}
148+
149+
return other is QuotaManagementListPageAsync &&
150+
service == other.service &&
151+
streamHandlerExecutor == other.streamHandlerExecutor &&
152+
params == other.params &&
153+
response == other.response
154+
}
155+
156+
override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response)
157+
158+
override fun toString() =
159+
"QuotaManagementListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}"
160+
}

0 commit comments

Comments
 (0)