github_types/
previews.rs

1// Copyright (c) 2019 Jason White
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21use std::fmt;
22
23/// API previews.
24///
25/// See: https://developer.github.com/v3/previews/
26#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub enum Preview {
28    /// Allows you to download repositories from your GitHub user or
29    /// organization account to review, backup, and migrate data to GitHub
30    /// Enterprise Server.
31    Wyandotte,
32
33    /// Import source repositories to GitHub with the API version of the GitHub
34    /// Importer.
35    BarredRock,
36
37    /// Exercise greater control over deployments with more information and
38    /// finer granularity.
39    AntMan,
40
41    /// Manage reactions for commits, issues, and comments.
42    SquirrelGirl,
43
44    /// Get a list of events for an issue or pull request.
45    Mockingbird,
46
47    /// Get more information about your GitHub Pages site.
48    MisterFantastic,
49
50    /// Manage integrations through the API.
51    MachineMan,
52
53    /// Manage projects.
54    Inertia,
55
56    /// Search commits.
57    Cloak,
58
59    /// Retrieve community profile metrics (also known as community health) for
60    /// any public repository.
61    BlackPanther,
62
63    /// Users can block other users. Organizations can block users, too.
64    GiantSentryFist,
65
66    /// View a list of repository topics in calls that return repository
67    /// results.
68    Mercy,
69
70    /// View all codes of conduct or get which code of conduct a repository has
71    /// currently.
72    ScarletWitch,
73
74    /// Include nested team content in team payloads.
75    Hellcat,
76
77    /// Transfer a repository to an organization or user.
78    Nightshade,
79
80    /// You can now add a reason when you lock an issue.
81    SailorV,
82
83    /// You can now use the API to invite new users to an organization by
84    /// creating an organization invitation.
85    Dazzler,
86
87    /// You can now use the API to manage team discussions and team discussion
88    /// comments.
89    Echo,
90
91    /// You can now use emoji in label names, add descriptions to labels, and
92    /// search for labels in a repository.
93    Symmetra,
94
95    /// You can now use the API to manage the setting for requiring signed
96    /// commits on protected branches.
97    Zzzax,
98
99    /// You can now require multiple approving reviews for a pull request using
100    /// the API.
101    LukeCage,
102
103    /// Retrieve information from someone's hovercard.
104    Hagar,
105
106    /// Allows a GitHub App to run external checks on a repository's code. See
107    /// the Check runs and Check suites APIs for more details.
108    Antiope,
109
110    /// The REST API v3 responses for issue events and issue timeline events
111    /// now return the project_card field for project-related events.
112    Starfox,
113
114    /// GitHub App Manifests allow people to create preconfigured GitHub Apps.
115    /// See "Creating GitHub Apps from a manifest" for more details.
116    Fury,
117
118    /// You can now update the `environment` of a deployment status and use the
119    /// `in_progress` and `queued` states. When you create deployment statuses,
120    /// you can now use the `auto_inactive` parameter to mark old `production`
121    /// deployments as `inactive`.
122    Flash,
123
124    /// You can now configure whether organization members can create
125    /// repositories and which types of repositories they can create. See "Edit
126    /// an organization" for more details.
127    Surtur,
128
129    /// You can now provide more information in GitHub for URLs that link to
130    /// registered domains by using the Content Attachments API. See "Using
131    /// content attachments" for more details.
132    Corsair,
133
134    /// Allows you to temporarily restrict interactions, such as commenting,
135    /// opening issues, and creating pull requests, for GitHub repositories or
136    /// organizations. When enabled, only the specified group of GitHub users
137    /// will be able to participate in these interactions. See the Repository
138    /// interactions and Organization interactions APIs for more details.
139    Sombra,
140
141    /// You can use the Draft Pull Requests API and its pull request endpoints
142    /// to see whether a pull request is in draft state. To learn more about
143    /// draft pull requests, see "About pull requests" in the GitHub Help
144    /// documentation.
145    ShadowCat,
146
147    /// You can use the new endpoints in the Pages API to enable or disable
148    /// Pages. To learn more about Pages, see "GitHub Pages Basics" in the
149    /// GitHub Help documentation.
150    Switcheroo,
151
152    /// You can use the new endpoints in the Commits API to list branches or
153    /// pull requests for a commit.
154    Groot,
155
156    /// Owners of GitHub Apps can now uninstall an app using the Apps API.
157    Gambit,
158}
159
160impl Preview {
161    /// Returns the kebab-case name of the preview.
162    pub fn name(self) -> &'static str {
163        match self {
164            Preview::Wyandotte => "wyandotte",
165            Preview::BarredRock => "barred-rock",
166            Preview::AntMan => "ant-man",
167            Preview::SquirrelGirl => "squirrel-girl",
168            Preview::Mockingbird => "mocking-bird",
169            Preview::MisterFantastic => "mister-fantastic",
170            Preview::MachineMan => "machine-man",
171            Preview::Inertia => "inertia",
172            Preview::Cloak => "clock",
173            Preview::BlackPanther => "black-panther",
174            Preview::GiantSentryFist => "giant-sentry-fist",
175            Preview::Mercy => "mercy",
176            Preview::ScarletWitch => "scarlet-witch",
177            Preview::Hellcat => "hellcat",
178            Preview::Nightshade => "nightshade",
179            Preview::SailorV => "sailor-v",
180            Preview::Dazzler => "dazzler",
181            Preview::Echo => "echo",
182            Preview::Symmetra => "symmetra",
183            Preview::Zzzax => "zzzax",
184            Preview::LukeCage => "luke-cage",
185            Preview::Hagar => "hagar",
186            Preview::Antiope => "antiope",
187            Preview::Starfox => "starfox",
188            Preview::Fury => "fury",
189            Preview::Flash => "flash",
190            Preview::Surtur => "surtur",
191            Preview::Corsair => "corsair",
192            Preview::Sombra => "sombra",
193            Preview::ShadowCat => "shadow-cat",
194            Preview::Switcheroo => "switcheroo",
195            Preview::Groot => "groot",
196            Preview::Gambit => "gambit",
197        }
198    }
199
200    /// Returns the media type for the preview. This can be used for the
201    /// `Accept` header in requests.
202    pub fn media_type(self) -> String {
203        format!("application/vnd.github.{}-preview+json", self.name())
204    }
205}
206
207impl fmt::Display for Preview {
208    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
209        f.write_str(self.name())
210    }
211}