|
| 1 | +package coder |
| 2 | + |
| 3 | +import ( |
| 4 | +"context" |
| 5 | +"net/http" |
| 6 | +) |
| 7 | + |
| 8 | +typeAuthProviderTypestring |
| 9 | + |
| 10 | +// AuthProviderType enum. |
| 11 | +const ( |
| 12 | +AuthProviderBuiltInAuthProviderType="built-in" |
| 13 | +AuthProviderSAMLAuthProviderType="saml" |
| 14 | +AuthProviderOIDCAuthProviderType="oidc" |
| 15 | +) |
| 16 | + |
| 17 | +typeConfigAuthstruct { |
| 18 | +ProviderType*AuthProviderType`json:"provider_type"` |
| 19 | +OIDC*ConfigOIDC`json:"oidc"` |
| 20 | +SAML*ConfigSAML`json:"saml"` |
| 21 | +} |
| 22 | + |
| 23 | +typeConfigOIDCstruct { |
| 24 | +ClientID*string`json:"client_id"` |
| 25 | +ClientSecret*string`json:"client_secret"` |
| 26 | +Issuer*string`json:"issuer"` |
| 27 | +} |
| 28 | + |
| 29 | +typeConfigSAMLstruct { |
| 30 | +IdentityProviderMetadataURL*string`json:"idp_metadata_url"` |
| 31 | +SignatureAlgorithm*string`json:"signature_algorithm"` |
| 32 | +NameIDFormat*string`json:"name_id_format"` |
| 33 | +PrivateKey*string`json:"private_key"` |
| 34 | +PublicKeyCertificate*string`json:"public_key_certificate"` |
| 35 | +} |
| 36 | + |
| 37 | +typeConfigOAuthBitbucketServerstruct { |
| 38 | +BaseURLstring`json:"base_url" diff:"oauth.bitbucket_server.base_url"` |
| 39 | +} |
| 40 | + |
| 41 | +typeConfigOAuthGitHubstruct { |
| 42 | +BaseURLstring`json:"base_url"` |
| 43 | +ClientIDstring`json:"client_id"` |
| 44 | +ClientSecretstring`json:"client_secret"` |
| 45 | +} |
| 46 | + |
| 47 | +typeConfigOAuthGitLabstruct { |
| 48 | +BaseURLstring`json:"base_url"` |
| 49 | +ClientIDstring`json:"client_id" ` |
| 50 | +ClientSecretstring`json:"client_secret"` |
| 51 | +} |
| 52 | + |
| 53 | +typeConfigOAuthstruct { |
| 54 | +BitbucketServerConfigOAuthBitbucketServer`json:"bitbucket_server"` |
| 55 | +GitHubConfigOAuthGitHub`json:"github"` |
| 56 | +GitLabConfigOAuthGitLab`json:"gitlab"` |
| 57 | +} |
| 58 | + |
| 59 | +func (cClient)SiteConfigAuth(ctx context.Context) (*ConfigAuth,error) { |
| 60 | +varconfConfigAuth |
| 61 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/auth/config",nil,&c);err!=nil { |
| 62 | +returnnil,err |
| 63 | +} |
| 64 | +return&conf,nil |
| 65 | +} |
| 66 | + |
| 67 | +func (cClient)PutSiteConfigAuth(ctx context.Context,reqConfigAuth)error { |
| 68 | +returnc.requestBody(ctx,http.MethodPut,"/api/auth/config",req,nil) |
| 69 | +} |
| 70 | + |
| 71 | +func (cClient)SiteConfigOAuth(ctx context.Context) (*ConfigOAuth,error) { |
| 72 | +varconfConfigOAuth |
| 73 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/oauth/config",nil,&conf);err!=nil { |
| 74 | +returnnil,err |
| 75 | +} |
| 76 | +return&conf,nil |
| 77 | +} |
| 78 | + |
| 79 | +func (cClient)PutSiteConfigOAuth(ctx context.Context,reqConfigOAuth)error { |
| 80 | +returnc.requestBody(ctx,http.MethodPut,"/api/oauth/config",req,nil) |
| 81 | +} |
| 82 | + |
| 83 | +typeconfigSetupModestruct { |
| 84 | +SetupModebool`json:"setup_mode"` |
| 85 | +} |
| 86 | + |
| 87 | +func (cClient)SiteSetupModeEnabled(ctx context.Context) (bool,error) { |
| 88 | +varconfconfigSetupMode |
| 89 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/config/setup-mode",nil,&conf);err!=nil { |
| 90 | +returnfalse,nil |
| 91 | +} |
| 92 | +returnconf.SetupMode,nil |
| 93 | +} |
| 94 | + |
| 95 | +typeExtensionMarketplaceTypestring |
| 96 | + |
| 97 | +// ExtensionMarketplaceType enum. |
| 98 | +const ( |
| 99 | +ExtensionMarketplaceInternalExtensionMarketplaceType="internal" |
| 100 | +ExtensionMarketplaceCustomExtensionMarketplaceType="custom" |
| 101 | +ExtensionMarketplacePublicExtensionMarketplaceType="public" |
| 102 | +) |
| 103 | + |
| 104 | +constMarketplaceExtensionPublicURL="https://extensions.coder.com/api" |
| 105 | + |
| 106 | +typeConfigExtensionMarketplacestruct { |
| 107 | +URLstring`json:"url"` |
| 108 | +TypeExtensionMarketplaceType`json:"type"` |
| 109 | +} |
| 110 | + |
| 111 | +func (cClient)SiteConfigExtensionMarketplace(ctx context.Context) (*ConfigExtensionMarketplace,error) { |
| 112 | +varconfConfigExtensionMarketplace |
| 113 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/extensions/config",nil,&conf);err!=nil { |
| 114 | +returnnil,err |
| 115 | +} |
| 116 | +return&conf,nil |
| 117 | +} |
| 118 | + |
| 119 | +func (cClient)PutSiteConfigExtensionMarketplace(ctx context.Context,reqConfigExtensionMarketplace)error { |
| 120 | +returnc.requestBody(ctx,http.MethodGet,"/api/extensions/config",req,nil) |
| 121 | +} |