gooddata 2.1.14 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/.gdc-ii-config.yaml +1 -1
  3. data/.github/workflows/build.yml +66 -0
  4. data/.github/workflows/pre-merge.yml +72 -0
  5. data/.sonar.settings +4 -0
  6. data/.travis.yml +78 -12
  7. data/CHANGELOG.md +62 -0
  8. data/Dockerfile +25 -14
  9. data/LICENSE +4418 -17
  10. data/LICENSE.rb +1 -1
  11. data/README.md +3 -3
  12. data/Rakefile +8 -1
  13. data/SDK_VERSION +1 -1
  14. data/VERSION +1 -1
  15. data/bin/test_projects_cleanup.rb +45 -3
  16. data/ci/mssql/pom.xml +62 -0
  17. data/ci/mysql/pom.xml +57 -0
  18. data/ci/postgresql/pom.xml +57 -0
  19. data/ci/redshift/pom.xml +1 -1
  20. data/dev-gooddata-sso.pub.encrypted +40 -40
  21. data/gdc_fossa_ruby_sdk.yaml +1 -0
  22. data/gooddata.gemspec +10 -6
  23. data/k8s/charts/lcm-bricks/Chart.yaml +1 -1
  24. data/k8s/charts/lcm-bricks/templates/prometheus/alertingRules.yaml +11 -1
  25. data/lcm.rake +2 -2
  26. data/lib/gooddata/bricks/middleware/aws_middleware.rb +35 -9
  27. data/lib/gooddata/cloud_resources/blobstorage/blobstorage_client.rb +98 -0
  28. data/lib/gooddata/cloud_resources/{cloud_resouce_factory.rb → cloud_resource_factory.rb} +8 -0
  29. data/lib/gooddata/cloud_resources/cloud_resources.rb +1 -1
  30. data/lib/gooddata/cloud_resources/mssql/drivers/.gitkeepme +0 -0
  31. data/lib/gooddata/cloud_resources/mssql/mssql_client.rb +122 -0
  32. data/lib/gooddata/cloud_resources/mysql/drivers/.gitkeepme +0 -0
  33. data/lib/gooddata/cloud_resources/mysql/mysql_client.rb +111 -0
  34. data/lib/gooddata/cloud_resources/postgresql/drivers/.gitkeepme +0 -0
  35. data/lib/gooddata/cloud_resources/postgresql/postgresql_client.rb +106 -0
  36. data/lib/gooddata/cloud_resources/snowflake/snowflake_client.rb +18 -1
  37. data/lib/gooddata/commands/scaffold.rb +9 -10
  38. data/lib/gooddata/core/nil_logger.rb +3 -1
  39. data/lib/gooddata/helpers/data_helper.rb +9 -5
  40. data/lib/gooddata/helpers/global_helpers.rb +6 -5
  41. data/lib/gooddata/lcm/actions/associate_clients.rb +8 -2
  42. data/lib/gooddata/lcm/actions/base_action.rb +0 -2
  43. data/lib/gooddata/lcm/actions/collect_meta.rb +3 -1
  44. data/lib/gooddata/lcm/actions/migrate_gdc_date_dimension.rb +3 -2
  45. data/lib/gooddata/lcm/actions/provision_clients.rb +31 -10
  46. data/lib/gooddata/lcm/actions/synchronize_clients.rb +56 -7
  47. data/lib/gooddata/lcm/actions/synchronize_dataset_mappings.rb +64 -0
  48. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +19 -8
  49. data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +16 -9
  50. data/lib/gooddata/lcm/actions/synchronize_users.rb +7 -6
  51. data/lib/gooddata/lcm/actions/update_metric_formats.rb +185 -0
  52. data/lib/gooddata/lcm/data/delete_from_lcm_release.sql.erb +5 -0
  53. data/lib/gooddata/lcm/helpers/release_table_helper.rb +42 -8
  54. data/lib/gooddata/lcm/lcm2.rb +5 -2
  55. data/lib/gooddata/lcm/types/base_type.rb +0 -2
  56. data/lib/gooddata/mixins/md_object_query.rb +9 -6
  57. data/lib/gooddata/models/blueprint/project_blueprint.rb +0 -2
  58. data/lib/gooddata/models/client.rb +14 -12
  59. data/lib/gooddata/models/data_source.rb +668 -0
  60. data/lib/gooddata/models/dataset_mapping.rb +36 -0
  61. data/lib/gooddata/models/domain.rb +3 -2
  62. data/lib/gooddata/models/metadata/analytical_dashboard.rb +49 -0
  63. data/lib/gooddata/models/metadata/analytical_visualization_object.rb +30 -0
  64. data/lib/gooddata/models/metadata/label.rb +26 -27
  65. data/lib/gooddata/models/metadata/visualization_object.rb +50 -0
  66. data/lib/gooddata/models/project.rb +66 -19
  67. data/lib/gooddata/models/schedule.rb +13 -1
  68. data/lib/gooddata/models/user_filters/user_filter_builder.rb +58 -54
  69. data/lib/gooddata/models/user_group.rb +0 -1
  70. data/lib/gooddata/rest/connection.rb +6 -4
  71. data/lib/gooddata/rest/phmap.rb +2 -1
  72. data/lib/gooddata.rb +2 -0
  73. data/rubydev_public.gpg.encrypted +51 -51
  74. data/rubydev_secret_keys.gpg.encrypted +109 -109
  75. metadata +52 -27
  76. data/DEPENDENCIES.md +0 -880
  77. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +0 -37
  78. data/lib/gooddata/helpers/data_source_helpers.rb +0 -47
