|
| 1 | +package zendesk |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/1Password/shell-plugins/sdk" |
| 5 | + "github.com/1Password/shell-plugins/sdk/importer" |
| 6 | + "github.com/1Password/shell-plugins/sdk/provision" |
| 7 | + "github.com/1Password/shell-plugins/sdk/schema" |
| 8 | + "github.com/1Password/shell-plugins/sdk/schema/credname" |
| 9 | + "github.com/1Password/shell-plugins/sdk/schema/fieldname" |
| 10 | +) |
| 11 | + |
| 12 | +func APIToken() schema.CredentialType { |
| 13 | + return schema.CredentialType{ |
| 14 | + Name: credname.APIToken, |
| 15 | + DocsURL: sdk.URL("https://developer.zendesk.com/api-reference/introduction/security-and-auth/#api-token"), |
| 16 | + Fields: []schema.CredentialField{ |
| 17 | + { |
| 18 | + Name: fieldname.Subdomain, |
| 19 | + MarkdownDescription: "Subdomain of Zendesk account, often found in the account's URL.", |
| 20 | + Optional: false, |
| 21 | + Secret: false, |
| 22 | + Composition: &schema.ValueComposition{ |
| 23 | + Charset: schema.Charset{ |
| 24 | + Uppercase: true, |
| 25 | + Lowercase: true, |
| 26 | + Digits: true, |
| 27 | + Symbols: true, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + { |
| 32 | + Name: fieldname.Email, |
| 33 | + MarkdownDescription: "Email used to authenticate to Zendesk.", |
| 34 | + Optional: false, |
| 35 | + Secret: false, |
| 36 | + Composition: &schema.ValueComposition{ |
| 37 | + Charset: schema.Charset{ |
| 38 | + Uppercase: true, |
| 39 | + Lowercase: true, |
| 40 | + Digits: true, |
| 41 | + Symbols: true, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + { |
| 46 | + Name: fieldname.Token, |
| 47 | + MarkdownDescription: "API token used to authenticate to Zendesk.", |
| 48 | + Optional: false, |
| 49 | + Secret: true, |
| 50 | + Composition: &schema.ValueComposition{ |
| 51 | + Length: 40, |
| 52 | + Charset: schema.Charset{ |
| 53 | + Uppercase: true, |
| 54 | + Lowercase: true, |
| 55 | + Digits: true, |
| 56 | + Symbols: true, |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, |
| 60 | + }, |
| 61 | + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), |
| 62 | + Importer: importer.TryAll( |
| 63 | + importer.TryEnvVarPair(defaultEnvVarMapping), |
| 64 | + )} |
| 65 | +} |
| 66 | + |
| 67 | +var defaultEnvVarMapping = map[string]sdk.FieldName{ |
| 68 | + "ZENDESK_SUBDOMAIN": fieldname.Subdomain, |
| 69 | + "ZENDESK_EMAIL": fieldname.Email, |
| 70 | + "ZENDESK_API_TOKEN": fieldname.Token, |
| 71 | +} |
0 commit comments