我有以下一段代码,我想一旦你看到我的问题就会很明显。
trait hasId {
def id: String
}
trait hasCount {
def count: Int
}
case class Foo(id: String, count: Int) extends hasId with hasCount
// This is the function I want to write
def printData(data: hasId and hasCount): Unit = {
println(data.id + ": " data.count);
}
Run Code Online (Sandbox Code Playgroud)
我应该如何声明函数签名?
我试图通过其REST Api访问Google的数据存储。它说他们允许通过API密钥进行身份验证。但是,似乎无法在任何地方使用它。我复制了从他们的Try this API页面生成的摘录。
curl --request POST \
'https://datastore.googleapis.com/v1/projects/PROJECT_ID:runQuery?key=[YOUR_API_KEY]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"query":{"filter":{"compositeFilter":{"op":"AND","filters":[{"propertyFilter":{"property":{"name":"id"},"op":"EQUAL","value":{"stringValue":"ID"}}}]}},"kind":[{"name":"NAME"}]},"partitionId":{"namespaceId":"NAMESPACE_ID","projectId":"PROJECT_ID"}}' \
--compressed
Run Code Online (Sandbox Code Playgroud)
但是它一直向我返回401错误。
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Run Code Online (Sandbox Code Playgroud)
似乎要求我改用OAuth,但这不是他们的文档所说的。任何人都经历过类似的事情吗?