Skip to content

Commit 6064b3a

Browse files
feat(api): Add /v2/auth_rules/results endpoint for listing rule evaluation data
1 parent 71b1a8b commit 6064b3a

21 files changed

Lines changed: 4838 additions & 52 deletions

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 176
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-fbdac41d84b5679c659e324345bc4101b056b5f5ed4ddefcd6680afe20db41dc.yml
3-
openapi_spec_hash: 37834cd63d604a528d0467c1cfb01919
4-
config_hash: 61652458521692cd0b88976827c42c25
1+
configured_endpoints: 177
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-32c9a538495a2c820a7ca28c4f09cc1226642b8f7c9422ce1889aebd15e225ca.yml
3+
openapi_spec_hash: b6403689900263b73d4054a548f00285
4+
config_hash: 693dddc4721eef512d75ab6c60897794
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.lithic.api.models
4+
5+
import com.lithic.api.core.AutoPager
6+
import com.lithic.api.core.Page
7+
import com.lithic.api.core.checkRequired
8+
import com.lithic.api.services.blocking.authRules.V2Service
9+
import java.util.Objects
10+
import java.util.Optional
11+
import kotlin.jvm.optionals.getOrNull
12+
13+
/** @see V2Service.listResults */
14+
class AuthRuleV2ListResultsPage
15+
private constructor(
16+
private val service: V2Service,
17+
private val params: AuthRuleV2ListResultsParams,
18+
private val response: AuthRuleV2ListResultsPageResponse,
19+
) : Page<V2ListResultsResponse> {
20+
21+
/**
22+
* Delegates to [AuthRuleV2ListResultsPageResponse], but gracefully handles missing data.
23+
*
24+
* @see AuthRuleV2ListResultsPageResponse.data
25+
*/
26+
fun data(): List<V2ListResultsResponse> =
27+
response._data().getOptional("data").getOrNull() ?: emptyList()
28+
29+
/**
30+
* Delegates to [AuthRuleV2ListResultsPageResponse], but gracefully handles missing data.
31+
*
32+
* @see AuthRuleV2ListResultsPageResponse.hasMore
33+
*/
34+
fun hasMore(): Optional<Boolean> = response._hasMore().getOptional("has_more")
35+
36+
override fun items(): List<V2ListResultsResponse> = data()
37+
38+
override fun hasNextPage(): Boolean = items().isNotEmpty()
39+
40+
fun nextPageParams(): AuthRuleV2ListResultsParams =
41+
if (params.endingBefore().isPresent) {
42+
params.toBuilder().endingBefore(items().first()._token().getOptional("token")).build()
43+
} else {
44+
params.toBuilder().startingAfter(items().last()._token().getOptional("token")).build()
45+
}
46+
47+
override fun nextPage(): AuthRuleV2ListResultsPage = service.listResults(nextPageParams())
48+
49+
fun autoPager(): AutoPager<V2ListResultsResponse> = AutoPager.from(this)
50+
51+
/** The parameters that were used to request this page. */
52+
fun params(): AuthRuleV2ListResultsParams = params
53+
54+
/** The response that this page was parsed from. */
55+
fun response(): AuthRuleV2ListResultsPageResponse = response
56+
57+
fun toBuilder() = Builder().from(this)
58+
59+
companion object {
60+
61+
/**
62+
* Returns a mutable builder for constructing an instance of [AuthRuleV2ListResultsPage].
63+
*
64+
* The following fields are required:
65+
* ```java
66+
* .service()
67+
* .params()
68+
* .response()
69+
* ```
70+
*/
71+
@JvmStatic fun builder() = Builder()
72+
}
73+
74+
/** A builder for [AuthRuleV2ListResultsPage]. */
75+
class Builder internal constructor() {
76+
77+
private var service: V2Service? = null
78+
private var params: AuthRuleV2ListResultsParams? = null
79+
private var response: AuthRuleV2ListResultsPageResponse? = null
80+
81+
@JvmSynthetic
82+
internal fun from(authRuleV2ListResultsPage: AuthRuleV2ListResultsPage) = apply {
83+
service = authRuleV2ListResultsPage.service
84+
params = authRuleV2ListResultsPage.params
85+
response = authRuleV2ListResultsPage.response
86+
}
87+
88+
fun service(service: V2Service) = apply { this.service = service }
89+
90+
/** The parameters that were used to request this page. */
91+
fun params(params: AuthRuleV2ListResultsParams) = apply { this.params = params }
92+
93+
/** The response that this page was parsed from. */
94+
fun response(response: AuthRuleV2ListResultsPageResponse) = apply {
95+
this.response = response
96+
}
97+
98+
/**
99+
* Returns an immutable instance of [AuthRuleV2ListResultsPage].
100+
*
101+
* Further updates to this [Builder] will not mutate the returned instance.
102+
*
103+
* The following fields are required:
104+
* ```java
105+
* .service()
106+
* .params()
107+
* .response()
108+
* ```
109+
*
110+
* @throws IllegalStateException if any required field is unset.
111+
*/
112+
fun build(): AuthRuleV2ListResultsPage =
113+
AuthRuleV2ListResultsPage(
114+
checkRequired("service", service),
115+
checkRequired("params", params),
116+
checkRequired("response", response),
117+
)
118+
}
119+
120+
override fun equals(other: Any?): Boolean {
121+
if (this === other) {
122+
return true
123+
}
124+
125+
return other is AuthRuleV2ListResultsPage &&
126+
service == other.service &&
127+
params == other.params &&
128+
response == other.response
129+
}
130+
131+
override fun hashCode(): Int = Objects.hash(service, params, response)
132+
133+
override fun toString() =
134+
"AuthRuleV2ListResultsPage{service=$service, params=$params, response=$response}"
135+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.lithic.api.models
4+
5+
import com.lithic.api.core.AutoPagerAsync
6+
import com.lithic.api.core.PageAsync
7+
import com.lithic.api.core.checkRequired
8+
import com.lithic.api.services.async.authRules.V2ServiceAsync
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.getOrNull
14+
15+
/** @see V2ServiceAsync.listResults */
16+
class AuthRuleV2ListResultsPageAsync
17+
private constructor(
18+
private val service: V2ServiceAsync,
19+
private val streamHandlerExecutor: Executor,
20+
private val params: AuthRuleV2ListResultsParams,
21+
private val response: AuthRuleV2ListResultsPageResponse,
22+
) : PageAsync<V2ListResultsResponse> {
23+
24+
/**
25+
* Delegates to [AuthRuleV2ListResultsPageResponse], but gracefully handles missing data.
26+
*
27+
* @see AuthRuleV2ListResultsPageResponse.data
28+
*/
29+
fun data(): List<V2ListResultsResponse> =
30+
response._data().getOptional("data").getOrNull() ?: emptyList()
31+
32+
/**
33+
* Delegates to [AuthRuleV2ListResultsPageResponse], but gracefully handles missing data.
34+
*
35+
* @see AuthRuleV2ListResultsPageResponse.hasMore
36+
*/
37+
fun hasMore(): Optional<Boolean> = response._hasMore().getOptional("has_more")
38+
39+
override fun items(): List<V2ListResultsResponse> = data()
40+
41+
override fun hasNextPage(): Boolean = items().isNotEmpty()
42+
43+
fun nextPageParams(): AuthRuleV2ListResultsParams =
44+
if (params.endingBefore().isPresent) {
45+
params.toBuilder().endingBefore(items().first()._token().getOptional("token")).build()
46+
} else {
47+
params.toBuilder().startingAfter(items().last()._token().getOptional("token")).build()
48+
}
49+
50+
override fun nextPage(): CompletableFuture<AuthRuleV2ListResultsPageAsync> =
51+
service.listResults(nextPageParams())
52+
53+
fun autoPager(): AutoPagerAsync<V2ListResultsResponse> =
54+
AutoPagerAsync.from(this, streamHandlerExecutor)
55+
56+
/** The parameters that were used to request this page. */
57+
fun params(): AuthRuleV2ListResultsParams = params
58+
59+
/** The response that this page was parsed from. */
60+
fun response(): AuthRuleV2ListResultsPageResponse = response
61+
62+
fun toBuilder() = Builder().from(this)
63+
64+
companion object {
65+
66+
/**
67+
* Returns a mutable builder for constructing an instance of
68+
* [AuthRuleV2ListResultsPageAsync].
69+
*
70+
* The following fields are required:
71+
* ```java
72+
* .service()
73+
* .streamHandlerExecutor()
74+
* .params()
75+
* .response()
76+
* ```
77+
*/
78+
@JvmStatic fun builder() = Builder()
79+
}
80+
81+
/** A builder for [AuthRuleV2ListResultsPageAsync]. */
82+
class Builder internal constructor() {
83+
84+
private var service: V2ServiceAsync? = null
85+
private var streamHandlerExecutor: Executor? = null
86+
private var params: AuthRuleV2ListResultsParams? = null
87+
private var response: AuthRuleV2ListResultsPageResponse? = null
88+
89+
@JvmSynthetic
90+
internal fun from(authRuleV2ListResultsPageAsync: AuthRuleV2ListResultsPageAsync) = apply {
91+
service = authRuleV2ListResultsPageAsync.service
92+
streamHandlerExecutor = authRuleV2ListResultsPageAsync.streamHandlerExecutor
93+
params = authRuleV2ListResultsPageAsync.params
94+
response = authRuleV2ListResultsPageAsync.response
95+
}
96+
97+
fun service(service: V2ServiceAsync) = apply { this.service = service }
98+
99+
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
100+
this.streamHandlerExecutor = streamHandlerExecutor
101+
}
102+
103+
/** The parameters that were used to request this page. */
104+
fun params(params: AuthRuleV2ListResultsParams) = apply { this.params = params }
105+
106+
/** The response that this page was parsed from. */
107+
fun response(response: AuthRuleV2ListResultsPageResponse) = apply {
108+
this.response = response
109+
}
110+
111+
/**
112+
* Returns an immutable instance of [AuthRuleV2ListResultsPageAsync].
113+
*
114+
* Further updates to this [Builder] will not mutate the returned instance.
115+
*
116+
* The following fields are required:
117+
* ```java
118+
* .service()
119+
* .streamHandlerExecutor()
120+
* .params()
121+
* .response()
122+
* ```
123+
*
124+
* @throws IllegalStateException if any required field is unset.
125+
*/
126+
fun build(): AuthRuleV2ListResultsPageAsync =
127+
AuthRuleV2ListResultsPageAsync(
128+
checkRequired("service", service),
129+
checkRequired("streamHandlerExecutor", streamHandlerExecutor),
130+
checkRequired("params", params),
131+
checkRequired("response", response),
132+
)
133+
}
134+
135+
override fun equals(other: Any?): Boolean {
136+
if (this === other) {
137+
return true
138+
}
139+
140+
return other is AuthRuleV2ListResultsPageAsync &&
141+
service == other.service &&
142+
streamHandlerExecutor == other.streamHandlerExecutor &&
143+
params == other.params &&
144+
response == other.response
145+
}
146+
147+
override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response)
148+
149+
override fun toString() =
150+
"AuthRuleV2ListResultsPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}"
151+
}

0 commit comments

Comments
 (0)