Debian Codegraph @

plugin/describekey.go

raw symbols SCIP
1 // Copyright The Notary Project Authors.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package plugin
15
16 // DescribeKeyRequest contains the parameters passed in a describe-key request.
17 type DescribeKeyRequest struct {
18 ContractVersion string `json:"contractVersion"`
19 KeyID string `json:"keyId"`
20 PluginConfig map[string]string `json:"pluginConfig,omitempty"`
21 }
22
23 func (DescribeKeyRequest) Command() Command {
24 return CommandDescribeKey
25 }
26
27 // Validate validates DescribeKeyRequest struct
28 func (r DescribeKeyRequest) Validate() error {
29 if r.ContractVersion == "" {
30 return NewValidationError("contractVersion cannot be empty")
31 }
32
33 if r.KeyID == "" {
34 return NewValidationError("keyId cannot be empty")
35 }
36
37 return nil
38 }
39
40 // DescribeKeyResponse is the response of a describe-key request.
41 type DescribeKeyResponse struct {
42 // The same key id as passed in the request.
43 KeyID string `json:"keyId"`
44
45 // One of following supported key types:
46 // https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
47 KeySpec KeySpec `json:"keySpec"`
48 }