-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update cross-media-measurement-api for EventGroup pattern.
- Loading branch information
Showing
22 changed files
with
773 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/org/wfanet/measurement/api/v2alpha/MeasurementConsumerEventGroupKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 an EventGroup with a MeasurementConsumer as the parent. */ | ||
data class MeasurementConsumerEventGroupKey( | ||
val measurementConsumerId: String, | ||
val eventGroupId: String | ||
) : ChildResourceKey { | ||
override fun toName(): String { | ||
return parser.assembleName( | ||
mapOf( | ||
IdVariable.MEASUREMENT_CONSUMER to measurementConsumerId, | ||
IdVariable.EVENT_GROUP to eventGroupId | ||
) | ||
) | ||
} | ||
|
||
override val parentKey = MeasurementConsumerKey(measurementConsumerId) | ||
|
||
companion object FACTORY : ResourceKey.Factory<MeasurementConsumerEventGroupKey> { | ||
private val parser = | ||
ResourceNameParser("measurementConsumers/{measurement_consumer}/eventGroups/{event_group}") | ||
|
||
val defaultValue = MeasurementConsumerEventGroupKey("", "") | ||
|
||
override fun fromName(resourceName: String): MeasurementConsumerEventGroupKey? { | ||
return parser.parseIdVars(resourceName)?.let { | ||
MeasurementConsumerEventGroupKey( | ||
it.getValue(IdVariable.MEASUREMENT_CONSUMER), | ||
it.getValue(IdVariable.EVENT_GROUP) | ||
) | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/org/wfanet/measurement/api/v2alpha/MeasurementRequisitionKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 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 | ||
|
||
private val parser = ResourceNameParser("dataProviders/{data_provider}/requisitions/{requisition}") | ||
|
||
/** [ResourceKey] of a Requisition. */ | ||
data class RequisitionKey(val dataProviderId: String, val requisitionId: String) : ResourceKey { | ||
override fun toName(): String { | ||
return parser.assembleName( | ||
mapOf(IdVariable.DATA_PROVIDER to dataProviderId, IdVariable.REQUISITION to requisitionId) | ||
) | ||
} | ||
|
||
companion object FACTORY : ResourceKey.Factory<RequisitionKey> { | ||
val defaultValue = RequisitionKey("", "") | ||
|
||
override fun fromName(resourceName: String): RequisitionKey? { | ||
return parser.parseIdVars(resourceName)?.let { | ||
RequisitionKey(it.getValue(IdVariable.DATA_PROVIDER), it.getValue(IdVariable.REQUISITION)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.