/**
 * Copyright 2019 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';

/**
 * Create a task for a given queue with an arbitrary payload.
 */
async function createTask(project, location, queue, payload, inSeconds) {
  // [START tasks_quickstart]
  // Imports the Google Cloud Tasks library.
  const {CloudTasksClient} = require('@google-cloud/tasks');

  // Instantiates a client.
  const client = new CloudTasksClient();

  // TODO(developer): Uncomment these lines and replace with your values.
  // const project = 'my-project-id';
  // const queue = 'my-appengine-queue';
  // const location = 'us-central1';
  // const payload = 'hello';

  // Construct the fully qualified queue name.
  const parent = client.queuePath(project, location, queue);

  const task = {
    appEngineHttpRequest: {
      httpMethod: 'POST',
      relativeUri: '/log_payload',
    },
  };

  if (payload) {
    task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64');
  }

  if (inSeconds) {
    task.scheduleTime = {
      seconds: inSeconds + Date.now() / 1000,
    };
  }

  const request = {
    parent: parent,
    task: task,
  };

  console.log('Sending task:');
  console.log(task);
  // Send create task request.
  const [response] = await client.createTask(request);
  const name = response.name;
  console.log(`Created task ${name}`);

  // [END tasks_quickstart]
}

createTask(...process.argv.slice(2)).catch(console.error);

@@ -1,14 +1,10 @@
 /
-**%0A *
+/
  Copyrig
@@ -22,18 +22,21 @@
 gle LLC%0A
- *
+//%0A//
  License
@@ -92,18 +92,18 @@
 ense%22);%0A
- *
+//
  you may
@@ -160,18 +160,18 @@
 icense.%0A
- *
+//
  You may
@@ -203,21 +203,23 @@
 ense at%0A
- *%0A *
+//%0A//  
     http
@@ -261,13 +261,13 @@
 2.0%0A
- *%0A *
+//%0A//
  Unl
@@ -331,18 +331,18 @@
 oftware%0A
- *
+//
  distrib
@@ -400,18 +400,18 @@
  BASIS,%0A
- *
+//
  WITHOUT
@@ -476,18 +476,18 @@
 mplied.%0A
- *
+//
  See the
@@ -547,18 +547,18 @@
 ons and%0A
- *
+//
  limitat
@@ -580,20 +580,16 @@
 License.
-%0A */
 %0A%0A'use s

update license headers (#310)