123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- package github
- import (
- "context"
- "fmt"
- )
- type LicensesService service
- type RepositoryLicense struct {
- Name *string `json:"name,omitempty"`
- Path *string `json:"path,omitempty"`
- SHA *string `json:"sha,omitempty"`
- Size *int `json:"size,omitempty"`
- URL *string `json:"url,omitempty"`
- HTMLURL *string `json:"html_url,omitempty"`
- GitURL *string `json:"git_url,omitempty"`
- DownloadURL *string `json:"download_url,omitempty"`
- Type *string `json:"type,omitempty"`
- Content *string `json:"content,omitempty"`
- Encoding *string `json:"encoding,omitempty"`
- License *License `json:"license,omitempty"`
- }
- func (l RepositoryLicense) String() string {
- return Stringify(l)
- }
- type License struct {
- Key *string `json:"key,omitempty"`
- Name *string `json:"name,omitempty"`
- URL *string `json:"url,omitempty"`
- SPDXID *string `json:"spdx_id,omitempty"`
- HTMLURL *string `json:"html_url,omitempty"`
- Featured *bool `json:"featured,omitempty"`
- Description *string `json:"description,omitempty"`
- Implementation *string `json:"implementation,omitempty"`
- Permissions *[]string `json:"permissions,omitempty"`
- Conditions *[]string `json:"conditions,omitempty"`
- Limitations *[]string `json:"limitations,omitempty"`
- Body *string `json:"body,omitempty"`
- }
- func (l License) String() string {
- return Stringify(l)
- }
- func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) {
- req, err := s.client.NewRequest("GET", "licenses", nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeLicensesPreview)
- var licenses []*License
- resp, err := s.client.Do(ctx, req, &licenses)
- if err != nil {
- return nil, resp, err
- }
- return licenses, resp, nil
- }
- func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) {
- u := fmt.Sprintf("licenses/%s", licenseName)
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeLicensesPreview)
- license := new(License)
- resp, err := s.client.Do(ctx, req, license)
- if err != nil {
- return nil, resp, err
- }
- return license, resp, nil
- }
|