storj/satellite/console/consoleweb/consoleql/apikey.go

66 lines
1.5 KiB
Go
Raw Normal View History

2019-01-24 16:26:36 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
2018-12-27 15:30:15 +00:00
// See LICENSE for copying information.
package consoleql
2018-12-27 15:30:15 +00:00
import (
"github.com/graphql-go/graphql"
"storj.io/storj/satellite/console"
2018-12-27 15:30:15 +00:00
)
const (
2019-01-24 16:26:36 +00:00
// APIKeyInfoType is graphql type name for api key
APIKeyInfoType = "keyInfo"
// CreateAPIKeyType is graphql type name for createAPIKey struct
// which incapsulates the actual key and it's info
CreateAPIKeyType = "graphqlCreateAPIKey"
// FieldKey is field name for the actual key in createAPIKey
FieldKey = "key"
2018-12-27 15:30:15 +00:00
)
// graphqlAPIKeyInfo creates satellite.APIKeyInfo graphql object
func graphqlAPIKeyInfo() *graphql.Object {
return graphql.NewObject(graphql.ObjectConfig{
2019-01-24 16:26:36 +00:00
Name: APIKeyInfoType,
2018-12-27 15:30:15 +00:00
Fields: graphql.Fields{
2019-01-24 16:26:36 +00:00
FieldID: &graphql.Field{
2018-12-27 15:30:15 +00:00
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldProjectID: &graphql.Field{
2018-12-27 15:30:15 +00:00
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldName: &graphql.Field{
2018-12-27 15:30:15 +00:00
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldCreatedAt: &graphql.Field{
2018-12-27 15:30:15 +00:00
Type: graphql.DateTime,
},
FieldPartnerID: &graphql.Field{
Type: graphql.String,
},
2018-12-27 15:30:15 +00:00
},
})
}
// graphqlCreateAPIKey creates createAPIKey graphql object
2019-04-04 15:56:20 +01:00
func graphqlCreateAPIKey(types *TypeCreator) *graphql.Object {
2018-12-27 15:30:15 +00:00
return graphql.NewObject(graphql.ObjectConfig{
2019-01-24 16:26:36 +00:00
Name: CreateAPIKeyType,
2018-12-27 15:30:15 +00:00
Fields: graphql.Fields{
2019-01-24 16:26:36 +00:00
FieldKey: &graphql.Field{
2018-12-27 15:30:15 +00:00
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
APIKeyInfoType: &graphql.Field{
2019-04-04 15:56:20 +01:00
Type: types.apiKeyInfo,
2018-12-27 15:30:15 +00:00
},
},
})
}
// createAPIKey holds macaroon.APIKey and console.APIKeyInfo
2018-12-27 15:30:15 +00:00
type createAPIKey struct {
Key string
KeyInfo *console.APIKeyInfo
2018-12-27 15:30:15 +00:00
}