Skip to content

Commit

Permalink
Update cross-media-measurement-api for Requisition parent. (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas authored Jun 27, 2023
1 parent e2b3419 commit 7c2f9a1
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 514 deletions.
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 = "dd7467771a667c6586f7605b1b09a5e1ffaaa78beee40be55e77c3b7c52fd126",
version = "0.35.0",
sha256 = "8cb0e25bb0bcc2dae6d175613b6b8b827f6a48e15592399c9a5534a7b18b4d07",
version = "0.36.0",
)

wfa_repo_archive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
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

private val parser =
ResourceNameParser("measurementConsumers/{measurement_consumer}/measurements/{measurement}")

/** [ResourceKey] of a Measurement. */
data class MeasurementKey(val measurementConsumerId: String, val measurementId: String) :
ResourceKey {
data class MeasurementKey(
val measurementConsumerId: String,
val measurementId: String,
) : ChildResourceKey {
override val parentKey = MeasurementConsumerKey(measurementConsumerId)

override fun toName(): String {
return parser.assembleName(
mapOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 Requisition with a Measurement parent. */
data class MeasurementRequisitionKey(
val measurementConsumerId: String,
val measurementId: String,
val requisitionId: String
) : ChildResourceKey {
override val parentKey = MeasurementKey(measurementConsumerId, measurementId)

override fun toName(): String {
return parser.assembleName(
mapOf(
IdVariable.MEASUREMENT_CONSUMER to measurementConsumerId,
IdVariable.MEASUREMENT to measurementId,
IdVariable.REQUISITION to requisitionId
)
)
}

companion object FACTORY : ResourceKey.Factory<MeasurementRequisitionKey> {
private val parser =
ResourceNameParser(
"measurementConsumers/{measurement_consumer}/measurements/{measurement}/requisitions/{requisition}"
)

val defaultValue = MeasurementRequisitionKey("", "", "")

override fun fromName(resourceName: String): MeasurementRequisitionKey? {
val idVars = parser.parseIdVars(resourceName) ?: return null
return MeasurementRequisitionKey(
idVars.getValue(IdVariable.MEASUREMENT_CONSUMER),
idVars.getValue(IdVariable.MEASUREMENT),
idVars.getValue(IdVariable.REQUISITION)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@
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

private val parser = ResourceNameParser("dataProviders/{data_provider}/requisitions/{requisition}")

/** [ResourceKey] of a Requisition. */
data class RequisitionKey(val dataProviderId: String, val requisitionId: String) : ResourceKey {
data class RequisitionKey(
val dataProviderId: String,
val requisitionId: String,
) : ChildResourceKey {
override val parentKey = DataProviderKey(dataProviderId)

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

companion object FACTORY : ResourceKey.Factory<RequisitionKey> {
private val parser =
ResourceNameParser("dataProviders/{data_provider}/requisitions/{requisition}")

val defaultValue = RequisitionKey("", "")

override fun fromName(resourceName: String): RequisitionKey? {
Expand Down
Loading

0 comments on commit 7c2f9a1

Please sign in to comment.