using System.Collections.Generic; using System.Diagnostics; using System.Globalization; namespace Octokit { /// /// Creates a Webhook for the repository. /// /// /// To create a webhook, the following fields are required by the config: /// /// /// url /// A required string defining the URL to which the payloads will be delivered. /// /// /// content_type /// /// An optional string defining the media type used to serialize the payloads. Supported values include json and /// form. The default is form. /// /// /// /// secret /// /// An optional string that’s passed with the HTTP requests as an X-Hub-Signature header. The value of this /// header is computed as the HMAC hex digest of the body, using the secret as the key. /// /// /// /// insecure_ssl: /// /// An optional string that determines whether the SSL certificate of the host for url will be verified when /// delivering payloads. Supported values include "0" (verification is performed) and "1" (verification is not /// performed). The default is "0". /// /// /// /// /// API: https://developer.github.com/v3/repos/hooks/#create-a-hook /// /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewRepositoryHook { /// /// Initializes a new instance of the class. /// /// /// Use "web" for a webhook or use the name of a valid service. (See /// https://api.github.com/hooks for the list of valid service /// names.) /// /// /// Key/value pairs to provide settings for this hook. These settings vary between the services and are /// defined in the github-services repository. Booleans are stored internally as “1” for true, and “0” for /// false. Any JSON true/false values will be converted automatically. /// public NewRepositoryHook(string name, IReadOnlyDictionary config) { Name = name; Config = config; } /// /// Gets the name of the hook to create. Use "web" for a webhook or use the name of a valid service. (See /// https://api.github.com/hooks for the list of valid service /// names.) /// /// /// The name. /// public string Name { get; private set; } /// /// Key/value pairs to provide settings for this hook. These settings vary between the services and are /// defined in the github-services repository. Booleans are stored internally as “1” for true, and “0” for /// false. Any JSON true/false values will be converted automatically. /// /// /// The configuration. /// public IReadOnlyDictionary Config { get; private set; } /// /// Determines what events the hook is triggered for. Default: ["push"] /// /// /// The events. /// public IEnumerable Events { get; set; } /// /// Determines whether the hook is actually triggered on pushes. /// /// /// true if active; otherwise, false. /// public bool Active { get; set; } public virtual NewRepositoryHook ToRequest() { return this; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Repository Hook: Name: {0}, Events: {1}", Name, string.Join(", ", Events)); } } } }