Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Get Team By Name #2716

Closed
1 task done
dylan-asos opened this issue May 21, 2023 · 3 comments · Fixed by #2717
Closed
1 task done

[FEAT]: Get Team By Name #2716

dylan-asos opened this issue May 21, 2023 · 3 comments · Fixed by #2717
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@dylan-asos
Copy link
Contributor

Describe the need

The API docs specify that you can get a team by slug name, e.g.

Request
https://api.github.com/orgs/ORG/teams/TEAM_SLUG

Response

{
  "id": 1,
  "node_id": "MDQ6VGVhbTE=",
  "url": "https://api.github.com/teams/1",
  "html_url": "https://github.com/orgs/github/teams/justice-league",
  "name": "Justice League",
  "slug": "justice-league",
  "description": "A great team.",
  "privacy": "closed",
  "notification_setting": "notifications_enabled",
  "permission": "admin",
  "members_url": "https://api.github.com/teams/1/members{/member}",
  "repositories_url": "https://api.github.com/teams/1/repos",
  "parent": null,
  "members_count": 3,
  "repos_count": 10,
  "created_at": "2017-07-14T16:53:42Z",
  "updated_at": "2017-08-17T12:37:15Z",
  "organization": {
    "login": "github",
    "id": 1,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
    "url": "https://api.github.com/orgs/github",
    "repos_url": "https://api.github.com/orgs/github/repos",
    "events_url": "https://api.github.com/orgs/github/events",
    "hooks_url": "https://api.github.com/orgs/github/hooks",
    "issues_url": "https://api.github.com/orgs/github/issues",
    "members_url": "https://api.github.com/orgs/github/members{/member}",
    "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "description": "A great organization",
    "name": "github",
    "company": "GitHub",
    "blog": "https://github.com/blog",
    "location": "San Francisco",
    "email": "[email protected]",
    "is_verified": true,
    "has_organization_projects": true,
    "has_repository_projects": true,
    "public_repos": 2,
    "public_gists": 1,
    "followers": 20,
    "following": 0,
    "html_url": "https://github.com/octocat",
    "created_at": "2008-01-14T04:33:35Z",
    "updated_at": "2017-08-17T12:37:15Z",
    "type": "Organization"
  }
}

Implement the functionality for ITeamsClient

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@dylan-asos dylan-asos added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels May 21, 2023
@dylan-asos
Copy link
Contributor Author

As per the API docs :

To create the slug, GitHub replaces special characters in the name string, changes all words to lowercase, and replaces spaces with a - separator. For example, "My TEam Näme" would become my-team-name.

The method I've created takes a teamSlug and attempts no conversion, so we're expecting the caller to have done the work to convert to the slug format.

Should the library expose a string.ToSlug() method to help the caller? e.g.

string teamName = "My TEam Näme";

string teamSlug = teamName.ToSlug();

Team team = client.Organization.Team.GetByName("org", teamSlug);

Then a choice of letting the caller do the work via the helper, or convert for them within the GetByName method.

@timrogers
Copy link
Contributor

As per the API docs :

To create the slug, GitHub replaces special characters in the name string, changes all words to lowercase, and replaces spaces with a - separator. For example, "My TEam Näme" would become my-team-name.

The method I've created takes a teamSlug and attempts no conversion, so we're expecting the caller to have done the work to convert to the slug format.

Should the library expose a string.ToSlug() method to help the caller? e.g.

string teamName = "My TEam Näme";



string teamSlug = teamName.ToSlug();



Team team = client.Organization.Team.GetByName("org", teamSlug);

Then a choice of letting the caller do the work via the helper, or convert for them within the GetByName method.

Unfortunately, I don't think that'll be safe from an API perspective.

The slug is non-deterministic - for example, if you have multiple teams with the same name, then a number will be appended to the slug.

@nickfloyd nickfloyd moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active May 22, 2023
@dylan-asos
Copy link
Contributor Author

dylan-asos commented May 22, 2023

Yup @timrogers came to the same conclusion - will leave it to the caller.

@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels May 31, 2023
@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants