|
| 1 | +/* |
| 2 | + * Copyright 2023 Google LLC |
| 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.google.cloud.bigquery; |
| 18 | + |
| 19 | +import com.google.auto.value.AutoValue; |
| 20 | +import java.io.Serializable; |
| 21 | + |
| 22 | +@AutoValue |
| 23 | +public abstract class BigLakeConfiguration implements Serializable { |
| 24 | + |
| 25 | + private static final long serialVersionUID = -5951589238459622025L; |
| 26 | + |
| 27 | + /** |
| 28 | + * Credential reference for accessing external storage system. Normalized as |
| 29 | + * project_id.location_id.connection_id. |
| 30 | + * |
| 31 | + * @return value or {@code null} for none |
| 32 | + */ |
| 33 | + public abstract String getConnectionId(); |
| 34 | + |
| 35 | + /** |
| 36 | + * Open source file format that the table data is stored in. Currently only PARQUET is supported. |
| 37 | + * |
| 38 | + * @return value or {@code null} for none |
| 39 | + */ |
| 40 | + public abstract String getFileFormat(); |
| 41 | + |
| 42 | + /** |
| 43 | + * Fully qualified location prefix of the external folder where data is stored. Starts with |
| 44 | + * "gs://" ends with "/". Does not contain "*". |
| 45 | + * |
| 46 | + * @return value or {@code null} for none |
| 47 | + */ |
| 48 | + public abstract String getStorageUri(); |
| 49 | + |
| 50 | + /** |
| 51 | + * Open source file format that the table data is stored in. Currently only PARQUET is supported. |
| 52 | + * |
| 53 | + * @return value or {@code null} for none |
| 54 | + */ |
| 55 | + public abstract String getTableFormat(); |
| 56 | + |
| 57 | + public static Builder newBuilder() { |
| 58 | + return new AutoValue_BigLakeConfiguration.Builder(); |
| 59 | + } |
| 60 | + |
| 61 | + public abstract Builder toBuilder(); |
| 62 | + |
| 63 | + @AutoValue.Builder |
| 64 | + public abstract static class Builder { |
| 65 | + /** |
| 66 | + * [Required] Required and immutable. Credential reference for accessing external storage |
| 67 | + * system. Normalized as project_id.location_id.connection_id. |
| 68 | + * |
| 69 | + * @param connectionId connectionId or {@code null} for none |
| 70 | + */ |
| 71 | + public abstract Builder setConnectionId(String connectionId); |
| 72 | + |
| 73 | + /** |
| 74 | + * [Required] Required and immutable. Open source file format that the table data is stored in. |
| 75 | + * Currently only PARQUET is supported. |
| 76 | + * |
| 77 | + * @param fileFormat fileFormat or {@code null} for none |
| 78 | + */ |
| 79 | + public abstract Builder setFileFormat(String fileFormat); |
| 80 | + |
| 81 | + /** |
| 82 | + * [Required] Required and immutable. Fully qualified location prefix of the external folder |
| 83 | + * where data is stored. Starts with "gs://" and ends with "/". Does not contain "*". |
| 84 | + * |
| 85 | + * @param storageUri storageUri or {@code null} for none |
| 86 | + */ |
| 87 | + public abstract Builder setStorageUri(String storageUri); |
| 88 | + |
| 89 | + /** |
| 90 | + * [Required] Required and immutable. Open source file format that the table data is stored in. |
| 91 | + * Currently only PARQUET is supported. |
| 92 | + * |
| 93 | + * @param tableFormat tableFormat or {@code null} for none |
| 94 | + */ |
| 95 | + public abstract Builder setTableFormat(String tableFormat); |
| 96 | + |
| 97 | + public abstract BigLakeConfiguration build(); |
| 98 | + } |
| 99 | + |
| 100 | + com.google.api.services.bigquery.model.BigLakeConfiguration toPb() { |
| 101 | + com.google.api.services.bigquery.model.BigLakeConfiguration biglakeConfiguration = |
| 102 | + new com.google.api.services.bigquery.model.BigLakeConfiguration(); |
| 103 | + biglakeConfiguration.setConnectionId(getConnectionId()); |
| 104 | + biglakeConfiguration.setFileFormat(getFileFormat()); |
| 105 | + biglakeConfiguration.setStorageUri(getStorageUri()); |
| 106 | + biglakeConfiguration.setTableFormat(getTableFormat()); |
| 107 | + |
| 108 | + return biglakeConfiguration; |
| 109 | + } |
| 110 | + |
| 111 | + static BigLakeConfiguration fromPb( |
| 112 | + com.google.api.services.bigquery.model.BigLakeConfiguration biglakeConfigurationPb) { |
| 113 | + return newBuilder() |
| 114 | + .setConnectionId(biglakeConfigurationPb.getConnectionId()) |
| 115 | + .setFileFormat(biglakeConfigurationPb.getFileFormat()) |
| 116 | + .setStorageUri(biglakeConfigurationPb.getStorageUri()) |
| 117 | + .setTableFormat(biglakeConfigurationPb.getTableFormat()) |
| 118 | + .build(); |
| 119 | + } |
| 120 | +} |
0 commit comments