storj/pkg/satellite/satelliteweb/satelliteql/apikey.go
2018-12-27 17:30:15 +02:00

60 lines
1.2 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package satelliteql
import (
"github.com/graphql-go/graphql"
"storj.io/storj/pkg/satellite"
)
const (
apiKeyInfoType = "keyInfo"
createAPIKeyType = "graphqlCreateAPIKey"
fieldKey = "key"
)
// graphqlAPIKeyInfo creates satellite.APIKeyInfo graphql object
func graphqlAPIKeyInfo() *graphql.Object {
return graphql.NewObject(graphql.ObjectConfig{
Name: apiKeyInfoType,
Fields: graphql.Fields{
fieldID: &graphql.Field{
Type: graphql.String,
},
fieldProjectID: &graphql.Field{
Type: graphql.String,
},
fieldName: &graphql.Field{
Type: graphql.String,
},
fieldCreatedAt: &graphql.Field{
Type: graphql.DateTime,
},
},
})
}
// graphqlCreateAPIKey creates createAPIKey graphql object
func graphqlCreateAPIKey(types Types) *graphql.Object {
return graphql.NewObject(graphql.ObjectConfig{
Name: createAPIKeyType,
Fields: graphql.Fields{
fieldKey: &graphql.Field{
Type: graphql.String,
},
apiKeyInfoType: &graphql.Field{
Type: types.APIKeyInfo(),
},
},
})
}
// createAPIKey holds satellite.APIKey and satellite.APIKeyInfo
type createAPIKey struct {
Key *satellite.APIKey
KeyInfo *satellite.APIKeyInfo
}