cli/pkg/cmd/repo/archive/http.go
Parth ec554822b8
Add repo archive command (#4410)
Co-authored-by: meiji163 <mysatellite99@gmail.com>
2021-10-12 12:48:40 +02:00

32 lines
718 B
Go

package archive
import (
"context"
"net/http"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/internal/ghinstance"
"github.com/shurcooL/githubv4"
"github.com/shurcooL/graphql"
)
func archiveRepo(client *http.Client, repo *api.Repository) error {
var mutation struct {
ArchiveRepository struct {
Repository struct {
ID string
}
} `graphql:"archiveRepository(input: $input)"`
}
variables := map[string]interface{}{
"input": githubv4.ArchiveRepositoryInput{
RepositoryID: repo.ID,
},
}
host := repo.RepoHost()
gql := graphql.NewClient(ghinstance.GraphQLEndpoint(host), client)
err := gql.MutateNamed(context.Background(), "ArchiveRepository", &mutation, variables)
return err
}