Skip to content

Commit

Permalink
Add initial reponse types
Browse files Browse the repository at this point in the history
This commit adds the initial data structures to capture the following v2/apis:

- v2/alternative
- v2/license
- v2/pkg
- v2/similar

These rely on the objects defined in the previous commits.

Signed-off-by: Adolfo García Veytia (puerco) <[email protected]>
  • Loading branch information
puerco committed Oct 10, 2024
1 parent d529703 commit bcc68f0
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/types/v2/responses/alternative.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2024 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package responses

import "github.com/stacklok/trusty-sdk-go/pkg/types/v2/objects"

// Example: 'https://api.trustypkg.dev/v2/alternatives?package_name=react&package_type=npm'

// Alternatives captures the response from the v2/alternatives API call.
type Alternatives struct {
Status *string
Packages []*objects.AlternativePackage `json:"packages"`
}
17 changes: 17 additions & 0 deletions pkg/types/v2/responses/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package responses has the data structures toread the responses from the
// Trusty API. These types use the structs defined in the v2/objects package.
package responses
23 changes: 23 additions & 0 deletions pkg/types/v2/responses/license.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package responses

import "github.com/stacklok/trusty-sdk-go/pkg/types/v2/objects"

// License captures the response of the v2/license API call.
type License struct {
License *objects.LicenseIdentifier
Claims []*objects.LicenseClaim
}
23 changes: 23 additions & 0 deletions pkg/types/v2/responses/pkg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package responses

import "github.com/stacklok/trusty-sdk-go/pkg/types/v2/objects"

// Pkg captures the reply from the v2/pkg call. This API call returns the
// full data about a pacakge known to Trusty.
type Pkg struct {
objects.Pkg
}
25 changes: 25 additions & 0 deletions pkg/types/v2/responses/similar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2024 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package responses

import "github.com/stacklok/trusty-sdk-go/pkg/types/v2/objects"

// Example: 'https://api.trustypkg.dev/v2/similar?package_name=react&package_type=npm'

// Similar is the response from the v2/similar API call. It is a list of packages
// with names that sound similar to the queried package.
type Similar struct {
Packages []*objects.SimilarPackage `json:"similar_package_names"`
}

0 comments on commit bcc68f0

Please sign in to comment.