1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.data.signals; 18 19 import android.adservices.common.AdTechIdentifier; 20 import android.net.Uri; 21 22 import androidx.annotation.NonNull; 23 import androidx.room.ColumnInfo; 24 import androidx.room.Entity; 25 import androidx.room.PrimaryKey; 26 27 import com.google.auto.value.AutoValue; 28 29 import java.time.Instant; 30 31 /** End-point provided by Ad tech to download their encoding logic. */ 32 @AutoValue 33 @AutoValue.CopyAnnotations 34 @Entity(tableName = DBEncoderEndpoint.TABLE_NAME, inheritSuperIndices = true) 35 public abstract class DBEncoderEndpoint { 36 37 public static final String TABLE_NAME = "encoder_endpoints"; 38 39 /** The ad-tech buyer associated with the signals that would be encoded */ 40 @AutoValue.CopyAnnotations 41 @ColumnInfo(name = "buyer") 42 @PrimaryKey 43 @NonNull getBuyer()44 public abstract AdTechIdentifier getBuyer(); 45 46 /** uri pointing to the encoding logic provided by the buyer during signals fetch */ 47 @AutoValue.CopyAnnotations 48 @ColumnInfo(name = "download_uri") 49 @NonNull getDownloadUri()50 public abstract Uri getDownloadUri(); 51 52 /** 53 * @return a builder for creating a {@link DBEncoderEndpoint} 54 */ 55 @NonNull builder()56 public static DBEncoderEndpoint.Builder builder() { 57 return new AutoValue_DBEncoderEndpoint.Builder(); 58 } 59 60 /** The time at which this entry for encoding end-point was created */ 61 @AutoValue.CopyAnnotations 62 @ColumnInfo(name = "creation_time", index = true) 63 @androidx.annotation.NonNull getCreationTime()64 public abstract Instant getCreationTime(); 65 66 /** 67 * @param buyer see {@link #getBuyer()} 68 * @param downloadUri see {@link #getDownloadUri()} 69 * @param creationTime {@link #getCreationTime()} 70 * @return an instance of {@link DBEncoderEndpoint} 71 */ create( @onNull AdTechIdentifier buyer, @NonNull Uri downloadUri, @NonNull Instant creationTime)72 public static DBEncoderEndpoint create( 73 @NonNull AdTechIdentifier buyer, 74 @NonNull Uri downloadUri, 75 @NonNull Instant creationTime) { 76 77 return builder() 78 .setBuyer(buyer) 79 .setDownloadUri(downloadUri) 80 .setCreationTime(creationTime) 81 .build(); 82 } 83 84 /** Provides a builder to create an instance of {@link DBEncoderEndpoint} */ 85 @AutoValue.Builder 86 public abstract static class Builder { 87 88 /** For more details see {@link #getBuyer()} */ setBuyer(@onNull AdTechIdentifier value)89 public abstract Builder setBuyer(@NonNull AdTechIdentifier value); 90 91 /** For more details see {@link #getDownloadUri()} */ setDownloadUri(@onNull Uri value)92 public abstract Builder setDownloadUri(@NonNull Uri value); 93 94 /** For more details see {@link #getCreationTime()} */ setCreationTime(@onNull Instant value)95 public abstract Builder setCreationTime(@NonNull Instant value); 96 97 /** 98 * @return an instance of {@link DBEncoderEndpoint} 99 */ build()100 public abstract DBEncoderEndpoint build(); 101 } 102 } 103