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.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package consoleql
|
2018-12-27 15:30:15 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/graphql-go/graphql"
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
"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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 satellite.APIKey and satellite.APIKeyInfo
|
|
|
|
type createAPIKey struct {
|
2019-01-15 13:03:24 +00:00
|
|
|
Key *console.APIKey
|
|
|
|
KeyInfo *console.APIKeyInfo
|
2018-12-27 15:30:15 +00:00
|
|
|
}
|