Skip to content

Commit

Permalink
docs and logging updates. apache#3034
Browse files Browse the repository at this point in the history
  • Loading branch information
bamaer committed Sep 1, 2023
1 parent 602c760 commit 33eab6b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ under the License.

The Google Sheets Input transform reads data from a Google Sheets worksheets.

This transform requires a Google service account (JSON file) and a Google Cloud project with the Sheets API enabled.
This transform requires a Google service account (JSON file) and a Google Cloud project with the Google Drive and Google Sheets API enabled.

|
== Supported Engines
Expand All @@ -44,13 +44,26 @@ This transform requires a Google service account (JSON file) and a Google Cloud

=== Service account tab

Click the `browse` button to pick your google service account client secret json file.

The `Test` button Lets you test your access to the API. On success, you should see a success message.
[%header, width="90%", cols="1,4"]
|===
|option|description
|JSON credential key file|Lets you specify or browse for spreadsheets existing in the service account drive or for the ones that are shared with the service account email.
|Application Name|Your application name for the service account in the Google Developer Console.
|Timeout|lets you specify an https timeout (in minutes, defaults to 5).
|Impersonation|lets you impersonate your service account. Check the https://cloud.google.com/iam/docs/impersonating-service-accounts[Google docs] for more information.
|===

Click the `Test Connection` button to verify your specified JSON credential key file for your service account can use the Google Drive and Spreadsheets APIs and has access to your Google Spreadsheets. On success, you will see a `Google Drive API: Success!` message.

=== Spreadsheet tab

Lets you specify or browse for spreadsheets existing in the service account drive or for the ones that are shared with the service account email.
[%header, width="90%", cols="1,4"]
|===
|option|description
|Spreadsheet Key|specify the key for the Google Spreadsheet you want to read from. Click the "Browse" button to get a list of available spreadsheets.
|Worksheet Id|specify the worksheet id (title) for the sheet in your Google Spreadsheet you want to read from. Click the "Browse" button to get the list of available worksheets in the selected Google Spreadsheet.
|===

=== Fields tab

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ under the License.

The Google Sheets Output transform writes data to a Google Sheets worksheets.

This transform requires a Google service account (JSON file) and a Google Cloud project with the Sheets API enabled.
This transform requires a Google service account (JSON file) and a Google Cloud project with the Google Drive and Google Sheets API enabled.

|
== Supported Engines
Expand All @@ -44,15 +44,24 @@ This transform requires a Google service account (JSON file) and a Google Cloud

=== Service account tab

Click the `browse` button to pick your google service account client secret json file.

The `Test` button Lets you test your access to the API. On success, you should see a success message.
[%header, width="90%", cols="1,4"]
|===
|option|description
|JSON credential key file|Lets you specify or browse for spreadsheets existing in the service account drive or for the ones that are shared with the service account email.
|Application Name|Your application name for the service account in the Google Developer Console.
|Timeout|lets you specify an https timeout (in minutes, defaults to 5).
|Impersonation|lets you impersonate your service account. Check the https://cloud.google.com/iam/docs/impersonating-service-accounts[Google docs] for more information.
|===

Click the `Test Connection` button to verify your specified JSON credential key file for your service account can use the Google Drive and Spreadsheets APIs and has access to your Google Spreadsheets. On success, you will see a `Google Drive API: Success!` message.


=== Spreadsheet tab

