Proje Yönetimi

Apps Script API, uygulamanızdan Apps Script projeleri oluşturmanıza ve değiştirmenize olanak tanır. Bu sayfadaki örnekler, bazı yaygın proje yönetimi işlemlerinin API ile nasıl gerçekleştirilebileceğini gösterir.

NOT: Apps Script API'nin kullanılabilmesi için etkinleştirilmesi gerekir.

Bu örneklerde, komut dosyası projesi kimliğini nerede sağlayacağınızı belirtmek için scriptId yer tutucusu kullanılır. Komut dosyası kimliğini bulmak için aşağıdaki adımları uygulayın:

  1. Apps Komut Dosyası projesinde, sol üstte Proje Ayarları'nı tıklayın.
  2. "Komut dosyası kimliği"nin yanındaki Kopyala'yı tıklayın.

Yeni bir Apps Komut Dosyası projesi oluşturma

Aşağıdaki projects.create isteği yeni bir bağımsız komut dosyası oluşturur.

POST https://scriptmanagement.googleapis.com/v1/projects/
{
  "title": "My Script"
}

Proje meta verilerini alma

Aşağıdaki projects.get isteği, komut dosyası projesinin meta verilerini alır.

GET https://scriptmanagement.googleapis.com/v1/projects/scriptId

Yanıt, aşağıdaki gibi bir nesneden oluşur:

{
  "scriptId": "scriptId",
  "title": "My Title",
  "parentId": "parentId",
  "createTime": "2017-10-02T15:01:23.045123456Z",
  "updateTime": "2017-10-02T15:01:23.045123456Z",
  "creator": { "name": "Grant" },
  "lastModifyUser": { "name": "Grant" },
}

Proje dosyalarını alma

Aşağıdaki projects.getContent isteği, her komut dosyası dosyasının kod kaynağı ve meta verileri dahil olmak üzere komut dosyası projesinin içeriğini alır.

GET https://scriptmanagement.googleapis.com/v1/projects/scriptId/content

Yanıt, aşağıdaki gibi bir Content nesnesinden oluşur:

{
  "scriptId": "scriptId",
  "files": [{
    "name": "My Script",
    "type": "SERVER_JS",
    "source": "function hello(){\nconsole.log('Hello world');}",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z",
    "functionSet": {
      "values": [
        "name": "helloWorld"
      ]
    }
  }, {
    "name": "appsscript",
    "type": "JSON",
    "source": "{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z"
  }]
}

Proje dosyalarını güncelleme

Aşağıdaki projects.updateContent isteği, belirtilen komut dosyası projesinin içeriğini günceller. Bu içerik, HEAD sürümü olarak depolanır ve komut dosyası API yürütülebilir projesi olarak yürütüldüğünde kullanılır.

PUT https://scriptmanagement.googleapis.com/v1/projects/scriptID/content
{
  "files": [{
    "name": "index",
    "type": "HTML",
    "source": "<html> <header><title>HTML Page</title></header> <body> My HTML </body> </html>"
  }, {
    "name": "My Script",
    "type": "SERVER_JS",
    "source": "function hello(){\nconsole.log('Hello world');}",
  }, {
    "name": "appsscript",
    "type": "JSON",
    "source": "{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z"
  }]
}

Yanıt, aşağıdaki gibi bir Content nesnesinden oluşur:

{
  "scriptId": "scriptId",
  "files": [{
    "name": "index",
    "type": "HTML",
    "source": "<html> <header><title>HTML Page</title></header> <body> My HTML </body> </html>",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z"
  }, {
    "name": "My Script",
    "type": "SERVER_JS",
    "source": "function hello(){\nconsole.log('Hello world');}",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z",
    "functionSet": {
      "values": [
        "name": "helloWorld"
      ]
    }
  }, {
    "name": "appsscript",
    "type": "JSON",
    "source": "{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}",
    "lastModifyUser": {
      "name": "Grant",
      "email": "grant@example.com",
    },
    "createTime": "2017-10-02T15:01:23.045123456Z",
    "updateTime": "2017-10-02T15:01:23.045123456Z"
  }]
}