Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cross-media-measurement-api dep for exchange API changes. #1284

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def wfa_measurement_system_repositories():
wfa_repo_archive(
name = "wfa_measurement_proto",
repo = "cross-media-measurement-api",
sha256 = "7fc35bd1b0504ae2168090d17da5480a86f0171c5e111549551e424dc1a89f6d",
version = "0.46.0",
sha256 = "e856f7c537b0b5100183ef0d653bce2c782557d7d5f437b1d1c7bc160e5eef46",
version = "0.47.0",
)

wfa_repo_archive(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.api.v2alpha

import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ResourceKey

/** [ResourceKey] for an Exchange with a DataProvider RecurringExchange parent. */
data class DataProviderExchangeKey(
override val parentKey: DataProviderRecurringExchangeKey,
override val exchangeId: String,
) : ExchangeKey {
constructor(
dataProviderId: String,
recurringExchangeId: String,
exchangeId: String
) : this(DataProviderRecurringExchangeKey(dataProviderId, recurringExchangeId), exchangeId)

val dataProviderId: String
get() = parentKey.dataProviderId

override fun toName(): String {
return parser.assembleName(
mapOf(
IdVariable.DATA_PROVIDER to dataProviderId,
IdVariable.RECURRING_EXCHANGE to recurringExchangeId,
IdVariable.EXCHANGE to exchangeId,
)
)
}

companion object FACTORY : ResourceKey.Factory<DataProviderExchangeKey> {
const val PATTERN = "${DataProviderRecurringExchangeKey.PATTERN}/exchanges/{exchange}"
private val parser = ResourceNameParser(PATTERN)

override fun fromName(resourceName: String): DataProviderExchangeKey? {
val idVars: Map<IdVariable, String> = parser.parseIdVars(resourceName) ?: return null
return DataProviderExchangeKey(
idVars.getValue(IdVariable.DATA_PROVIDER),
idVars.getValue(IdVariable.RECURRING_EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.api.v2alpha

import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ResourceKey

/** [ResourceKey] for an ExchangeStepAttempt with a DataProvider RecurringExchange parent. */
data class DataProviderExchangeStepAttemptKey(
override val parentKey: DataProviderExchangeStepKey,
override val exchangeStepAttemptId: String,
) : ExchangeStepAttemptKey {
constructor(
dataProviderId: String,
recurringExchangeId: String,
exchangeId: String,
exchangeStepId: String,
exchangeStepAttemptId: String,
) : this(
DataProviderExchangeStepKey(dataProviderId, recurringExchangeId, exchangeId, exchangeStepId),
exchangeStepAttemptId
)

val dataProviderId: String
get() = parentKey.dataProviderId

override fun toName(): String {
return parser.assembleName(
mapOf(
IdVariable.DATA_PROVIDER to dataProviderId,
IdVariable.RECURRING_EXCHANGE to recurringExchangeId,
IdVariable.EXCHANGE to exchangeId,
IdVariable.EXCHANGE_STEP to exchangeStepId,
IdVariable.EXCHANGE_STEP_ATTEMPT to exchangeStepAttemptId,
)
)
}

companion object FACTORY : ResourceKey.Factory<DataProviderExchangeStepAttemptKey> {
const val PATTERN = "${DataProviderExchangeStepKey.PATTERN}/attempts/{exchange_step_attempt}"
private val parser = ResourceNameParser(PATTERN)

override fun fromName(resourceName: String): DataProviderExchangeStepAttemptKey? {
val idVars: Map<IdVariable, String> = parser.parseIdVars(resourceName) ?: return null
return DataProviderExchangeStepAttemptKey(
idVars.getValue(IdVariable.DATA_PROVIDER),
idVars.getValue(IdVariable.RECURRING_EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE_STEP),
idVars.getValue(IdVariable.EXCHANGE_STEP_ATTEMPT),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.api.v2alpha

import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ResourceKey

/** [ResourceKey] for an ExchangeStep with a DataProvider RecurringExchange parent. */
data class DataProviderExchangeStepKey(
override val parentKey: DataProviderExchangeKey,
override val exchangeStepId: String,
) : ExchangeStepKey {
constructor(
dataProviderId: String,
recurringExchangeId: String,
exchangeId: String,
exchangeStepId: String,
) : this(DataProviderExchangeKey(dataProviderId, recurringExchangeId, exchangeId), exchangeStepId)

val dataProviderId: String
get() = parentKey.dataProviderId

override fun toName(): String {
return parser.assembleName(
mapOf(
IdVariable.DATA_PROVIDER to dataProviderId,
IdVariable.RECURRING_EXCHANGE to recurringExchangeId,
IdVariable.EXCHANGE to exchangeId,
IdVariable.EXCHANGE_STEP to exchangeStepId,
)
)
}

companion object FACTORY : ResourceKey.Factory<DataProviderExchangeStepKey> {
const val PATTERN = "${DataProviderExchangeKey.PATTERN}/steps/{exchange_step}"
private val parser = ResourceNameParser(PATTERN)

override fun fromName(resourceName: String): DataProviderExchangeStepKey? {
val idVars: Map<IdVariable, String> = parser.parseIdVars(resourceName) ?: return null
return DataProviderExchangeStepKey(
idVars.getValue(IdVariable.DATA_PROVIDER),
idVars.getValue(IdVariable.RECURRING_EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE_STEP),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ResourceKey

/** [DataProviderKey] of a Data Provider. */
data class DataProviderKey(val dataProviderId: String) : ResourceKey, CertificateParentKey {
data class DataProviderKey(
val dataProviderId: String,
) : ResourceKey, CertificateParentKey, RecurringExchangeParentKey {
override fun toName(): String {
return parser.assembleName(mapOf(IdVariable.DATA_PROVIDER to dataProviderId))
}

companion object FACTORY : ResourceKey.Factory<DataProviderKey> {
const val COLLECTION_NAME = "dataProviders"
const val PATTERN = "$COLLECTION_NAME/{data_provider}"
val defaultValue = DataProviderKey("")

private val parser = ResourceNameParser("$COLLECTION_NAME/{data_provider}")
private val parser = ResourceNameParser(PATTERN)

override fun fromName(resourceName: String): DataProviderKey? {
return parser.parseIdVars(resourceName)?.let {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.api.v2alpha

import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ChildResourceKey
import org.wfanet.measurement.common.api.ResourceKey

/** [ResourceKey] of a RecurringExchange with a DataProvider parent. */
data class DataProviderRecurringExchangeKey(
override val parentKey: DataProviderKey,
override val recurringExchangeId: String
) : RecurringExchangeKey, ChildResourceKey {
constructor(
dataProviderId: String,
recurringExchangeId: String
) : this(DataProviderKey(dataProviderId), recurringExchangeId)

val dataProviderId: String
get() = parentKey.dataProviderId

override fun toName(): String {
return parser.assembleName(
mapOf(
IdVariable.DATA_PROVIDER to dataProviderId,
IdVariable.RECURRING_EXCHANGE to recurringExchangeId
)
)
}

companion object FACTORY : ResourceKey.Factory<DataProviderRecurringExchangeKey> {
const val PATTERN = "${DataProviderKey.PATTERN}/recurringExchanges/{recurring_exchange}"
private val parser = ResourceNameParser(PATTERN)

override fun fromName(resourceName: String): DataProviderRecurringExchangeKey? {
val idVars: Map<IdVariable, String> = parser.parseIdVars(resourceName) ?: return null
return DataProviderRecurringExchangeKey(
idVars.getValue(IdVariable.DATA_PROVIDER),
idVars.getValue(IdVariable.RECURRING_EXCHANGE)
)
}
}
}
41 changes: 34 additions & 7 deletions src/main/kotlin/org/wfanet/measurement/api/v2alpha/ExchangeKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,52 @@
package org.wfanet.measurement.api.v2alpha

import org.wfanet.measurement.common.ResourceNameParser
import org.wfanet.measurement.common.api.ChildResourceKey
import org.wfanet.measurement.common.api.ResourceKey

/** [ExchangeKey] of an Exchange. */
data class ExchangeKey(val recurringExchangeId: String, val exchangeId: String) : ResourceKey {
/** [ResourceKey] of an Exchange. */
sealed interface ExchangeKey : ChildResourceKey {
override val parentKey: RecurringExchangeKey

val recurringExchangeId: String
get() = parentKey.recurringExchangeId

val exchangeId: String

companion object FACTORY : ResourceKey.Factory<ExchangeKey> {
override fun fromName(resourceName: String): ExchangeKey? {
return CanonicalExchangeKey.fromName(resourceName)
?: DataProviderExchangeKey.fromName(resourceName)
?: ModelProviderExchangeKey.fromName(resourceName)
}
}
}

/** Canonical [ResourceKey] of an Exchange. */
data class CanonicalExchangeKey(
override val parentKey: CanonicalRecurringExchangeKey,
override val exchangeId: String,
) : ExchangeKey {
constructor(
recurringExchangeId: String,
exchangeId: String
) : this(CanonicalRecurringExchangeKey(recurringExchangeId), exchangeId)

override fun toName(): String {
return parser.assembleName(
mapOf(IdVariable.RECURRING_EXCHANGE to recurringExchangeId, IdVariable.EXCHANGE to exchangeId)
)
}

companion object FACTORY : ResourceKey.Factory<ExchangeKey> {
companion object FACTORY : ResourceKey.Factory<CanonicalExchangeKey> {
private val parser =
ResourceNameParser("recurringExchanges/{recurring_exchange}/exchanges/{exchange}")
ResourceNameParser("${CanonicalRecurringExchangeKey.PATTERN}/exchanges/{exchange}")

val defaultValue = ExchangeKey("", "")
val defaultValue = CanonicalExchangeKey("", "")

override fun fromName(resourceName: String): ExchangeKey? {
override fun fromName(resourceName: String): CanonicalExchangeKey? {
val idVars = parser.parseIdVars(resourceName) ?: return null
return ExchangeKey(
return CanonicalExchangeKey(
idVars.getValue(IdVariable.RECURRING_EXCHANGE),
idVars.getValue(IdVariable.EXCHANGE)
)
Expand Down
Loading