[%header, width="90%"]
[%header, width="90%", cols="1,4"]
|===
|Option|Description
|option|description
|Spreadsheet key|Lets you specify or browse for spreadsheets existing in the service account drive or for the ones that are shared with the service account email. If you type in a sheet name (that does not exist in the drive) it will attempt to create a sheet it the "create" checkbox is ticked.
|Worksheet Id|Should be browsed form the selected spreadsheet key. If you want to create a new file, type in any key that will become the name of the worksheet in the created spreadsheet
|Append to sheet|Appends the lines **without the header** to an existing spreadsheet. This is incompatible with the create option below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ private void getSpreadsheetFields() {
// fieldname, int position, int length )
GoogleSheetsInputField sampleInputFields = new GoogleSheetsInputField();
String columnsLetter = getColumnName(j + 1);
logBasic("column:" + Integer.toString(j) + ")" + columnsLetter);
logDebug("column:" + Integer.toString(j) + ")" + columnsLetter);
Integer nbSampleFields = Integer.parseInt(variables.resolve(wSampleFields.getText()));

String sampleRange =
Expand All @@ -796,7 +796,7 @@ private void getSpreadsheetFields() {
+ "2:"
+ columnsLetter
+ variables.resolve(wSampleFields.getText());
logBasic("Guess Fieds : Range : " + sampleRange);
logDebug("Guess Fieds : Range : " + sampleRange);
ValueRange sampleResult =
service
.spreadsheets()
Expand All @@ -814,7 +814,7 @@ private void getSpreadsheetFields() {
&& sampleRow.get(0) != null
&& !sampleRow.get(0).toString().isEmpty()) {
String tmp = sampleRow.get(0).toString();
logBasic(Integer.toString(m) + ")" + tmp.toString());
logDebug(Integer.toString(m) + ")" + tmp.toString());
tmpSampleColumnValues[m] = tmp;
m++;
} else {
Expand All @@ -825,13 +825,27 @@ private void getSpreadsheetFields() {
System.arraycopy(tmpSampleColumnValues, 0, sampleColumnValues, 0, m);
sampleInputFields.setSamples(sampleColumnValues);
sampleInputFields.guess();
item.setText(2, sampleInputFields.getTypeDesc());
item.setText(3, sampleInputFields.getFormat());
item.setText(5, Integer.toString(sampleInputFields.getPrecision()));
item.setText(6, sampleInputFields.getCurrencySymbol());
item.setText(7, sampleInputFields.getDecimalSymbol());
item.setText(8, sampleInputFields.getGroupSymbol());
item.setText(9, sampleInputFields.getTrimTypeDesc());
if(!StringUtils.isEmpty(sampleInputFields.getTypeDesc())){
item.setText(2, sampleInputFields.getTypeDesc());
}
if(!StringUtils.isEmpty(sampleInputFields.getFormat())){
item.setText(3, sampleInputFields.getFormat());
}
if(!StringUtils.isEmpty(Integer.toString(sampleInputFields.getPrecision()))){
item.setText(5, Integer.toString(sampleInputFields.getPrecision()));
}
if(!StringUtils.isEmpty(sampleInputFields.getCurrencySymbol())){
item.setText(6, sampleInputFields.getCurrencySymbol());
}
if(!StringUtils.isEmpty(sampleInputFields.getDecimalSymbol())){
item.setText(7, sampleInputFields.getDecimalSymbol());
}
if(!StringUtils.isEmpty(sampleInputFields.getGroupSymbol())){
item.setText(8, sampleInputFields.getGroupSymbol());
}
if(!StringUtils.isEmpty(sampleInputFields.getTrimTypeDesc())){
item.setText(9, sampleInputFields.getTrimTypeDesc());
}
} else {
item.setText(2, "String");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
name = "i18n::GoogleSheetsInput.transform.Name",
description = "i18n::GoogleSheetsInput.transform.Name",
categoryDescription = "i18n:org.apache.hop.pipeline.transform:BaseTransform.Category.Input",
documentationUrl =
"https://hop.apache.org/manual/latest/pipeline/transforms/googlesheetsinput.html")
documentationUrl = "/pipeline/transforms/google-sheets-input.html")
public class GoogleSheetsInputMeta
extends BaseTransformMeta<GoogleSheetsInput, GoogleSheetsInputData> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
name = "i18n::GoogleSheetsOutput.transform.Name",
description = "i18n::GoogleSheetsOutput.transform.Name",
categoryDescription = "i18n:org.apache.hop.pipeline.transform:BaseTransform.Category.Input",
documentationUrl =
"https://hop.apache.org/manual/latest/pipeline/transforms/googlesheetsoutput.html")
documentationUrl = "/pipeline/transforms/google-sheets-output.html")
public class GoogleSheetsOutputMeta
extends BaseTransformMeta<GoogleSheetsOutput, GoogleSheetsOutputData> {

Expand Down

0 comments on commit 33eab6b

Please sign in to comment.