Repository navigation
Expand file tree
/
Copy pathCopyJobConfiguration.php
More file actions
156 lines (143 loc) · 4.75 KB
/
Copy pathCopyJobConfiguration.php
File metadata and controls
156 lines (143 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
* 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.
*/
namespace Google\Cloud\BigQuery;
/**
* Represents a configuration for a copy job. For more information on the
* available settings please see the
* [Jobs configuration API documentation](https://cloud.google.com/bigquery/docs/reference/rest/v2/Job).
*
* Example:
* ```
* use Google\Cloud\BigQuery\BigQueryClient;
*
* $bigQuery = new BigQueryClient();
* $sourceTable = $bigQuery->dataset('my_dataset')
* ->table('my_source_table');
* $destinationTable = $bigQuery->dataset('my_dataset')
* ->table('my_destination_table');
*
* $copyJobConfig = $sourceTable->copy($destinationTable);
* ```
*/
class CopyJobConfiguration implements JobConfigurationInterface
{
use JobConfigurationTrait;
/**
* @param string $projectId The project's ID.
* @param array $config A set of configuration options for a job.
* @param string|null $location The geographic location in which the job is
* executed.
*/
public function __construct($projectId, array $config, $location)
{
$this->jobConfigurationProperties($projectId, $config, $location);
}
/**
* Set whether the job is allowed to create new tables. Creation, truncation
* and append actions occur as one atomic update upon job completion.
*
* Example:
* ```
* $copyJobConfig->createDisposition('CREATE_NEVER');
* ```
*
* @param string $createDisposition The create disposition. Acceptable
* values include `"CREATED_IF_NEEDED"`, `"CREATE_NEVER"`. **Defaults
* to** `"CREATE_IF_NEEDED"`.
* @return CopyJobConfiguration
*/
public function createDisposition($createDisposition)
{
$this->config['configuration']['copy']['createDisposition'] = $createDisposition;
return $this;
}
/**
* Sets the custom encryption configuration (e.g., Cloud KMS keys).
*
* Example:
* ```
* $copyJobConfig->destinationEncryptionConfiguration([
* 'kmsKeyName' => 'my_key'
* ]);
* ```
*
* @param array $configuration Custom encryption configuration.
* @return CopyJobConfiguration
*/
public function destinationEncryptionConfiguration(array $configuration)
{
$this->config['configuration']['copy']['destinationEncryptionConfiguration'] = $configuration;
return $this;
}
/**
* Sets the destination table.
*
* Example:
* ```
* $table = $bigQuery->dataset('my_dataset')
* ->table('my_table');
* $copyJobConfig->destinationTable($table);
* ```
*
* @param Table $destinationTable The destination table.
* @return CopyJobConfiguration
*/
public function destinationTable(Table $destinationTable)
{
$this->config['configuration']['copy']['destinationTable'] = $destinationTable->identity();
return $this;
}
/**
* Sets the source table to copy.
*
* Example:
* ```
* $table = $bigQuery->dataset('my_dataset')
* ->table('source_table');
* $copyJobConfig->sourceTable($table);
* ```
*
* @param Table $sourceTable The destination table.
* @return CopyJobConfiguration
*/
public function sourceTable(Table $sourceTable)
{
$this->config['configuration']['copy']['sourceTable'] = $sourceTable->identity();
return $this;
}
/**
* Sets the action that occurs if the destination table already exists. Each
* action is atomic and only occurs if BigQuery is able to complete the job
* successfully. Creation, truncation and append actions occur as one atomic
* update upon job completion.
*
* Example:
* ```
* $copyJobConfig->writeDisposition('WRITE_TRUNCATE');
* ```
*
* @param string $writeDisposition The write disposition. Acceptable values
* include `"WRITE_TRUNCATE"`, `"WRITE_APPEND"`, `"WRITE_EMPTY"`.
* **Defaults to** `"WRITE_EMPTY"`.
* @return CopyJobConfiguration
*/
public function writeDisposition($writeDisposition)
{
$this->config['configuration']['copy']['writeDisposition'] = $writeDisposition;
return $this;
}
}