Ohara: Refactor all api to support group and name

Created on 21 Jun 2019  ·  3Comments  ·  Source: oharastream/ohara

related issues: #1711 #1734

1. 每個 Object 的 Unique key 由三個部分組成: type, group, name

  • 使用者不用提供 type,根據 API 類型而定,不同 API 會有不同的值
  • 使用者可以選擇是否提供 group,不提供的話,後端會使用預設值
  • 使用者可以選擇是否提供 name,不提供的話,由後端自動(Random)產生

2. 允許增加任何額外的資訊,放到 Object 的 props 裡,例如:

{ group: 'wk00', name: 'afa23fAf3', props: { name: 'My first pipeline', tags: [], }, ... }

  • 最上層的 name 與 props 的 name 是不一樣的東西
  • 每個物件一定會擁有最上層的 name,作為Resource ID 使用,一但建立後,就不能再修改
  • props 裡面的 name 是給使用者識別用,可有可無,甚至可以修改,完全視 UI 需要而定

3. UI 流程 及 相關 API 範例:

  • 建立一個名為 "wk00" 的 Workspace,建立後不允許修改名稱

    POST /v0/workers
    
    {
    name: 'wk00',
    ...
    }
    
    • 上傳 Stream App Jar,需指定某個 Workspace 的 name 作為 group
    POST /v0/stream/jars
    
    Content-Type: multipart/form-data
    group="wk00"
    streamapp="my-streamApp.jar"
    
    • 建立 Pipeline,需指定某個 Workspace,例如 wk00
    POST /v0/pipelines
    
    {
      group: 'wk00',
      props: {
        name: 'Untitled pipeline',
      },
      ...
    }
    
    • 列出所有 Pipelines
    GET /v0/pipelines
    
    [{
      grooup: 'wk00',
      name: 'afDa8dfA2',
      props: {
        name: 'Untitled pipeline',
      },
      ...
    }]
    
    • 編輯 Pipeline
    GET /v0/pipelines/afDa8dfA2?group=wk00
    
    {
      grooup: 'wk00',
      name: 'afDa8dfA2',
      props: {
        name: 'Untitled pipeline',
      },
      ...
    }
    
    • 修改 Pipeline 的名稱
    PUT /v0/pipeline/afDa8dfA2?group=wk00
    
    {
      props: {
        name: 'My first pipeline',
      },
      ...
    }
    
    • 列出這個 Pipeline 可以使用的所有 Stream App Jar

    GET /v0/stream/jars?group=wk00
    
    [{
      group: 'wk00',
      name: 'my-streamApp',
      extenion: 'jar',
    },
    ...]

needs investigation

Most helpful comment

/cc @chia7712 @saivirtue @konekoya @wu87988622 @jackyoh @vitojeng

All 3 comments

/cc @chia7712 @saivirtue @konekoya @wu87988622 @jackyoh @vitojeng

  1. 允許增加任何額外的資訊,放到 Object 的 props 裡,例如:

這個是上周會議後與 @eechih 討論的新欄位,tags與其他使用者可以自訂的參數(如name)都會放到這裡面
整理來看我覺得沒什麼問題,+1

all related issues are created. close this.

Was this page helpful?
0 / 5 - 0 ratings