function _M.addSubscription()

in scripts/lua/management/lib/subscriptions.lua [25:37]


function _M.addSubscription(dataStore, artifactId, tenantId, clientId, clientSecret, hashFunction)
  local subscriptionKey = utils.concatStrings({"subscriptions:tenant:", tenantId, ":api:", artifactId})
  dataStore:setSnapshotId(tenantId)
  if clientSecret ~= nil then
    if hashFunction == nil then
      hashFunction = utils.hash
    end
    subscriptionKey = utils.concatStrings({subscriptionKey, ":clientsecret:", clientId, ":", hashFunction(clientSecret)})
  else
    subscriptionKey = utils.concatStrings({subscriptionKey, ":key:", clientId})
  end
  dataStore:createSubscription(subscriptionKey)
end