Skip to content

Commit

Permalink
Merge branch 'main' into folder-automation
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickVoulet authored Jan 16, 2024
2 parents 875d04c + 82c5c04 commit 318418a
Show file tree
Hide file tree
Showing 108 changed files with 1,126 additions and 605 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/clasp_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for dir in "${dirs[@]}"; do
pushd "${dir}" > /dev/null || exit
contains_changes "$dir" "${changed_files[@]}" || continue
echo "Publishing ${dir}"
echo clasp push -f
clasp push -f
status=$?
if [ $status -ne 0 ]; then
exit_code=$status
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
workflow_dispatch:
push:
branches:
- master
- main
jobs:
publish:
concurrency:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ align="left"
width="96px"/>
### Calendar
- [List upcoming events](calendar/quickstart)
- [Create a vacation calendar](calendar/vacationCalendar)
- [Create a vacation calendar](solutions/automations/vacation-calendar/Code.js)

<img
src="https://www.gstatic.com/images/branding/product/2x/classroom_96dp.png"
Expand Down
10 changes: 5 additions & 5 deletions adminSDK/directory/quickstart.gs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
// [START admin_sdk_directory_quickstart]
/**
* Lists users in a G Suite domain.
* Lists users in a Google Workspace domain.
* @see https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list
*/
function listUsers() {
Expand All @@ -28,17 +28,17 @@ function listUsers() {
const response = AdminDirectory.Users.list(optionalArgs);
const users = response.users;
if (!users || users.length === 0) {
Logger.log('No users found.');
console.log('No users found.');
return;
}
// Print the list of user's full name and email
Logger.log('Users:');
console.log('Users:');
for (const user of users) {
Logger.log('%s (%s)', user.primaryEmail, user.name.fullName);
console.log('%s (%s)', user.primaryEmail, user.name.fullName);
}
} catch (err) {
// TODO (developer)- Handle exception from the Directory API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END admin_sdk_directory_quickstart]
10 changes: 5 additions & 5 deletions adminSDK/reports/quickstart.gs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
// [START admin_sdk_reports_quickstart]
/**
* List login events for a G Suite domain.
* List login events for a Google Workspace domain.
* @see https://developers.google.com/admin-sdk/reports/reference/rest/v1/activities/list
*/
function listLogins() {
Expand All @@ -28,18 +28,18 @@ function listLogins() {
const response = AdminReports.Activities.list(userKey, applicationName, optionalArgs);
const activities = response.items;
if (!activities || activities.length === 0) {
Logger.log('No logins found.');
console.log('No logins found.');
return;
}
// Print login events
Logger.log('Logins:');
console.log('Logins:');
for (const activity of activities) {
Logger.log('%s: %s (%s)', activity.id.time, activity.actor.email,
console.log('%s: %s (%s)', activity.id.time, activity.actor.email,
activity.events[0].name);
}
} catch (err) {
// TODO (developer)- Handle exception from the Report API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END admin_sdk_reports_quickstart]
8 changes: 4 additions & 4 deletions adminSDK/reseller/quickstart.gs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ function listSubscriptions() {
const response = AdminReseller.Subscriptions.list(optionalArgs);
const subscriptions = response.subscriptions;
if (!subscriptions || subscriptions.length === 0) {
Logger.log('No subscriptions found.');
console.log('No subscriptions found.');
return;
}
Logger.log('Subscriptions:');
console.log('Subscriptions:');
for (const subscription of subscriptions) {
Logger.log('%s (%s, %s)', subscription.customerId, subscription.skuId,
console.log('%s (%s, %s)', subscription.customerId, subscription.skuId,
subscription.plan.planName);
}
} catch (err) {
// TODO (developer)- Handle exception from the Reseller API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END admin_sdk_reseller_quickstart]
52 changes: 26 additions & 26 deletions advanced/adminSDK.gs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ function listAllUsers() {
});
const users = page.users;
if (!users) {
Logger.log('No users found.');
console.log('No users found.');
return;
}
// Print the user's full name and email.
for (const user of users) {
Logger.log('%s (%s)', user.name.fullName, user.primaryEmail);
console.log('%s (%s)', user.name.fullName, user.primaryEmail);
}
pageToken = page.nextPageToken;
} while (pageToken);
Expand All @@ -52,10 +52,10 @@ function getUser() {
const userEmail = '[email protected]';
try {
const user = AdminDirectory.Users.get(userEmail);
Logger.log('User data:\n %s', JSON.stringify(user, null, 2));
console.log('User data:\n %s', JSON.stringify(user, null, 2));
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_get_users]
Expand All @@ -79,10 +79,10 @@ function addUser() {
};
try {
user = AdminDirectory.Users.insert(user);
Logger.log('User %s created with ID %s.', user.primaryEmail, user.id);
console.log('User %s created with ID %s.', user.primaryEmail, user.id);
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_add_user]
Expand All @@ -100,10 +100,10 @@ function createAlias() {
};
try {
alias = AdminDirectory.Users.Aliases.insert(alias, userEmail);
Logger.log('Created alias %s for user %s.', alias.alias, userEmail);
console.log('Created alias %s for user %s.', alias.alias, userEmail);
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_create_alias]
Expand All @@ -124,12 +124,12 @@ function listAllGroups() {
});
const groups = page.groups;
if (!groups) {
Logger.log('No groups found.');
console.log('No groups found.');
return;
}
// Print group name and email.
for (const group of groups) {
Logger.log('%s (%s)', group.name, group.email);
console.log('%s (%s)', group.name, group.email);
}
pageToken = page.nextPageToken;
} while (pageToken);
Expand All @@ -152,10 +152,10 @@ function addGroupMember() {
};
try {
AdminDirectory.Members.insert(member, groupEmail);
Logger.log('User %s added as a member of group %s.', userEmail, groupEmail);
console.log('User %s added as a member of group %s.', userEmail, groupEmail);
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_add_group_member]
Expand Down Expand Up @@ -209,10 +209,10 @@ function getGroupSettings() {
const groupId = '[email protected]';
try {
const group = AdminGroupsSettings.Groups.get(groupId);
Logger.log(JSON.stringify(group, null, 2));
console.log(JSON.stringify(group, null, 2));
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_get_group_setting]
Expand All @@ -231,7 +231,7 @@ function updateGroupSettings() {
AdminGroupsSettings.Groups.patch(group, groupId);
} catch (err) {
// TODO (developer)- Handle exception from the API
Logger.log('Failed with error %s', err.message);
console.log('Failed with error %s', err.message);
}
}
// [END apps_script_admin_sdk_update_group_setting]
Expand All @@ -257,7 +257,7 @@ function getLicenseAssignments() {
} while (pageToken);
// Print the productId and skuId
for (const assignment of assignments) {
Logger.log('userId: %s, productId: %s, skuId: %s',
console.log('userId: %s, productId: %s, skuId: %s',
assignment.userId, assignment.productId, assignment.skuId);
}
}
Expand All @@ -277,10 +277,10 @@ function insertLicenseAssignment() {
try {
const results = AdminLicenseManager.LicenseAssignments
.insert({userId: userId}, productId, skuId);
Logger.log(results);
console.log(results);
} catch (e) {
// TODO (developer) - Handle exception.
Logger.log('Failed with an error %s ', e.message);
console.log('Failed with an error %s ', e.message);
}
}
// [END apps_script_admin_sdk_insert_license_assignment]
Expand Down Expand Up @@ -322,10 +322,10 @@ function generateLoginActivityReport() {
} while (pageToken);

if (rows.length === 0) {
Logger.log('No results returned.');
console.log('No results returned.');
return;
}
const spreadsheet = SpreadsheetApp.create('G Suite Login Report');
const spreadsheet = SpreadsheetApp.create('Google Workspace Login Report');
const sheet = spreadsheet.getActiveSheet();

// Append the headers.
Expand All @@ -335,7 +335,7 @@ function generateLoginActivityReport() {
// Append the results.
sheet.getRange(2, 1, rows.length, headers.length).setValues(rows);

Logger.log('Report spreadsheet created: %s', spreadsheet.getUrl());
console.log('Report spreadsheet created: %s', spreadsheet.getUrl());
}
// [END apps_script_admin_sdk_generate_login_activity_report]

Expand Down Expand Up @@ -368,7 +368,7 @@ function generateUserUsageReport() {
});
if (page.warnings) {
for (const warning of page.warnings) {
Logger.log(warning.message);
console.log(warning.message);
}
}
const reports = page.usageReports;
Expand All @@ -389,10 +389,10 @@ function generateUserUsageReport() {
} while (pageToken);

if (rows.length === 0) {
Logger.log('No results returned.');
console.log('No results returned.');
return;
}
const spreadsheet = SpreadsheetApp.create('G Suite User Usage Report');
const spreadsheet = SpreadsheetApp.create('Google Workspace User Usage Report');
const sheet = spreadsheet.getActiveSheet();

// Append the headers.
Expand All @@ -403,7 +403,7 @@ function generateUserUsageReport() {
// Append the results.
sheet.getRange(2, 1, rows.length, headers.length).setValues(rows);

Logger.log('Report spreadsheet created: %s', spreadsheet.getUrl());
console.log('Report spreadsheet created: %s', spreadsheet.getUrl());
}

/**
Expand Down Expand Up @@ -447,7 +447,7 @@ function getSubscriptions() {
for (const sub of result.subscriptions) {
const creationDate = new Date();
creationDate.setUTCSeconds(sub.creationTime);
Logger.log('customer ID: %s, date created: %s, plan name: %s, sku id: %s',
console.log('customer ID: %s, date created: %s, plan name: %s, sku id: %s',
sub.customerId, creationDate.toDateString(), sub.plan.planName,
sub.skuId);
}
Expand Down
18 changes: 9 additions & 9 deletions advanced/adsense.gs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function listAccounts() {
do {
const response = AdSense.Accounts.list({pageToken: pageToken});
if (!response.accounts) {
Logger.log('No accounts found.');
console.log('No accounts found.');
return;
}
for (const account of response.accounts) {
Logger.log('Found account with resource name "%s" and display name "%s".',
console.log('Found account with resource name "%s" and display name "%s".',
account.name, account.displayName);
}
pageToken = response.nextPageToken;
Expand All @@ -48,13 +48,13 @@ function listAdClients(accountName) {
pageToken: pageToken
});
if (!response.adClients) {
Logger.log('No ad clients found for this account.');
console.log('No ad clients found for this account.');
return;
}
for (const adClient of response.adClients) {
Logger.log('Found ad client for product "%s" with resource name "%s".',
console.log('Found ad client for product "%s" with resource name "%s".',
adClient.productCode, adClient.name);
Logger.log('Reporting dimension ID: %s',
console.log('Reporting dimension ID: %s',
adClient.reportingDimensionId ?? 'None');
}
pageToken = response.nextPageToken;
Expand All @@ -76,11 +76,11 @@ function listAdUnits(adClientName) {
pageToken: pageToken
});
if (!response.adUnits) {
Logger.log('No ad units found for this ad client.');
console.log('No ad units found for this ad client.');
return;
}
for (const adUnit of response.adUnits) {
Logger.log('Found ad unit with resource name "%s" and display name "%s".',
console.log('Found ad unit with resource name "%s" and display name "%s".',
adUnit.name, adUnit.displayName);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ function generateReport(accountName, adClientReportingDimensionId) {
});

if (!report.rows) {
Logger.log('No rows returned.');
console.log('No rows returned.');
return;
}
const spreadsheet = SpreadsheetApp.create('AdSense Report');
Expand All @@ -128,7 +128,7 @@ function generateReport(accountName, adClientReportingDimensionId) {
sheet.getRange(2, 1, report.rows.length, report.headers.length)
.setValues(report.rows.map((row) => row.cells.map((cell) => cell.value)));

Logger.log('Report spreadsheet created: %s',
console.log('Report spreadsheet created: %s',
spreadsheet.getUrl());
}

Expand Down
Loading

0 comments on commit 318418a

Please sign in to comment.