Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitcfdde80

Browse files
committed
Add config sdk methods
1 parent25ac3c3 commitcfdde80

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

‎coder-sdk/config.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
}

‎coder-sdk/users.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,7 @@ type CreateUserReq struct {
125125
func (cClient)CreateUser(ctx context.Context,reqCreateUserReq)error {
126126
returnc.requestBody(ctx,http.MethodPost,"/api/users",req,nil)
127127
}
128+
129+
func (cClient)DeleteUser(ctx context.Context,userIDstring)error {
130+
returnc.requestBody(ctx,http.MethodDelete,"/api/users/"+userID,nil,nil)
131+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp