Skip to content

Commit

Permalink
Update cross-media-measurement-api dep for DataProvider capabilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas committed Mar 15, 2024
1 parent ad99520 commit 4bf41f4
Show file tree
Hide file tree
Showing 13 changed files with 636 additions and 187 deletions.
10 changes: 9 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ bazel_dep(
)
bazel_dep(
name = "cross-media-measurement-api",
version = "0.60.0",
repo_name = "wfa_measurement_proto",
)
bazel_dep(
Expand Down Expand Up @@ -330,3 +329,12 @@ single_version_override(
module_name = "boringssl",
version = BORINGSSL_VERSION,
)

# TODO(world-federation-of-advertisers/cross-media-measurement-api#199): Use version.
archive_override(
module_name = "cross-media-measurement-api",
strip_prefix = "cross-media-measurement-api-8a1e491350d89333343dcca9f534cc68fbaf9736",
urls = [
"https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/8a1e491350d89333343dcca9f534cc68fbaf9736.tar.gz",
],
)
70 changes: 27 additions & 43 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ import org.wfanet.measurement.internal.kingdom.DataProvider
import org.wfanet.measurement.internal.kingdom.DataProvidersGrpcKt.DataProvidersCoroutineImplBase
import org.wfanet.measurement.internal.kingdom.GetDataProviderRequest
import org.wfanet.measurement.internal.kingdom.ReplaceDataAvailabilityIntervalRequest
import org.wfanet.measurement.internal.kingdom.ReplaceDataProviderCapabilitiesRequest
import org.wfanet.measurement.internal.kingdom.ReplaceDataProviderRequiredDuchiesRequest
import org.wfanet.measurement.internal.kingdom.batchGetDataProvidersResponse
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.common.DataProviderNotFoundException
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.common.KingdomInternalException
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.readers.DataProviderReader
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.writers.CreateDataProvider
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.writers.ReplaceDataAvailabilityInterval
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.writers.ReplaceDataProviderCapabilities
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.writers.ReplaceDataProviderRequiredDuchies

class SpannerDataProvidersService(
Expand Down Expand Up @@ -99,4 +101,16 @@ class SpannerDataProvidersService(
throw e.asStatusRuntimeException(Status.Code.NOT_FOUND, "DataProvider not found.")
}
}

override suspend fun replaceDataProviderCapabilities(
request: ReplaceDataProviderCapabilitiesRequest
): DataProvider {
grpcRequire(request.externalDataProviderId != 0L) { "external_data_provider_id is missing." }

try {
return ReplaceDataProviderCapabilities(request).execute(client, idGenerator)
} catch (e: DataProviderNotFoundException) {
throw e.asStatusRuntimeException(Status.Code.NOT_FOUND, "DataProvider not found.")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.kingdom.deploy.gcloud.spanner.writers

import org.wfanet.measurement.common.identity.ExternalId
import org.wfanet.measurement.gcloud.spanner.bufferUpdateMutation
import org.wfanet.measurement.gcloud.spanner.set
import org.wfanet.measurement.gcloud.spanner.setJson
import org.wfanet.measurement.internal.kingdom.DataProvider
import org.wfanet.measurement.internal.kingdom.ReplaceDataProviderCapabilitiesRequest
import org.wfanet.measurement.internal.kingdom.copy
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.common.DataProviderNotFoundException
import org.wfanet.measurement.kingdom.deploy.gcloud.spanner.readers.DataProviderReader

class ReplaceDataProviderCapabilities(private val request: ReplaceDataProviderCapabilitiesRequest) :
SpannerWriter<DataProvider, DataProvider>() {
override suspend fun TransactionScope.runTransaction(): DataProvider {
val externalDataProviderId = ExternalId(request.externalDataProviderId)
val dataProviderResult: DataProviderReader.Result =
DataProviderReader().readByExternalDataProviderId(transactionContext, externalDataProviderId)
?: throw DataProviderNotFoundException(externalDataProviderId)

val updatedDetails: DataProvider.Details =
dataProviderResult.dataProvider.details.copy { capabilities = request.capabilities }

transactionContext.bufferUpdateMutation("DataProviders") {
set("DataProviderId" to dataProviderResult.dataProviderId)
set("DataProviderDetails" to updatedDetails)
setJson("DataProviderDetailsJson" to updatedDetails)
}

return dataProviderResult.dataProvider.copy { details = updatedDetails }
}

override fun ResultScope<DataProvider>.buildResult(): DataProvider {
return checkNotNull(transactionResult)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ kt_jvm_library(
"//src/main/kotlin/org/wfanet/measurement/api:public_api_version",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:principal_server_interceptor",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:resource_key",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common:hmss_protocol_config",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common:llv2_protocol_config",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common:ro_llv2_protocol_config",
"//src/main/proto/wfa/measurement/api/v2alpha:crypto_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:differential_privacy_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:measurement_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:measurement_spec_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:measurements_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:page_token_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:protocol_config_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:data_providers_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:measurement_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:measurements_service_kt_jvm_grpc_proto",
"@wfa_common_jvm//imports/kotlin/kotlinx/coroutines:core",
Expand Down
Loading

0 comments on commit 4bf41f4

Please sign in to comment.