-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
kind_api.go
60 lines (46 loc) · 2.01 KB
/
kind_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package backstage
import (
"context"
"net/http"
)
// KindAPI defines name for API kind.
const KindAPI = "API"
// ApiEntityV1alpha1 describes an interface that can be exposed by a component. The API can be defined in different formats,
// like OpenAPI, AsyncAPI, GraphQL, gRPC, or other formats.
// https://github.com/backstage/backstage/blob/master/packages/catalog-model/src/schema/kinds/API.v1alpha1.schema.json
type ApiEntityV1alpha1 struct {
Entity
// ApiVersion is always "backstage.io/v1alpha1".
ApiVersion string `json:"apiVersion" yaml:"apiVersion"`
// Kind is always "API".
Kind string `json:"kind" yaml:"kind"`
// Spec is the specification data describing the API itself.
Spec *ApiEntityV1alpha1Spec `json:"spec" yaml:"spec"`
}
// ApiEntityV1alpha1Spec describes the specification data describing the API itself.
type ApiEntityV1alpha1Spec struct {
// Type of the API definition.
Type string `json:"type" yaml:"type"`
// Lifecycle state of the API.
Lifecycle string `json:"lifecycle" yaml:"lifecycle"`
// Owner is entity reference to the owner of the API.
Owner string `json:"owner" yaml:"owner"`
// Definition of the API, based on the format defined by the type.
Definition string `json:"definition" yaml:"definition"`
// System is entity reference to the system that the API belongs to.
System string `json:"system,omitempty" yaml:"system,omitempty"`
}
// apiService handles communication with the API related methods of the Backstage Catalog API.
type apiService typedEntityService[ComponentEntityV1alpha1]
// newApiService returns a new instance of API-type entityService.
func newApiService(s *entityService) *apiService {
return &apiService{
client: s.client,
apiPath: s.apiPath,
}
}
// Get returns an API entity identified by the name and the namespace ("default", if not specified) it belongs to.
func (s *apiService) Get(ctx context.Context, n string, ns string) (*ApiEntityV1alpha1, *http.Response, error) {
cs := (typedEntityService[ApiEntityV1alpha1])(*s)
return cs.get(ctx, KindAPI, n, ns)
}