123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- package github
- import (
- "context"
- "fmt"
- "time"
- )
- type OrganizationsService service
- type Organization struct {
- Login *string `json:"login,omitempty"`
- ID *int64 `json:"id,omitempty"`
- AvatarURL *string `json:"avatar_url,omitempty"`
- HTMLURL *string `json:"html_url,omitempty"`
- Name *string `json:"name,omitempty"`
- Company *string `json:"company,omitempty"`
- Blog *string `json:"blog,omitempty"`
- Location *string `json:"location,omitempty"`
- Email *string `json:"email,omitempty"`
- Description *string `json:"description,omitempty"`
- PublicRepos *int `json:"public_repos,omitempty"`
- PublicGists *int `json:"public_gists,omitempty"`
- Followers *int `json:"followers,omitempty"`
- Following *int `json:"following,omitempty"`
- CreatedAt *time.Time `json:"created_at,omitempty"`
- UpdatedAt *time.Time `json:"updated_at,omitempty"`
- TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
- OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
- PrivateGists *int `json:"private_gists,omitempty"`
- DiskUsage *int `json:"disk_usage,omitempty"`
- Collaborators *int `json:"collaborators,omitempty"`
- BillingEmail *string `json:"billing_email,omitempty"`
- Type *string `json:"type,omitempty"`
- Plan *Plan `json:"plan,omitempty"`
- NodeID *string `json:"node_id,omitempty"`
-
- URL *string `json:"url,omitempty"`
- EventsURL *string `json:"events_url,omitempty"`
- HooksURL *string `json:"hooks_url,omitempty"`
- IssuesURL *string `json:"issues_url,omitempty"`
- MembersURL *string `json:"members_url,omitempty"`
- PublicMembersURL *string `json:"public_members_url,omitempty"`
- ReposURL *string `json:"repos_url,omitempty"`
- }
- func (o Organization) String() string {
- return Stringify(o)
- }
- type Plan struct {
- Name *string `json:"name,omitempty"`
- Space *int `json:"space,omitempty"`
- Collaborators *int `json:"collaborators,omitempty"`
- PrivateRepos *int `json:"private_repos,omitempty"`
- }
- func (p Plan) String() string {
- return Stringify(p)
- }
- type OrganizationsListOptions struct {
-
- Since int64 `url:"since,omitempty"`
-
-
-
- ListOptions
- }
- func (s *OrganizationsService) ListAll(ctx context.Context, opt *OrganizationsListOptions) ([]*Organization, *Response, error) {
- u, err := addOptions("organizations", opt)
- if err != nil {
- return nil, nil, err
- }
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
- orgs := []*Organization{}
- resp, err := s.client.Do(ctx, req, &orgs)
- if err != nil {
- return nil, resp, err
- }
- return orgs, resp, nil
- }
- func (s *OrganizationsService) List(ctx context.Context, user string, opt *ListOptions) ([]*Organization, *Response, error) {
- var u string
- if user != "" {
- u = fmt.Sprintf("users/%v/orgs", user)
- } else {
- u = "user/orgs"
- }
- u, err := addOptions(u, opt)
- if err != nil {
- return nil, nil, err
- }
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
- var orgs []*Organization
- resp, err := s.client.Do(ctx, req, &orgs)
- if err != nil {
- return nil, resp, err
- }
- return orgs, resp, nil
- }
- func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error) {
- u := fmt.Sprintf("orgs/%v", org)
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
- organization := new(Organization)
- resp, err := s.client.Do(ctx, req, organization)
- if err != nil {
- return nil, resp, err
- }
- return organization, resp, nil
- }
- func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organization, *Response, error) {
- u := fmt.Sprintf("organizations/%d", id)
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
- organization := new(Organization)
- resp, err := s.client.Do(ctx, req, organization)
- if err != nil {
- return nil, resp, err
- }
- return organization, resp, nil
- }
- func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) {
- u := fmt.Sprintf("orgs/%v", name)
- req, err := s.client.NewRequest("PATCH", u, org)
- if err != nil {
- return nil, nil, err
- }
-
- req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
- o := new(Organization)
- resp, err := s.client.Do(ctx, req, o)
- if err != nil {
- return nil, resp, err
- }
- return o, resp, nil
- }
|