1 /*
2  * Copyright (C) 2024 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.service.stats;
18 
19 import static com.android.adservices.service.stats.AdServicesLoggerUtil.FIELD_UNSET;
20 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.JS_RUN_STATUS_UNSET;
21 
22 import com.google.auto.value.AutoValue;
23 
24 /** Class for SelectAdsFromOutcomes API Called stats */
25 @AutoValue
26 public abstract class SelectAdsFromOutcomesApiCalledStats {
27 
28     /** Number of IDs passed to the mediation call */
getCountIds()29     public abstract int getCountIds();
30 
31     /** Number of non-existing IDs during mediation call */
getCountNonExistingIds()32     public abstract int getCountNonExistingIds();
33 
34     /** Whether the truncation API call used a prebuilt script */
getUsedPrebuilt()35     public abstract boolean getUsedPrebuilt();
36 
37     /** Mediation script download result code */
getDownloadResultCode()38     public abstract int getDownloadResultCode();
39 
40     /** Mediation script download latency in milliseconds */
getDownloadLatencyMillis()41     public abstract int getDownloadLatencyMillis();
42 
43     /** Mediation script execution result code */
44     @AdsRelevanceStatusUtils.JsRunStatus
getExecutionResultCode()45     public abstract int getExecutionResultCode();
46 
47     /** Mediation script execution latency in milliseconds */
getExecutionLatencyMillis()48     public abstract int getExecutionLatencyMillis();
49 
50     /** Returns a generic builder. */
builder()51     public static Builder builder() {
52         return new AutoValue_SelectAdsFromOutcomesApiCalledStats.Builder()
53                 .setCountIds(FIELD_UNSET)
54                 .setCountNonExistingIds(FIELD_UNSET)
55                 .setDownloadResultCode(FIELD_UNSET)
56                 .setDownloadLatencyMillis(FIELD_UNSET)
57                 .setExecutionResultCode(JS_RUN_STATUS_UNSET)
58                 .setExecutionLatencyMillis(FIELD_UNSET);
59     }
60 
61     /** Builder class for SelectAdsFromOutcomesApiCalledStats. */
62     @AutoValue.Builder
63     public abstract static class Builder {
64         /** Sets the number of IDs passed to the mediation call */
setCountIds(int countIds)65         public abstract Builder setCountIds(int countIds);
66 
67         /** Sets the number of non-existing IDs during mediation call */
setCountNonExistingIds(int countNonExistingIds)68         public abstract Builder setCountNonExistingIds(int countNonExistingIds);
69 
70         /** Sets whether the truncation API call used a prebuilt script */
setUsedPrebuilt(boolean usedPrebuilt)71         public abstract Builder setUsedPrebuilt(boolean usedPrebuilt);
72 
73         /** Sets the mediation script download result code */
setDownloadResultCode(int downloadResultCode)74         public abstract Builder setDownloadResultCode(int downloadResultCode);
75 
76         /** Sets the mediation script download latency in milliseconds */
setDownloadLatencyMillis(int downloadLatencyMillis)77         public abstract Builder setDownloadLatencyMillis(int downloadLatencyMillis);
78 
79         /** Sets the mediation script execution result code */
setExecutionResultCode( @dsRelevanceStatusUtils.JsRunStatus int executionResultCode)80         public abstract Builder setExecutionResultCode(
81                 @AdsRelevanceStatusUtils.JsRunStatus int executionResultCode);
82 
83         /** Sets the mediation script execution latency in milliseconds */
setExecutionLatencyMillis(int executionLatencyMillis)84         public abstract Builder setExecutionLatencyMillis(int executionLatencyMillis);
85 
86         /** Builds the {@link SelectAdsFromOutcomesApiCalledStats} object. */
build()87         public abstract SelectAdsFromOutcomesApiCalledStats build();
88     }
89 }
90