Class LookerDataSourceSpecBuilder

LookerDataSourceSpecBuilder

The builder for LookerDataSourceSpec.

This example shows how to create a new Looker Data Source Spec builder.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();

Methods

MethodReturn typeBrief description
build()DataSourceSpecBuilds a data source specification from the settings in this builder.
copy()DataSourceSpecBuilderCreates a DataSourceSpecBuilder based on this data source's settings.
getExploreName()StringGets the name of the Looker explore in the model.
getInstanceUrl()StringGets the URL of the Looker instance.
getModelName()StringGets the name of the Looker model in the instance.
getParameters()DataSourceParameter[]Gets the parameters of the data source.
getType()DataSourceTypeGets the type of the data source.
removeAllParameters()LookerDataSourceSpecBuilderRemoves all the parameters.
removeParameter(parameterName)LookerDataSourceSpecBuilderRemoves the specified parameter.
setExploreName(exploreName)LookerDataSourceSpecBuilderSets the explore name in the Looker model.
setInstanceUrl(instanceUrl)LookerDataSourceSpecBuilderSets the instance URL for Looker.
setModelName(modelName)LookerDataSourceSpecBuilderSets the Looker model name in the Looker instance.
setParameterFromCell(parameterName, sourceCell)LookerDataSourceSpecBuilderAdds a parameter, or if the parameter with the name exists, updates its source cell for data source spec builders of type DataSourceType.BIGQUERY.

Detailed documentation

build()

Builds a data source specification from the settings in this builder. Must use as...() to specify a data source type before building.

The following code sample builds a BigQuery DataSource Spec.

var bigQueryDataSourceSpec = SpreadsheetApp.newDataSourceSpec().asBigQuery();
// TODO(developer): Replace with the required dataset, project and table IDs.
bigQueryDataSourceSpec.setDatasetId("my data set id");
bigQueryDataSourceSpec.setProjectId("my project id");
bigQueryDataSourceSpec.setTableId("my table id");

bigQueryDataSourceSpec.build();

The following code sample builds a Looker DataSource Spec.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
var lookerSpec = lookerDataSourceSpecBuilder.setExploreName("my explore name")
                                            .setInstanceUrl("my instance url")
                                            .setModelName("my model name")
                                            .build();

Return

DataSourceSpec — The data source specification.


copy()

Creates a DataSourceSpecBuilder based on this data source's settings.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();

var newSpec = spec.copy();

Return

DataSourceSpecBuilder — The builder.


getExploreName()

Gets the name of the Looker explore in the model.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

var lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
var exploreName = lookerDataSourceSpec.getExploreName();
Logger.log(exploreName);

Return

String — The name of the Looker explore.


getInstanceUrl()

Gets the URL of the Looker instance.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

var lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
var instanceUrl = lookerDataSourceSpec.getInstanceUrl();
Logger.log(instanceUrl);

Return

String — The URL of the Looker instance.


getModelName()

Gets the name of the Looker model in the instance.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

var lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
var modelName = lookerDataSourceSpec.getModelName();
Logger.log(modelName);

Return

String — The name of the Looker model.


getParameters()

Gets the parameters of the data source.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();
var parameters = spec.getParameters();

This method is only available for BigQuery data sources.

Return

DataSourceParameter[] — The parameter list.


getType()

Gets the type of the data source.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();
var type = spec.getType();

Return

DataSourceType — The data source type.


removeAllParameters()

Removes all the parameters.

var specBuilder = SpreadsheetApp.newDataSourceSpec();
specBuilder.removeAllParameters();

Return

LookerDataSourceSpecBuilder — The builder, for chaining.


removeParameter(parameterName)

Removes the specified parameter.

var specBuilder = SpreadsheetApp.newDataSourceSpec();
specBuilder.removeParameter("x");

Parameters

NameTypeDescription
parameterNameStringThe name of the parameter to remove.

Return

LookerDataSourceSpecBuilder — The builder, for chaining.


setExploreName(exploreName)

Sets the explore name in the Looker model.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
// TODO(developer): replace explore name with your own
lookerDataSourceSpecBuilder.setExploreName("my explore name");

Parameters

NameTypeDescription
exploreNameStringThe explore name in the selected Looker model.

Return

LookerDataSourceSpecBuilder — This builder, for chaining.


setInstanceUrl(instanceUrl)

Sets the instance URL for Looker.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
 // TODO(developer): replace instance url with your own
lookerDataSourceSpecBuilder.setInstanceUrl("my instance url");

Parameters

NameTypeDescription
instanceUrlStringThe URL of the Looker instance.

Return

LookerDataSourceSpecBuilder — The builder, for chaining.


setModelName(modelName)

Sets the Looker model name in the Looker instance.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
// TODO(developer): replace model name with your own
lookerDataSourceSpecBuilder.setModelName("my model name");

Parameters

NameTypeDescription
modelNameStringThe model name in the Looker instance.

Return

LookerDataSourceSpecBuilder — The builder, for chaining.


setParameterFromCell(parameterName, sourceCell)

Adds a parameter, or if the parameter with the name exists, updates its source cell for data source spec builders of type DataSourceType.BIGQUERY.

This method is only available for BigQuery data sources.

var specBuilder = SpreadsheetApp.newDataSourceSpec().asBigQuery();
specBuilder.setParameterFromCell("x", "A1");
var bigQuerySpec = specBuilder.build();

Parameters

NameTypeDescription
parameterNameStringThe parameter name.
sourceCellStringThe source cell, as specified in A1 notation.

Return

LookerDataSourceSpecBuilder — The builder, for chaining.