Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate code from googleapis/nodejs-datacatalog #2877

Merged
merged 50 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
329c5e2
repo setups
jkwlui Mar 28, 2019
75b3945
feat!: first release of client library (#8)
bcoe Jun 20, 2019
8250ab5
chore: release 1.0.0 (#9)
yoshi-automation Jun 20, 2019
f5edf3e
chore: release 1.0.1 (#11)
yoshi-automation Jun 26, 2019
10c3369
chore(deps): update dependency execa to v2 (#16)
renovate-bot Jul 26, 2019
1651942
chore: release 1.0.2 (#23)
yoshi-automation Aug 5, 2019
a6989b8
chore: release 1.1.0 (#30)
yoshi-automation Sep 16, 2019
c22fc78
chore(deps): update dependency execa to v3 (#47)
renovate-bot Oct 14, 2019
eade272
chore: release 1.3.0 (#49)
release-please[bot] Oct 22, 2019
f94aef8
chore: release 1.4.0 (#63)
release-please[bot] Nov 21, 2019
b604b28
chore: release 1.4.1 (#66)
release-please[bot] Dec 5, 2019
531fa41
chore: release 1.5.0 (#70)
release-please[bot] Dec 11, 2019
eccc3b1
chore(deps): update dependency execa to v4 (#77)
renovate-bot Dec 20, 2019
5b72b3a
chore: release 1.5.1 (#73)
release-please[bot] Dec 20, 2019
802bccd
refactor: use explicit mocha imports (#83)
JustinBeckwith Dec 30, 2019
33b2c67
chore: release 1.6.0 (#84)
release-please[bot] Jan 2, 2020
9f64878
chore(deps): update dependency mocha to v7 (#89)
renovate-bot Jan 6, 2020
c6f97a5
chore: release 1.6.1
release-please[bot] Jan 6, 2020
f6ee938
chore: release 1.6.2 (#92)
release-please[bot] Jan 8, 2020
fc51420
chore: release 1.6.3 (#94)
release-please[bot] Jan 9, 2020
c882b54
chore: release 1.7.0 (#111)
release-please[bot] Feb 10, 2020
684af52
chore: release 1.8.0 (#125)
release-please[bot] Mar 11, 2020
04b8dcf
chore: release 2.0.0 (#141)
release-please[bot] Apr 15, 2020
fbbd3ff
chore(deps): update dependency mocha to v8 (#173)
renovate-bot Jun 11, 2020
232972f
chore: release 2.1.0 (#160)
release-please[bot] Jun 16, 2020
982e371
chore: release 2.1.1 (#183)
release-please[bot] Jul 10, 2020
54e720e
chore: release 2.1.2 (#195)
release-please[bot] Jul 27, 2020
8f1342f
chore: release 2.1.3 (#219)
release-please[bot] Nov 16, 2020
2ec6ef2
docs(samples): adds samples and tests (#225)
steffnay Dec 2, 2020
9d4e951
chore(deps): update dependency execa to v5 (#226)
renovate-bot Dec 3, 2020
dedf10b
chore: release 2.2.0 (#232)
release-please[bot] Mar 8, 2021
ce0be81
chore: release 2.3.0 (#245)
release-please[bot] Apr 28, 2021
d44cf19
chore: release 2.3.1 (#250)
release-please[bot] May 13, 2021
37f4528
chore: release 2.3.2 (#266)
release-please[bot] Jun 24, 2021
6423de6
chore: release 2.3.3 (#271)
release-please[bot] Jun 30, 2021
141191d
chore: release 2.3.4 (#273)
release-please[bot] Jul 21, 2021
bcbae9d
chore: release 2.4.0 (#282)
release-please[bot] Aug 5, 2021
91c6a21
chore: release 2.4.1 (#286)
release-please[bot] Aug 14, 2021
84b0070
chore: release 2.4.2 (#292)
release-please[bot] Aug 17, 2021
357e510
chore: release 2.5.0 (#295)
release-please[bot] Aug 23, 2021
3315da9
chore(main): release 2.6.0 (#329)
release-please[bot] Feb 17, 2022
9bc966e
docs(samples): add policyTagManager samples (#330)
steffnay Feb 18, 2022
f4251ae
fix(deps): roll back dependency @google-cloud/datacatalog to ^2.5.0 (…
renovate-bot Mar 18, 2022
d29f9d2
build!: update library to use Node 12 (#362)
alexander-fenster May 17, 2022
6c81b5f
fix(deps): update dependency @google-cloud/bigquery to v6 (#365)
renovate-bot Jun 9, 2022
5b2fac4
chore(main): release 3.0.0 (#363)
release-please[bot] Jun 20, 2022
9722200
chore(main): release 3.1.0 (#371)
release-please[bot] Jul 5, 2022
75a8a1e
fix(deps): update dependency uuid to v9 (#382)
renovate-bot Sep 9, 2022
24b41ac
Merge remote-tracking branch 'migration/main' into nodejs-datacatalog…
NimJay Nov 18, 2022
3b2115c
Generate datacatalog-snippets.yaml
NimJay Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/datacatalog-snippets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: datacatalog-snippets
on:
push:
branches:
- main
paths:
- 'datacatalog/snippets/**'
pull_request:
paths:
- 'datacatalog/snippets/**'
pull_request_target:
types: [labeled]
paths:
- 'datacatalog/snippets/**'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: datacatalog/snippets
- run: npm test
working-directory: datacatalog/snippets
env:
MOCHA_REPORTER_SUITENAME: datacatalog_snippets
MOCHA_REPORTER_OUTPUT: datacatalog_snippets_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"containerengine/hello-world",
"container/snippets",
"datacatalog/cloud-client",
"datacatalog/snippets",
"datalabeling",
"datastore/functions",
"datacatalog/quickstart",
Expand Down
5 changes: 5 additions & 0 deletions datacatalog/snippets/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
rules:
no-console: off
node/no-missing-require: off
node/no-extraneous-require: off
192 changes: 192 additions & 0 deletions datacatalog/snippets/createCustomEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

async function main(projectId, entryGroupId, entryId, tagTemplateId) {
// [START data_catalog_create_custom_entry]
// Import the Google Cloud client library.
const {DataCatalogClient} = require('@google-cloud/datacatalog').v1;
const datacatalog = new DataCatalogClient();

async function createCustomEntry() {
// Create a custom entry within an entry group.

/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'my_project';
// const entryGroupId = 'my_entry_group';
// const entryId = 'my_entry';
// const tagTemplateId = 'my_tag_template';

// Currently, Data Catalog stores metadata in the us-central1 region.
const location = 'us-central1';

// Delete any pre-existing Entry with the same name
// that will be used to create the new Entry.
try {
const entryName = datacatalog.entryPath(
projectId,
location,
entryGroupId,
entryId
);
await datacatalog.deleteEntry({name: entryName});
console.log(`Deleted Entry: ${entryName}`);
} catch (err) {
console.log('Entry does not exist.');
}

// Delete any pre-existing Entry Group with the same name
// that will be used to construct the new EntryGroup.
try {
const entryGroupName = datacatalog.entryGroupPath(
projectId,
location,
entryGroupId
);
await datacatalog.deleteEntryGroup({name: entryGroupName});
console.log(`Deleted Entry Group: ${entryGroupName}`);
} catch (err) {
console.log('Entry Group does not exist.');
}

// Delete any pre-existing Template with the same name
// that will be used to create a new Template.
const tagTemplateName = datacatalog.tagTemplatePath(
projectId,
location,
tagTemplateId
);

let tagTemplateRequest = {
name: tagTemplateName,
force: true,
};

try {
await datacatalog.deleteTagTemplate(tagTemplateRequest);
console.log(`Deleted template: ${tagTemplateName}`);
} catch (error) {
console.log(`Cannot delete template: ${tagTemplateName}`);
}

// Construct the EntryGroup for the EntryGroup request.
const entryGroup = {
displayName: 'My awesome Entry Group',
description: 'This Entry Group represents an external system',
};

// Construct the EntryGroup request to be sent by the client.
const entryGroupRequest = {
parent: datacatalog.locationPath(projectId, location),
entryGroupId: entryGroupId,
entryGroup: entryGroup,
};

// Use the client to send the API request.
const [createdEntryGroup] = await datacatalog.createEntryGroup(
entryGroupRequest
);
console.log(`Created entry group: ${createdEntryGroup.name}`);

// Construct the Entry for the Entry request.
const entry = {
userSpecifiedSystem: 'onprem_data_system',
userSpecifiedType: 'onprem_data_asset',
displayName: 'My awesome data asset',
description: 'This data asset is managed by an external system.',
linkedResource: '//my-onprem-server.com/dataAssets/my-awesome-data-asset',
schema: {
columns: [
{
column: 'first_column',
description: 'This columns consists of ....',
mode: 'NULLABLE',
type: 'STRING',
},
{
column: 'second_column',
description: 'This columns consists of ....',
mode: 'NULLABLE',
type: 'DOUBLE',
},
],
},
};

// Construct the Entry request to be sent by the client.
const entryRequest = {
parent: datacatalog.entryGroupPath(projectId, location, entryGroupId),
entryId: entryId,
entry: entry,
};

// Use the client to send the API request.
const [createdEntry] = await datacatalog.createEntry(entryRequest);
console.log(`Created entry: ${createdEntry.name}`);

// Create a Tag Template.
// For more field types, including ENUM, please refer to
// https://cloud.google.com/data-catalog/docs/quickstarts/quickstart-search-tag#data-catalog-quickstart-nodejs.
const fieldSource = {
displayName: 'Source of data asset',
type: {
primitiveType: 'STRING',
},
};

const tagTemplate = {
displayName: 'Demo Tag Template',
fields: {
source: fieldSource,
},
};

tagTemplateRequest = {
parent: datacatalog.locationPath(projectId, location),
tagTemplateId: tagTemplateId,
tagTemplate: tagTemplate,
};

// Use the client to send the API request.
const [createdTagTemplate] = await datacatalog.createTagTemplate(
tagTemplateRequest
);
console.log(`Created template: ${createdTagTemplate.name}`);

// Attach a Tag to the custom Entry.
const tag = {
template: createdTagTemplate.name,
fields: {
source: {
stringValue: 'On-premises system name',
},
},
};

const tagRequest = {
parent: createdEntry.name,
tag: tag,
};

// Use the client to send the API request.
const [createdTag] = await datacatalog.createTag(tagRequest);
console.log(`Created tag: ${createdTag.name}`);
}
createCustomEntry();
// [END data_catalog_create_custom_entry]
}
main(...process.argv.slice(2));
Loading