@@ -0,0 +1,668 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+ #
4
+ # Copyright (c) 2010-2021 GoodData Corporation. All rights reserved.
5
+ # This source code is licensed under the BSD-style license found in the
6
+ # LICENSE file in the root directory of this source tree.
7
+
8
+ require_relative '../rest/resource'
9
+
10
+ module GoodData
11
+ class DataSource < Rest::Resource
12
+ attr_accessor :connection_info
13
+
14
+ DATA_SOURCES_URL = '/gdc/dataload/dataSources'
15
+ SNOWFLAKE = 'snowflake'
16
+ REDSHIFT = 'redshift'
17
+ BIGQUERY = 'bigQuery'
18
+ GENERIC = 'generic'
19
+ S3 = 's3'
20
+ ADS = 'ads'
21
+ ERROR_MESSAGE_NO_SCHEMA = 'Data source schema has to be provided'
22
+
23
+ class << self
24
+ # Get all data sources or get a specify data source from data source identify
25
+ # Expected parameter value:
26
+ # - :all return all data sources
27
+ # - :data_source_id return a data source with the specify data source identify
28
+ def [](id = :all, options = { client: GoodData.client })
29
+ c = GoodData.get_client(options)
30
+
31
+ if id == :all
32
+ data = c.get(DATA_SOURCES_URL)
33
+ data['dataSources']['items'].map do |ds_data|
34
+ c.create(DataSource, ds_data)
35
+ end
36
+ else
37
+ c.create(DataSource, c.get(DATA_SOURCES_URL + '/' + id))
38
+ end
39
+ end
40
+
41
+ # Get a specify data source from data source identify
42
+ #
43
+ # @param [String] id Data source identify
44
+ # @return [DataSource] Data source corresponding in backend or throw exception if the data source identify doesn't exist
45
+ def from_id(id, options = { client: GoodData.client })
46
+ DataSource[id, options]
47
+ end
48
+
49
+ # Get a specify data source from data source alias
50
+ #
51
+ # @param [String] data_source_alias Data source alias
52
+ # @return [DataSource] Data source corresponding in backend or throw exception if the data source alias doesn't exist
53
+ def from_alias(data_source_alias, options = { client: GoodData.client })
54
+ data_sources = all(options)
55
+ result = data_sources.find do |data_source|
56
+ data_source.alias == data_source_alias
57
+ end
58
+ fail "Data source alias '#{data_source_alias}' has not found" unless result
59
+
60
+ result
61
+ end
62
+
63
+ # Get all data sources
64
+ def all(options = { client: GoodData.client })
65
+ DataSource[:all, options]
66
+ end
67
+
68
+ # Create data source from json
69
+ # Expected keys:
70
+ # - :name (mandatory)
71
+ # - :alias (optional)
72
+ # - :prefix (optional)
73
+ # - :connectionInfo (mandatory)
74
+ # - :client (mandatory)
75
+ def create(opts)
76
+ ds_name = opts[:name]
77
+ ds_alias = opts[:alias]
78
+ ds_prefix = opts[:prefix]
79
+ ds_connection_info = opts[:connectionInfo]
80
+
81
+ GoodData.logger.info "Creating data source '#{ds_name}'"
82
+ fail ArgumentError, 'Data source name has to be provided' if ds_name.nil? || ds_name.blank?
83
+ fail ArgumentError, 'Data source connection info has to be provided' if ds_connection_info.nil?
84
+
85
+ json = {
86
+ 'dataSource' => {
87
+ 'name' => ds_name,
88
+ 'connectionInfo' => ds_connection_info
89
+ }
90
+ }
91
+ json['dataSource']['alias'] = ds_alias if ds_alias
92
+ json['dataSource']['prefix'] = ds_prefix if ds_prefix
93
+
94
+ # Create data source
95
+ c = GoodData.get_client(opts)
96
+ res = c.post(DATA_SOURCES_URL, json)
97
+
98
+ # create the public facing object
99
+ c.create(DataSource, res)
100
+ end
101
+ end
102
+
103
+ # Save data source to backend. The saving will validate existing data source name and connection info. So need set
104
+ # values for them.
105
+ #
106
+ # Input info:
107
+ # - :name (mandatory)
108
+ # - :alias (optional)
109
+ # - :prefix (optional)
110
+ # - :connectionInfo (mandatory)
111
+ #
112
+ # Return: create data source in backend and return data source object corresponding with data source in backend.
113
+ def save
114
+ validate
115
+ validate_connection_info
116
+ if saved?
117
+ update_obj_json = client.put(uri, to_update_payload)
118
+ @json = update_obj_json
119
+ else
120
+ res = client.post(DATA_SOURCES_URL, to_update_payload)
121
+ fail 'Unable to create new Data Source' if res.nil?
122
+
123
+ @json = res
124
+ end
125
+ @connection_info = build_connection_info
126
+ self
127
+ end
128
+
129
+ def delete
130
+ saved? ? client.delete(uri) : nil
131
+ end
132
+
133
+ def initialize(json)
134
+ super
135
+ @json = json
136
+ validate
137
+ @connection_info = build_connection_info
138
+ end
139
+
140
+ def saved?
141
+ !uri.blank?
142
+ end
143
+
144
+ def name
145
+ @json['dataSource']['name']
146
+ end
147
+
148
+ def name=(new_name)
149
+ @json['dataSource']['name'] = new_name
150
+ end
151
+
152
+ def alias
153
+ @json['dataSource']['alias']
154
+ end
155
+
156
+ def alias=(new_alias)
157
+ @json['dataSource']['alias'] = new_alias
158
+ end
159
+
160
+ def prefix
161
+ @json['dataSource']['prefix']
162
+ end
163
+
164
+ def prefix=(new_prefix)
165
+ @json['dataSource']['prefix'] = new_prefix
166
+ end
167
+
168
+ def uri
169
+ @json['dataSource']['links']['self'] if @json && @json['dataSource'] && @json['dataSource']['links']
170
+ end
171
+
172
+ def id
173
+ uri.split('/')[-1]
174
+ end
175
+
176
+ def is(type)
177
+ @json['dataSource']['connectionInfo'][type]
178
+ end
179
+
180
+ def type
181
+ @json['dataSource']['connectionInfo'].first[0].upcase
182
+ end
183
+
184
+ private
185
+
186
+ def build_connection_info
187
+ return snowflake_connection_info if is(SNOWFLAKE)
188
+ return redshift_connection_info if is(REDSHIFT)
189
+ return bigquery_connection_info if is(BIGQUERY)
190
+ return generic_connection_info if is(GENERIC)
191
+ return s3_connection_info if is(S3)
192
+ return ads_connection_info if is(ADS)
193
+
194
+ # In case don't know data source type then support get or set directly json data for connection info
195
+ ConnectionInfo.new(@json['dataSource']['connectionInfo'])
196
+ end
197
+
198
+ def support_connection_info(connection_info)
199
+ [SnowflakeConnectionInfo, RedshiftConnectionInfo, BigQueryConnectionInfo,
200
+ GenericConnectionInfo, S3ConnectionInfo, AdsConnectionInfo].include? connection_info.class
201
+ end
202
+
203
+ def snowflake_connection_info
204
+ return nil unless is(SNOWFLAKE)
205
+
206
+ SnowflakeConnectionInfo.new(@json['dataSource']['connectionInfo'])
207
+ end
208
+
209
+ def redshift_connection_info
210
+ return nil unless is(REDSHIFT)
211
+
212
+ RedshiftConnectionInfo.new(@json['dataSource']['connectionInfo'])
213
+ end
214
+
215
+ def bigquery_connection_info
216
+ return nil unless is(BIGQUERY)
217
+
218
+ BigQueryConnectionInfo.new(@json['dataSource']['connectionInfo'])
219
+ end
220
+
221
+ def generic_connection_info
222
+ return nil unless is(GENERIC)
223
+
224
+ GenericConnectionInfo.new(@json['dataSource']['connectionInfo'])
225
+ end
226
+
227
+ def s3_connection_info
228
+ return nil unless is(S3)
229
+
230
+ S3ConnectionInfo.new(@json['dataSource']['connectionInfo'])
231
+ end
232
+
233
+ def ads_connection_info
234
+ return nil unless is(ADS)
235
+
236
+ AdsConnectionInfo.new(@json['dataSource']['connectionInfo'])
237
+ end
238
+
239
+ def to_update_payload
240
+ json_data = {
241
+ 'dataSource' => {
242
+ 'name' => name,
243
+ 'connectionInfo' => @connection_info.to_update_payload
244
+ }
245
+ }
246
+ json_data['dataSource']['alias'] = self.alias if self.alias
247
+ json_data['dataSource']['prefix'] = prefix if prefix
248
+ json_data
249
+ end
250
+
251
+ def validate
252
+ fail 'Invalid data source json data' unless @json['dataSource']
253
+ fail 'Data source connection info has to be provided' unless @json['dataSource']['connectionInfo']
254
+ fail 'Data source name has to be provided' if name.nil? || name.blank?
255
+ end
256
+
257
+ def validate_connection_info
258
+ @connection_info.validate
259
+ end
260
+
261
+ class ConnectionInfo < Rest::Resource
262
+ def initialize(connection_info_json)
263
+ @json = connection_info_json
264
+ end
265
+
266
+ def connection_info
267
+ @json
268
+ end
269
+
270
+ def connection_info=(connection_info_json)
271
+ @json = connection_info_json
272
+ end
273
+
274
+ def to_update_payload
275
+ @json
276
+ end
277
+
278
+ # Abstract function
279
+ def validate
280
+ end
281
+ end
282
+
283
+ class SnowflakeConnectionInfo < ConnectionInfo
284
+ def initialize(connection_info_json)
285
+ @json = connection_info_json[GoodData::DataSource::SNOWFLAKE]
286
+ end
287
+
288
+ def url
289
+ @json['url']
290
+ end
291
+
292
+ def url=(new_url)
293
+ @json['url'] = new_url
294
+ end
295
+
296
+ def user_name
297
+ @json['authentication']['basic']['userName'] if @json && @json['authentication'] && @json['authentication']['basic']
298
+ end
299
+
300
+ def user_name=(new_user_name)
301
+ @json['authentication']['basic']['userName'] = new_user_name
302
+ end
303
+
304
+ def password
305
+ @json['authentication']['basic']['password'] if @json && @json['authentication'] && @json['authentication']['basic']
306
+ end
307
+
308
+ def password=(new_password)
309
+ @json['authentication']['basic']['password'] = new_password
310
+ end
311
+
312
+ def database
313
+ @json['database']
314
+ end
315
+
316
+ def database=(new_database)
317
+ @json['database'] = new_database
318
+ end
319
+
320
+ def schema
321
+ @json['schema']
322
+ end
323
+
324
+ def schema=(new_schema)
325
+ @json['schema'] = new_schema
326
+ end
327
+
328
+ def warehouse
329
+ @json['warehouse']
330
+ end
331
+
332
+ def warehouse=(new_warehouse)
333
+ @json['warehouse'] = new_warehouse
334
+ end
335
+
336
+ def to_update_payload
337
+ {
338
+ 'snowflake' => {
339
+ 'url' => url,
340
+ 'authentication' => {
341
+ 'basic' => {
342
+ 'userName' => user_name,
343
+ 'password' => password
344
+ }
345
+ },
346
+ 'database' => database,
347
+ 'schema' => schema,
348
+ 'warehouse' => warehouse
349
+ }
350
+ }
351
+ end
352
+
353
+ def validate
354
+ fail 'Data source url has to be provided' if url.nil? || url.blank?
355
+ fail 'Data source database has to be provided' if database.nil? || database.blank?
356
+ fail ERROR_MESSAGE_NO_SCHEMA if schema.nil? || schema.blank?
357
+ fail 'Data source warehouse has to be provided' if warehouse.nil? || warehouse.blank?
358
+ fail 'Data source username has to be provided' if user_name.nil? || user_name.blank?
359
+ end
360
+ end
361
+
362
+ class RedshiftConnectionInfo < ConnectionInfo
363
+ def initialize(connection_info_json)
364
+ @json = connection_info_json[GoodData::DataSource::REDSHIFT]
365
+ end
366
+
367
+ def url
368
+ @json['url']
369
+ end
370
+
371
+ def url=(new_url)
372
+ @json['url'] = new_url
373
+ end
374
+
375
+ def user_name
376
+ @json['authentication']['basic']['userName'] if basic_authentication
377
+ end
378
+
379
+ def user_name=(new_user_name)
380
+ @json['authentication']['basic']['userName'] = new_user_name
381
+ end
382
+
383
+ def password
384
+ @json['authentication']['basic']['password'] if basic_authentication
385
+ end
386
+
387
+ def password=(new_password)
388
+ @json['authentication']['basic']['password'] = new_password
389
+ end
390
+
391
+ def db_user
392
+ @json['authentication']['iam']['dbUser'] if iam_authentication
393
+ end
394
+
395
+ def db_user=(new_db_user)
396
+ @json['authentication']['iam']['dbUser'] = new_db_user
397
+ end
398
+
399
+ def access_key_id
400
+ @json['authentication']['iam']['accessKeyId'] if iam_authentication
401
+ end
402
+
403
+ def access_key_id=(new_access_key_id)
404
+ @json['authentication']['iam']['accessKeyId'] = new_access_key_id
405
+ end
406
+
407
+ def secret_access_key
408
+ @json['authentication']['iam']['secretAccessKey'] if iam_authentication
409
+ end
410
+
411
+ def secret_access_key=(new_secret_access_key)
412
+ @json['authentication']['iam']['secretAccessKey'] = new_secret_access_key
413
+ end
414
+
415
+ def basic_authentication
416
+ @json && @json['authentication'] && @json['authentication']['basic']
417
+ end
418
+
419
+ def iam_authentication
420
+ @json && @json['authentication'] && @json['authentication']['iam']
421
+ end
422
+
423
+ def database
424
+ @json['database']
425
+ end
426
+
427
+ def database=(new_database)
428
+ @json['database'] = new_database
429
+ end
430
+
431
+ def schema
432
+ @json['schema']
433
+ end
434
+
435
+ def schema=(new_schema)
436
+ @json['schema'] = new_schema
437
+ end
438
+
439
+ def to_update_payload
440
+ if basic_authentication
441
+ {
442
+ 'redshift' => {
443
+ 'url' => url,
444
+ 'authentication' => {
445
+ 'basic' => {
446
+ 'userName' => user_name,
447
+ 'password' => password
448
+ }
449
+ },
450
+ 'database' => database,
451
+ 'schema' => schema
452
+ }
453
+ }
454
+ else
455
+ {
456
+ 'redshift' => {
457
+ 'url' => url,
458
+ 'authentication' => {
459
+ 'iam' => {
460
+ 'dbUser' => db_user,
461
+ 'accessKeyId' => access_key_id,
462
+ 'secretAccessKey' => secret_access_key
463
+ }
464
+ },
465
+ 'database' => database,
466
+ 'schema' => schema
467
+ }
468
+ }
469
+ end
470
+ end
471
+
472
+ def validate
473
+ fail 'Data source url has to be provided' if url.nil? || url.blank?
474
+ fail 'Data source database has to be provided' if database.nil? || database.blank?
475
+ fail ERROR_MESSAGE_NO_SCHEMA if schema.nil? || schema.blank?
476
+
477
+ if basic_authentication
478
+ fail 'Data source username has to be provided' if user_name.nil? || user_name.blank?
479
+ elsif iam_authentication
480
+ fail 'Data source db_user has to be provided' if db_user.nil? || db_user.blank?
481
+ fail 'Data source access key has to be provided' if access_key_id.nil? || access_key_id.blank?
482
+ end
483
+ end
484
+ end
485
+
486
+ class BigQueryConnectionInfo < ConnectionInfo
487
+ def initialize(connection_info_json)
488
+ @json = connection_info_json[GoodData::DataSource::BIGQUERY]
489
+ end
490
+
491
+ def client_email
492
+ @json['authentication']['serviceAccount']['clientEmail'] if @json && @json['authentication'] && @json['authentication']['serviceAccount']
493
+ end
494
+
495
+ def client_email=(new_client_email)
496
+ @json['authentication']['serviceAccount']['clientEmail'] = new_client_email
497
+ end
498
+
499
+ def private_key
500
+ @json['authentication']['serviceAccount']['privateKey'] if @json && @json['authentication'] && @json['authentication']['serviceAccount']
501
+ end
502
+
503
+ def private_key=(new_private_key)
504
+ @json['authentication']['serviceAccount']['privateKey'] = new_private_key
505
+ end
506
+
507
+ def project
508
+ @json['project']
509
+ end
510
+
511
+ def project=(new_project)
512
+ @json['project'] = new_project
513
+ end
514
+
515
+ def schema
516
+ @json['schema']
517
+ end
518
+
519
+ def schema=(new_schema)
520
+ @json['schema'] = new_schema
521
+ end
522
+
523
+ def to_update_payload
524
+ {
525
+ 'bigQuery' => {
526
+ 'authentication' => {
527
+ 'serviceAccount' => {
528
+ 'clientEmail' => client_email,
529
+ 'privateKey' => private_key
530
+ }
531
+ },
532
+ 'project' => project,
533
+ 'schema' => schema
534
+ }
535
+ }
536
+ end
537
+
538
+ def validate
539
+ fail 'Data source client email has to be provided' if client_email.nil? || client_email.blank?
540
+ fail 'Data source project has to be provided' if project.nil? || project.blank?
541
+ fail ERROR_MESSAGE_NO_SCHEMA if schema.nil? || schema.blank?
542
+ end
543
+ end
544
+
545
+ class GenericConnectionInfo < ConnectionInfo
546
+ def initialize(connection_info_json)
547
+ @json = connection_info_json[GoodData::DataSource::GENERIC]
548
+ end
549
+
550
+ def params
551
+ @json['params']
552
+ end
553
+
554
+ def params=(new_params)
555
+ @json['params'] = new_params
556
+ end
557
+
558
+ def secure_params
559
+ @json['secureParams']
560
+ end
561
+
562
+ def secure_params=(new_secure_params)
563
+ @json['secureParams'] = new_secure_params
564
+ end
565
+
566
+ def to_update_payload
567
+ {
568
+ 'generic' => {
569
+ 'params' => params,
570
+ 'secureParams' => secure_params
571
+ }
572
+ }
573
+ end
574
+
575
+ def validate
576
+ end
577
+ end
578
+
579
+ class S3ConnectionInfo < ConnectionInfo
580
+ def initialize(connection_info_json)
581
+ @json = connection_info_json[GoodData::DataSource::S3]
582
+ end
583
+
584
+ def bucket
585
+ @json['bucket']
586
+ end
587
+
588
+ def bucket=(new_bucket)
589
+ @json['bucket'] = new_bucket
590
+ end
591
+
592
+ def access_key
593
+ @json['accessKey']
594
+ end
595
+
596
+ def access_key=(new_access_key)
597
+ @json['accessKey'] = new_access_key
598
+ end
599
+
600
+ def secret_key
601
+ @json['secretKey']
602
+ end
603
+
604
+ def secret_key=(new_secret_key)
605
+ @json['secretKey'] = new_secret_key
606
+ end
607
+
608
+ def server_side_encryption
609
+ @json['serverSideEncryption']
610
+ end
611
+
612
+ def server_side_encryption=(new_server_side_encryption)
613
+ @json['serverSideEncryption'] = new_server_side_encryption
614
+ end
615
+
616
+ def to_update_payload
617
+ {
618
+ 's3' => {
619
+ 'bucket' => bucket,
620
+ 'accessKey' => access_key,
621
+ 'secretKey' => secret_key,
622
+ 'serverSideEncryption' => server_side_encryption
623
+ }
624
+ }
625
+ end
626
+
627
+ def validate
628
+ fail 'S3 bucket has to be provided' if bucket.nil? || bucket.blank?
629
+ fail 'S3 access key has to be provided' if access_key.nil? || access_key.blank?
630
+ end
631
+ end
632
+
633
+ class AdsConnectionInfo < ConnectionInfo
634
+ def initialize(connection_info_json)
635
+ @json = connection_info_json[GoodData::DataSource::ADS]
636
+ end
637
+
638
+ def instance
639
+ @json['instance']
640
+ end
641
+
642
+ def instance=(new_instance)
643
+ @json['instance'] = new_instance
644
+ end
645
+
646
+ def exportable
647
+ @json['exportable']
648
+ end
649
+
650
+ def exportable=(new_exportable)
651
+ @json['exportable'] = new_exportable
652
+ end
653
+
654
+ def to_update_payload
655
+ {
656
+ 'ads' => {
657
+ 'instance' => instance,
658
+ 'exportable' => exportable
659
+ }
660
+ }
661
+ end
662
+
663
+ def validate
664
+ fail 'Data source instance has to be provided' if instance.nil? || instance.blank?
665
+ end
666
+ end
667
+ end
668
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+ #
4
+ # Copyright (c) 2010-2021 GoodData Corporation. All rights reserved.
5
+ # This source code is licensed under the BSD-style license found in the
6
+ # LICENSE file in the root directory of this source tree.
7
+
8
+ module GoodData
9
+ class DatasetMapping
10
+ DATASET_MAPPING_GET_URI = '/gdc/dataload/projects/%<project_id>s/modelMapping/datasets'
11
+ DATASET_MAPPING_UPDATE_URI = '/gdc/dataload/projects/%<project_id>s/modelMapping/datasets/bulk/upsert'
12
+
13
+ class << self
14
+ def [](opts = { :client => GoodData.connection, :project => GoodData.project })
15
+ client, project = GoodData.get_client_and_project(opts)
16
+ get_uri = DATASET_MAPPING_GET_URI % { project_id: project.pid }
17
+ res = client.get(get_uri)
18
+ res
19
+ end
20
+
21
+ alias_method :get, :[]
22
+ end
23
+
24
+ def initialize(data)
25
+ @data = data
26
+ end
27
+
28
+ def save(opts)
29
+ client, project = GoodData.get_client_and_project(opts)
30
+
31
+ post_uri = DATASET_MAPPING_UPDATE_URI % { project_id: project.pid }
32
+ res = client.post(post_uri, @data, opts)
33
+ res
34
+ end
35
+ end
36
+ end