Class LookerDataSourceSpec
Stay organized with collections
Save and categorize content based on your preferences.
LookerDataSourceSpec
A DataSourceSpec
which is used to access specifically the existing Looker data source
specifications. To create a new data source specification, use SpreadsheetApp.newDataSourceSpec()
.
This example shows how you can get the Looker data source spec from a sheet which has just one
Looker connection.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
Detailed documentation
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',
);
const spec = ss.getDataSources()[0].getSpec();
const 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',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const 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',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const 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',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const 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',
);
const spec = ss.getDataSources()[0].getSpec();
const 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',
);
const spec = ss.getDataSources()[0].getSpec();
const type = spec.getType();
Return
DataSourceType
— The data source type.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.
[null,null,["Last updated 2024-12-03 UTC."],[[["\u003cp\u003e\u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e enables access to existing Looker data source specifications within Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eTo create new data source specifications, use \u003ccode\u003eSpreadsheetApp.newDataSourceSpec()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve details such as explore name, instance URL, and model name from a \u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eSeveral methods, including \u003ccode\u003ecopy()\u003c/code\u003e, \u003ccode\u003egetExploreName()\u003c/code\u003e, \u003ccode\u003egetInstanceUrl()\u003c/code\u003e, \u003ccode\u003egetModelName()\u003c/code\u003e, \u003ccode\u003egetParameters()\u003c/code\u003e, and \u003ccode\u003egetType()\u003c/code\u003e, are available for interacting with Looker data source specifications.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetParameters()\u003c/code\u003e method is specific to BigQuery data sources and retrieves their parameters.\u003c/p\u003e\n"]]],["The `LookerDataSourceSpec` accesses existing Looker data sources. Key actions include retrieving data source details via methods: `getExploreName()` gets the Looker explore name, `getInstanceUrl()` gets the Looker instance URL, and `getModelName()` gets the Looker model name. `getParameters()` retrieves data source parameters (available only for BigQuery), and `getType()` gets the data source type. The `copy()` method creates a `DataSourceSpecBuilder` based on current settings. You can retrieve the looker data source by using `getDataSources()[0].getSpec().asLooker()`.\n"],null,["# Class LookerDataSourceSpec\n\nLookerDataSourceSpec\n\nA [DataSourceSpec](/apps-script/reference/spreadsheet/data-source-spec) which is used to access specifically the existing Looker data source\nspecifications. To create a new data source specification, use [SpreadsheetApp.newDataSourceSpec()](/apps-script/reference/spreadsheet/spreadsheet-app#newDataSourceSpec()).\n\nThis example shows how you can get the Looker data source spec from a sheet which has just one\nLooker connection.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [copy()](#copy()) | [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) | Creates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings. |\n| [getExploreName()](#getExploreName()) | `String` | Gets the name of the Looker explore in the model. |\n| [getInstanceUrl()](#getInstanceUrl()) | `String` | Gets the URL of the Looker instance. |\n| [getModelName()](#getModelName()) | `String` | Gets the name of the Looker model in the instance. |\n| [getParameters()](#getParameters()) | [DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) | Gets the parameters of the data source. |\n| [getType()](#getType()) | [DataSourceType](/apps-script/reference/spreadsheet/data-source-type) | Gets the type of the data source. |\n\nDetailed documentation\n----------------------\n\n### `copy()`\n\nCreates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\n\nconst newSpec = spec.copy();\n```\n\n#### Return\n\n\n[DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) --- The builder.\n\n*** ** * ** ***\n\n### `get``Explore``Name()`\n\nGets the name of the Looker explore in the model.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst exploreName = lookerDataSourceSpec.getExploreName();\nLogger.log(exploreName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker explore.\n\n*** ** * ** ***\n\n### `get``Instance``Url()`\n\nGets the URL of the Looker instance.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst instanceUrl = lookerDataSourceSpec.getInstanceUrl();\nLogger.log(instanceUrl);\n```\n\n#### Return\n\n\n`String` --- The URL of the Looker instance.\n\n*** ** * ** ***\n\n### `get``Model``Name()`\n\nGets the name of the Looker model in the instance.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst modelName = lookerDataSourceSpec.getModelName();\nLogger.log(modelName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker model.\n\n*** ** * ** ***\n\n### `get``Parameters()`\n\nGets the parameters of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst parameters = spec.getParameters();\n```\n\nThis method is only available for BigQuery data sources.\n\n#### Return\n\n\n[DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) --- The parameter list.\n\n*** ** * ** ***\n\n### `get``Type()`\n\nGets the type of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst type = spec.getType();\n```\n\n#### Return\n\n\n[DataSourceType](/apps-script/reference/spreadsheet/data-source-type) --- The data source type."]]