private static class AllPrefixes extends DoFn<CompletionCandidate, KV<String, CompletionCandidate>> { private final int minPrefix; private final int maxPrefix; public AllPrefixes(int minPrefix) { this(minPrefix, Integer.MAX_VALUE); } public AllPrefixes(int minPrefix, int maxPrefix) { this.minPrefix = minPrefix; this.maxPrefix = maxPrefix; } @Override public void processElement(ProcessContext c) { String word = c.element().value; for (int i = minPrefix; i <= Math.min(word.length(), maxPrefix); i++) { c.output(KV.of(word.substring(0, i), c.element())); } } }
@Override public void populateDisplayData(DisplayData.Builder builder) { super.populateDisplayData(builder); builder .add(DisplayData.item("MinimumPrefixLength", minPrefix)) .addIfNotDefault(DisplayData.item("MaximumPrefixLength", maxPrefix), Integer.MAX_VALUE); }
@Override public void populateDisplayData(DisplayData.Builder builder) { super.populateDisplayData(builder); builder .add(DisplayData.item("size", size) .withLabel("Window Size")) .add(DisplayData.item("period", period) .withLabel("Window Period")) .add(DisplayData.item("offset", offset) .withLabel("Window Start Offset")); }
gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER canvas-syntax-130823 scesproject2 346904393285 windy-bearing-129522 scesproject1 222844913538
gcloud projects list --format="json"
[ { "createTime": "2016-04-28T22:33:12.274Z", "labels": { "env": "test", "version": "alpha" }, "lifecycleState": "ACTIVE", "name": "scesproject1", "parent": { "id": "297814986428", "type": "organization" }, "projectId": "windy-bearing-129522", "projectNumber": "222844913538" }, { "createTime": "2016-05-11T03:08:13.359Z", "labels": { "env": "test", "version": "beta" }, "lifecycleState": "ACTIVE", "name": "scesproject2", "parent": { "id": "297814986428", "type": "organization" }, "projectId": "canvas-syntax-130823", "projectNumber": "346904393285" } ]
gcloud projects list --format="table[box,title='My Project List'](createTime:sort=1,name,projectNumber,projectId:label=ProjectID,parent.id:label=Parent)"
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ My Project List │ ├──────────────────────────┬──────────────┬────────────────┬──────────────────────┬──────────────┤ │ CREATE_TIME │ NAME │ PROJECT_NUMBER │ ProjectID │ Parent │ ├──────────────────────────┼──────────────┼────────────────┼──────────────────────┼──────────────┤ │ 2016-04-28T22:33:12.274Z │ scesproject1 │ 222844913538 │ windy-bearing-129522 │ 297814986428 │ │ 2016-05-11T03:08:13.359Z │ scesproject2 │ 346904393285 │ canvas-syntax-130823 │ 297814986428 │ └──────────────────────────┴──────────────┴────────────────┴──────────────────────┴──────────────┘
gcloud projects list --format="table(createTime.date('%Y-%m-%d'),name,projectNumber,projectId)"
CREATE_TIME NAME PROJECT_NUMBER PROJECT_ID 2016-05-11 scesproject2 346904393285 canvas-syntax-130823 2016-04-28 scesproject1 222844913538 windy-bearing-129522
gcloud compute zones list --format="json"
{ "creationTimestamp": "2014-05-30T18:35:16.514-07:00", "description": "us-central1-a", "id": "2000", "kind": "compute#zone", "name": "us-central1-a", "region": "us-central1", "selfLink": "https://www.googleapis.com/compute/v1/projects/windy-bearing-129522/ zones/us-central1-a", "status": "UP" },
gcloud compute zones list --format="value(selfLink.scope())"
us-central1-a
gcloud compute zones list --format="value(selfLink.basename())"
gcloud compute zones list --format="value(selfLink.scope(projects))"
windy-bearing-129522/zones/us-central1-a
gcloud compute instances list --format="json"
"serviceAccounts": [ { "email": "1071284184436-compute@developer.gserviceaccount.com", "scopes": [ "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring.write", "https://www.googleapis.com/auth/cloud.useraccounts.readonly" ] } ],
gcloud compute instances list --format="flattened(name,serviceAccounts[].email,serviceAccounts[].scopes[].basename())"
name: instance-1 serviceAccounts[0].email: 1071284184436-compute@developer.gserviceaccount.com serviceAccounts[0].scopes[0]: devstorage.read_only serviceAccounts[0].scopes[1]: logging.write serviceAccounts[0].scopes[2]: monitoring.write serviceAccounts[0].scopes[3]: cloud.useraccounts.readonly
gcloud compute instances list --filter=name:instance-1 --flatten="serviceAccounts[].scopes[]" --format="csv(name,id,serviceAccounts.email,serviceAccounts.scopes.basename())"
name,id,email,scopes instance-1,763097360168409044,1071284184436-compute@developer.gserviceaccount.com, devstorage.read_only instance-1,763097360168409044,1071284184436-compute@developer.gserviceaccount.com, logging.write instance-1,763097360168409044,1071284184436-compute@developer.gserviceaccount.com, monitoring.write instance-1,763097360168409044,1071284184436-compute@developer.gserviceaccount.com, servicecontrol instance-1,763097360168409044,1071284184436-compute@developer.gserviceaccount.com, service.management
gcloud compute instances list --filter=name:instance-1 --format="table[box,no-heading](name,id,serviceAccounts:format='table[box,no-heading](email,scopes:format=\"table[box,no-heading](.)\")')"
┌────────────┬────────────────────┐ │ instance-1 │ 763097360168409044 │ └────────────┴────────────────────┘ ┌────────────────────────────────────────────────────┐ │ 1071284184431-compute@developer.gserviceaccount.com│ └────────────────────────────────────────────────────┘ ┌──────────────────────────────────────────────────────┐ │ https://www.googleapis.com/auth/devstorage.read_only │ │ https://www.googleapis.com/auth/logging.write │ │ https://www.googleapis.com/auth/monitoring.write │ │ https://www.googleapis.com/auth/servicecontrol │ │ https://www.googleapis.com/auth/service.management │ └──────────────────────────────────────────────────────┘
gcloud beta iam service-accounts keys list --iam-account svc-2-429@mineral-minutia-820.iam.gserviceaccount.com --project mineral-minutia-820 --format="json"
[ { "name": "projects/mineral-minutia-820/serviceAccounts/svc-2-429@mineral -minutia-820.iam.gserviceaccount.com/keys/ 04bd2d56d0cc5746b125d17f95d4b0dd654accca", "validAfterTime": "2016-03-11T05:30:04.000Z", "validBeforeTime": "2026-03-09T05:30:04.000Z" }, { "name": "projects/mineral-minutia-820/serviceAccounts/svc-2- 429@mineral-minutia-820.iam.gserviceaccount.com/keys/ 1deb44e2f54328fc7bb316e5a87315e3314f114f", "validAfterTime": "2016-01-02T18:54:26.000Z", "validBeforeTime": "2025-12-30T18:54:26.000Z" }, .... ]
gcloud beta iam service-accounts keys list --iam-account svc-2-429@mineral-minutia-820.iam.gserviceaccount.com --project mineral-minutia-820 --format="table(name.scope(serviceAccounts).segment(0):label='service Account',name.scope(keys):label='keyID',validAfterTime)"
gcloud projects list --format="json" --filter="labels.env=test AND labels.version=alpha"
[ { "createTime": "2016-04-28T22:33:12.274Z", "labels": { "env": "test", "version": "alpha" }, "lifecycleState": "ACTIVE", "name": "scesproject1", "parent": { "id": "297814986428", "type": "organization" }, "projectId": "windy-bearing-129522", "projectNumber": "222844913538" } ]
gcloud projects list --format="table(projectNumber,projectId,createTime)" --filter="createTime.date('%Y-%m-%d', Z)='2016-05-11'"
PROJECT_NUMBER PROJECT_ID CREATE_TIME 346904393285 canvas-syntax-130823 2016-05-11T03:08:13.359Z
gcloud projects list --format="table(projectId,parent.id.yesno(yes="YES", no=”NO”):label='Has Parent':sort=2)"
PROJECT_ID Has Parent mineral-minutia-820 NO fabled-ray-104117 YES rk-test-0506 YES user2proj1 YES user2project2 YES
gcloud compute instances list --format="flattened(name,serviceAccounts[].email,serviceAccounts[].scopes.map().scope())"
#!/bin/bash for project in $(gcloud projects list --format="value(projectId)") do echo "ProjectId: $project" for robot in $(gcloud beta iam service-accounts list --project $project --format="value(email)") do echo " -> Robot $robot" for key in $(gcloud beta iam service-accounts keys list --iam-account $robot --project $project --format="value(name.basename())") do echo " $key" done done done
foreach ($project in gcloud projects list --format="value(projectId)") { Write-Host "ProjectId: $project" foreach ($robot in gcloud beta iam service-accounts list --project $project --format="value(email)") { Write-Host " -> Robot $robot" foreach ($key in gcloud beta iam service-accounts keys list --iam-account $robot --project $project --format="value(name.basename())") { Write-Host " $key" } } }
#!/bin/bash for scopesInfo in $( gcloud compute instances list --filter=name:instance-1 \ --format="csv[no-heading](name,id,serviceAccounts[].email.list(), serviceAccounts[].scopes[].map().list(separator=;))") do IFS=',' read -r -a scopesInfoArray<<< "$scopesInfo" NAME="${scopesInfoArray[0]}" ID="${scopesInfoArray[1]}" EMAIL="${scopesInfoArray[2]}" SCOPES_LIST="${scopesInfoArray[3]}" echo "NAME: $NAME, ID: $ID, EMAIL: $EMAIL" echo "" IFS=';' read -r -a scopeListArray<<< "$SCOPES_LIST" for SCOPE in "${scopeListArray[@]}" do echo " SCOPE: $SCOPE" done done
gcloud beta debug logpoints create
$ gcloud beta debug logpoints create MarkovServlet.java:114 "Hello seed {seed}"
「それでもサイトは無事始動し、万々歳です」(Tidwell 氏)
Welcome to ____ __ / __/__ ___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /___/ .__/\_,_/_/ /_/\_\ version 2.0.0-preview /_/ Using Scala version 2.11.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_91) Type in expressions to have them evaluated. Type :help for more information. scala> spark res0: org.apache.spark.sql.SparkSession = org.apache.spark.sql.SparkSession@68f9e807
val csvData = spark.read.csv("gs://my-bucket/project-data/csv")