SFTPGo allows to securely share your files over SFTP, HTTP and optionally FTP/S and WebDAV as well.
Several storage backends are supported and they are configurable per user, so you can serve a local directory for a user and an S3 bucket (or part of it) for another one.
SFTPGo also supports virtual folders, a virtual folder can use any of the supported storage backends. So you can have, for example, an S3 user that exposes a GCS bucket (or part of it) on a specified path and an encrypted local filesystem on another one.
Virtual folders can be private or shared among multiple users, for shared virtual folders you can define different quota limits for each user.
SFTPGo allows to create HTTP/S links to externally share files and folders securely, by setting limits to the number of downloads/uploads, protecting the share with a password, limiting access by source IP address, setting an automatic expiration date.
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import client "github.com/hasusuf/sftpgo-client/client"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), client.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), client.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), client.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), client.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to /api/v2
Class | Method | HTTP request | Description |
---|---|---|---|
APIKeysApi | AddApiKey | Post /apikeys | Add API key |
APIKeysApi | DeleteApiKey | Delete /apikeys/{id} | Delete API key |
APIKeysApi | GetApiKeyById | Get /apikeys/{id} | Find API key by id |
APIKeysApi | GetApiKeys | Get /apikeys | Get API keys |
APIKeysApi | UpdateApiKey | Put /apikeys/{id} | Update API key |
AdminsApi | AddAdmin | Post /admins | Add admin |
AdminsApi | AdminForgotPassword | Post /admins/{username}/forgot-password | Send a password reset code by email |
AdminsApi | AdminResetPassword | Post /admins/{username}/reset-password | Reset the password |
AdminsApi | ChangeAdminPassword | Put /admin/changepwd | Change admin password |
AdminsApi | ChangeAdminPasswordDeprecated | Put /changepwd/admin | Change admin password |
AdminsApi | DeleteAdmin | Delete /admins/{username} | Delete admin |
AdminsApi | DisableAdmin2fa | Put /admins/{username}/2fa/disable | Disable second factor authentication |
AdminsApi | GenerateAdminRecoveryCodes | Post /admin/2fa/recoverycodes | Generate recovery codes |
AdminsApi | GenerateAdminTotpSecret | Post /admin/totp/generate | Generate a new TOTP secret |
AdminsApi | GetAdminByUsername | Get /admins/{username} | Find admins by username |
AdminsApi | GetAdminProfile | Get /admin/profile | Get admin profile |
AdminsApi | GetAdminRecoveryCodes | Get /admin/2fa/recoverycodes | Get recovery codes |
AdminsApi | GetAdminTotpConfigs | Get /admin/totp/configs | Get available TOTP configuration |
AdminsApi | GetAdmins | Get /admins | Get admins |
AdminsApi | SaveAdminTotpConfig | Post /admin/totp/save | Save a TOTP config |
AdminsApi | UpdateAdmin | Put /admins/{username} | Update admin |
AdminsApi | UpdateAdminProfile | Put /admin/profile | Update admin profile |
AdminsApi | ValidateAdminTotpSecret | Post /admin/totp/validate | Validate a one time authentication code |
ConnectionsApi | CloseConnection | Delete /connections/{connectionID} | Close connection |
ConnectionsApi | GetConnections | Get /connections | Get connections details |
DataRetentionApi | GetUsersRetentionChecks | Get /retention/users/checks | Get retention checks |
DataRetentionApi | StartUserRetentionCheck | Post /retention/users/{username}/check | Start a retention check |
DefenderApi | DeleteDefenderHostById | Delete /defender/hosts/{id} | Removes a host from the defender lists |
DefenderApi | GetBanTime | Get /defender/bantime | Get ban time |
DefenderApi | GetDefenderHostById | Get /defender/hosts/{id} | Get host by id |
DefenderApi | GetDefenderHosts | Get /defender/hosts | Get hosts |
DefenderApi | GetScore | Get /defender/score | Get score |
DefenderApi | UnbanHost | Post /defender/unban | Unban |
EventsApi | GetFsEvents | Get /events/fs | Get filesystem events |
EventsApi | GetProviderEvents | Get /events/provider | Get provider events |
FoldersApi | AddFolder | Post /folders | Add folder |
FoldersApi | DeleteFolder | Delete /folders/{name} | Delete folder |
FoldersApi | GetFolderByName | Get /folders/{name} | Find folders by name |
FoldersApi | GetFolders | Get /folders | Get folders |
FoldersApi | UpdateFolder | Put /folders/{name} | Update folder |
HealthcheckApi | Healthz | Get /healthz | health check |
MaintenanceApi | Dumpdata | Get /dumpdata | Dump data |
MaintenanceApi | GetStatus | Get /status | Get status |
MaintenanceApi | GetVersion | Get /version | Get version details |
MaintenanceApi | LoaddataFromFile | Get /loaddata | Load data from path |
MaintenanceApi | LoaddataFromRequestBody | Post /loaddata | Load data |
MetadataApi | GetUsersMetadataChecks | Get /metadata/users/checks | Get metadata checks |
MetadataApi | StartUserMetadataCheck | Post /metadata/users/{username}/check | Start a metadata check |
PublicSharesApi | DownloadShareFile | Get /shares/{id}/files | Download a single file |
PublicSharesApi | GetShare | Get /shares/{id} | Download shared files and folders as a single zip file |
PublicSharesApi | GetShareDirContents | Get /shares/{id}/dirs | Read directory contents |
PublicSharesApi | UploadSingleToShare | Post /shares/{id}/{fileName} | Upload a single file to the shared path |
PublicSharesApi | UploadToShare | Post /shares/{id} | Upload one or more files to the shared path |
QuotaApi | FolderQuotaUpdateUsage | Put /quotas/folders/{name}/usage | Update folder quota usage limits |
QuotaApi | FolderQuotaUpdateUsageDeprecated | Put /folder-quota-update | Update folder quota limits |
QuotaApi | GetFoldersQuotaScans | Get /quotas/folders/scans | Get active folder quota scans |
QuotaApi | GetFoldersQuotaScansDeprecated | Get /folder-quota-scans | Get folders quota scans |
QuotaApi | GetUsersQuotaScans | Get /quotas/users/scans | Get active user quota scans |
QuotaApi | GetUsersQuotaScansDeprecated | Get /quota-scans | Get quota scans |
QuotaApi | StartFolderQuotaScan | Post /quotas/folders/{name}/scan | Start a folder quota scan |
QuotaApi | StartFolderQuotaScanDeprecated | Post /folder-quota-scans | Start a folder quota scan |
QuotaApi | StartUserQuotaScan | Post /quotas/users/{username}/scan | Start a user quota scan |
QuotaApi | StartUserQuotaScanDeprecated | Post /quota-scans | Start user quota scan |
QuotaApi | UserQuotaUpdateUsage | Put /quotas/users/{username}/usage | Update disk quota usage limits |
QuotaApi | UserQuotaUpdateUsageDeprecated | Put /quota-update | Update quota usage limits |
QuotaApi | UserTransferQuotaUpdateUsage | Put /quotas/users/{username}/transfer-usage | Update transfer quota usage limits |
TokenApi | ClientLogout | Get /user/logout | Invalidate a user access token |
TokenApi | GetToken | Get /token | Get a new admin access token |
TokenApi | GetUserToken | Get /user/token | Get a new user access token |
TokenApi | Logout | Get /logout | Invalidate an admin access token |
UserAPIsApi | AddShare | Post /user/shares | Add a share |
UserAPIsApi | ChangeUserPassword | Put /user/changepwd | Change user password |
UserAPIsApi | CreateUserDir | Post /user/dirs | Create a directory |
UserAPIsApi | CreateUserFile | Post /user/files/upload | Upload a single file |
UserAPIsApi | CreateUserFiles | Post /user/files | Upload files |
UserAPIsApi | DeleteUserDir | Delete /user/dirs | Delete a directory |
UserAPIsApi | DeleteUserFile | Delete /user/files | Delete a file |
UserAPIsApi | DeleteUserShare | Delete /user/shares/{id} | Delete share |
UserAPIsApi | DownloadUserFile | Get /user/files | Download a single file |
UserAPIsApi | GenerateUserRecoveryCodes | Post /user/2fa/recoverycodes | Generate recovery codes |
UserAPIsApi | GenerateUserTotpSecret | Post /user/totp/generate | Generate a new TOTP secret |
UserAPIsApi | GetUserDirContents | Get /user/dirs | Read directory contents |
UserAPIsApi | GetUserFile | Get /user/file | Download a single file |
UserAPIsApi | GetUserFolderContents | Get /user/folder | Read folders contents |
UserAPIsApi | GetUserProfile | Get /user/profile | Get user profile |
UserAPIsApi | GetUserPublicKeys | Get /user/publickeys | Get the user's public keys |
UserAPIsApi | GetUserRecoveryCodes | Get /user/2fa/recoverycodes | Get recovery codes |
UserAPIsApi | GetUserShareById | Get /user/shares/{id} | Get share by id |
UserAPIsApi | GetUserShares | Get /user/shares | List user shares |
UserAPIsApi | GetUserTotpConfigs | Get /user/totp/configs | Get available TOTP configuration |
UserAPIsApi | RenameUserDir | Patch /user/dirs | Rename a directory |
UserAPIsApi | RenameUserFile | Patch /user/files | Rename a file |
UserAPIsApi | SaveUserTotpConfig | Post /user/totp/save | Save a TOTP config |
UserAPIsApi | SetUserPublicKeys | Put /user/publickeys | Set the user's public keys |
UserAPIsApi | SetpropsUserFile | Patch /user/files/metadata | Set metadata for a file/directory |
UserAPIsApi | Streamzip | Post /user/streamzip | Download multiple files and folders as a single zip file |
UserAPIsApi | UpdateUserProfile | Put /user/profile | Update user profile |
UserAPIsApi | UpdateUserShare | Put /user/shares/{id} | Update share |
UserAPIsApi | ValidateUserTotpSecret | Post /user/totp/validate | Validate a one time authentication code |
UsersApi | AddUser | Post /users | Add user |
UsersApi | DeleteUser | Delete /users/{username} | Delete user |
UsersApi | DisableUser2fa | Put /users/{username}/2fa/disable | Disable second factor authentication |
UsersApi | GetUserByUsername | Get /users/{username} | Find users by username |
UsersApi | GetUsers | Get /users | Get users |
UsersApi | UpdateUser | Put /users/{username} | Update user |
UsersApi | UserForgotPassword | Post /users/{username}/forgot-password | Send a password reset code by email |
UsersApi | UserResetPassword | Post /users/{username}/reset-password | Reset the password |
Note, each API key must be added to a map of map[string]APIKey
where the key is: X-SFTPGO-API-KEY and passed in as the auth context for each request.
Example
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
Example
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime
面向多计算场景的一站式融合计算平台
Go CSS Markdown Vue Text other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》