| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package compute
- import (
- "fmt"
- "os"
- "yunion.io/x/cloudmux/pkg/cloudprovider"
- "yunion.io/x/jsonutils"
- api "yunion.io/x/onecloud/pkg/apis/compute"
- baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
- )
- type CloudaccountListOptions struct {
- baseoptions.BaseListOptions
- Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event|tablestore"`
- ReadOnly *bool `help:"filter read only account" negative:"no-read-only"`
- //DistinctField string `help:"distinct field"`
- ProxySetting string `help:"Proxy setting id or name"`
- // 按宿主机数量排序
- OrderByHostCount string
- // 按虚拟机数量排序
- OrderByGuestCount string
- }
- func (opts *CloudaccountListOptions) Params() (jsonutils.JSONObject, error) {
- return baseoptions.ListStructToParams(opts)
- }
- type SUserPasswordCredential struct {
- Username string `help:"Username" positional:"true"`
- Password string `help:"Password" positional:"true"`
- }
- type SVMwareCredentialWithEnvironment struct {
- SUserPasswordCredential
- Host string `help:"VMware VCenter/ESXi host" positional:"true"`
- Port string `help:"VMware VCenter/ESXi host port" default:"443"`
- Zone string `help:"zone for this account"`
- }
- type SNutanixCredentialWithEnvironment struct {
- SUserPasswordCredential
- Host string `help:"Nutanix host" positional:"true"`
- Port string `help:"Nutanix host port" default:"9440"`
- }
- type SProxmoxCredentialWithEnvironment struct {
- SUserPasswordCredential
- Host string `help:"Proxmox host" positional:"true"`
- Port string `help:"Proxmox host port" default:"8006"`
- }
- type SAzureCredential struct {
- ClientID string `help:"Azure client_id" positional:"true"`
- ClientSecret string `help:"Azure clinet_secret" positional:"true"`
- }
- type SAzureCredentialWithEnvironment struct {
- DirectoryID string `help:"Azure directory_id" positional:"true"`
- SAzureCredential
- Environment string `help:"Cloud environment" choices:"AzureGermanCloud|AzureChinaCloud|AzurePublicCloud" default:"AzureChinaCloud"`
- }
- type SQcloudCredential struct {
- AppID string `help:"Qcloud appid" positional:"true"`
- SecretID string `help:"Qcloud secret_id" positional:"true"`
- SecretKey string `help:"Qcloud secret_key" positional:"true"`
- }
- type SOpenStackCredential struct {
- ProjectName string `help:"OpenStack project_name" positional:"true"`
- SUserPasswordCredential
- DomainName string `help:"OpenStack domain name"`
- }
- type SOpenStackCredentialWithAuthURL struct {
- SOpenStackCredential
- AuthURL string `help:"OpenStack auth_url" positional:"true" json:"auth_url"`
- }
- type SAccessKeyCredential struct {
- AccessKeyID string `help:"Access_key_id" positional:"true"`
- AccessKeySecret string `help:"Access_key_secret" positional:"true"`
- }
- type SAccessKeyCredentialWithEnvironment struct {
- SAccessKeyCredential
- Environment string `help:"Cloud environment" choices:"InternationalCloud|ChinaCloud" default:"ChinaCloud"`
- }
- /// create options
- type SCloudAccountCreateBaseOptions struct {
- Name string `help:"Name of cloud account" positional:"true"`
- // PROVIDER string `help:"Driver for cloud account" choices:"VMware|Aliyun|Azure|Qcloud|OpenStack|Huawei|Aws"`
- Desc string `help:"Description" token:"desc" json:"description"`
- Brand string `help:"Brand of cloud account"`
- AutoCreateProject bool `help:"Enable the account with same name project"`
- AutoCreateProjectForProvider bool `help:"Is Auto Create Project For Provider"`
- EnableAutoSync bool `help:"Enable automatically synchronize resources of this account"`
- SyncIntervalSeconds int `help:"Interval to synchronize if auto sync is enable" metavar:"SECONDS"`
- Project string `help:"project for this account"`
- ProjectDomain string `help:"domain for this account"`
- Disabled *bool `help:"create cloud account with disabled status"`
- SkipDuplicateAccountCheck bool `help:"skip check duplicate account"`
- SamlAuth string `help:"Enable or disable saml auth" choices:"true|false"`
- ProxySetting string `help:"proxy setting id or name" json:"proxy_setting"`
- DryRun bool `help:"test create cloudaccount params"`
- ShowSubAccounts bool `help:"test and show subaccount info"`
- ReadOnly bool `help:"Read only account"`
- RegionId string
- ProjectMappingId string
- EnableProjectSync bool
- EnableResourceSync bool
- SkipSyncResources []string `help:"Skip sync resource, etc snapshot"`
- Currency string `choices:"CNY|USD"`
- }
- type SVMwareCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SVMwareCredentialWithEnvironment
- }
- type SAliyunAccessKeyCredentialWithEnvironment struct {
- SAccessKeyCredential
- Environment string `help:"Cloud environment" choices:"InternationalCloud|FinanceCloud" default:"InternationalCloud"`
- }
- func (opts *SVMwareCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("VMware"), "provider")
- return params, nil
- }
- type SAliyunCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAliyunAccessKeyCredentialWithEnvironment
- OptionsBillingReportBucket string `help:"bucket that stores billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"prefix of billing file name" json:"-"`
- }
- func (opts *SAliyunCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Aliyun"), "provider")
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if options.Size() > 0 {
- params.(*jsonutils.JSONDict).Add(options, "options")
- }
- return params, nil
- }
- type SAzureCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAzureCredentialWithEnvironment
- }
- func (opts *SAzureCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Azure"), "provider")
- return params, nil
- }
- type SQcloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SQcloudCredential
- OptionsBillingReportBucket string `help:"bucket that stores billing report" json:"-"`
- }
- func (opts *SQcloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- params.Add(jsonutils.NewString("Qcloud"), "provider")
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Set("billing_report_bucket", jsonutils.NewString(opts.OptionsBillingReportBucket))
- }
- if options.Length() > 0 {
- params.Set("options", options)
- }
- return params, nil
- }
- type SGoogleCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- GoogleJsonFile string `help:"Google auth json file" positional:"true"`
- }
- func parseGcpCredential(filename string) (jsonutils.JSONObject, error) {
- data, err := os.ReadFile(filename)
- if err != nil {
- return nil, err
- }
- authParams, err := jsonutils.Parse(data)
- if err != nil {
- return nil, err
- }
- ret := jsonutils.NewDict()
- for _, k := range []string{
- "client_email",
- "project_id",
- "private_key_id",
- "private_key",
- } {
- v, _ := authParams.Get(k)
- ret.Add(v, fmt.Sprintf("gcp_%s", k))
- }
- return ret, nil
- }
- func (opts *SGoogleCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Google"), "provider")
- authParams, err := parseGcpCredential(opts.GoogleJsonFile)
- if err != nil {
- return nil, err
- }
- err = jsonutils.Update(params, authParams)
- if err != nil {
- return nil, err
- }
- return params, nil
- }
- type SAWSCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredentialWithEnvironment
- OptionsBillingReportBucket string `help:"bucket that stores billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"prefix of billing file name" json:"-"`
- OptionsAssumeRoleName string `help:"assume role name" json:"-"`
- }
- func (opts *SAWSCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if len(opts.OptionsAssumeRoleName) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsAssumeRoleName), "aws_assume_role_name")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- params.Add(jsonutils.NewString("Aws"), "provider")
- return params, nil
- }
- type SOpenStackCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SOpenStackCredentialWithAuthURL
- }
- func (opts *SOpenStackCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("OpenStack"), "provider")
- return params, nil
- }
- type SHuaweiCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SHuaweiCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Huawei"), "provider")
- return params, nil
- }
- type SHCSOAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- cloudprovider.SHCSOEndpoints
- SAccessKeyCredential
- }
- func (opts *SHCSOAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("HCSO"), "provider")
- return params, nil
- }
- type SHCSAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- AuthURL string `help:"Hcs auth_url" positional:"true" json:"auth_url"`
- SAccessKeyCredential
- }
- func (opts *SHCSAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("HCS"), "provider")
- return params, nil
- }
- type SUcloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SUcloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Ucloud"), "provider")
- return params, nil
- }
- type SVolcengineCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- OptionsBillingReportBucket string `help:"update Aliyun S3 bucket that stores account billing report" json:"-"`
- }
- func (opts *SVolcengineCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- params.Add(jsonutils.NewString("VolcEngine"), "provider")
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Set("billing_report_bucket", jsonutils.NewString(opts.OptionsBillingReportBucket))
- }
- if options.Length() > 0 {
- params.Set("options", options)
- }
- return params, nil
- }
- type SZStackCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SUserPasswordCredential
- AuthURL string `help:"ZStack auth_url" positional:"true" json:"auth_url"`
- }
- func (opts *SZStackCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("ZStack"), "provider")
- return params, nil
- }
- type SHcsOpCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SUserPasswordCredential
- AuthURL string `help:"HcsOp auth_url" positional:"true" json:"auth_url"`
- }
- func (opts *SHcsOpCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("HCSOP"), "provider")
- return params, nil
- }
- type SS3CloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- Endpoint string `help:"S3 endpoint" required:"true" positional:"true" json:"endpoint"`
- OptionSignVer string `help:"signing algorithm version" choices:"v2|v4"`
- }
- func (opts *SS3CloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("S3"), "provider")
- options := jsonutils.NewDict()
- if len(opts.OptionSignVer) > 0 {
- options.Add(jsonutils.NewString(opts.OptionSignVer), "sign_ver")
- }
- return params, nil
- }
- type SCephCloudAccountCreateOptions struct {
- SS3CloudAccountCreateOptions
- }
- func (opts *SCephCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Ceph"), "provider")
- return params, nil
- }
- type SXskyCloudAccountCreateOptions struct {
- SS3CloudAccountCreateOptions
- }
- func (opts *SXskyCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Xsky"), "provider")
- return params, nil
- }
- type SCtyunCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredentialWithEnvironment
- }
- func (opts *SCtyunCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Ctyun"), "provider")
- return params, nil
- }
- type SEcloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredentialWithEnvironment
- }
- func (opts *SEcloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Ecloud"), "provider")
- return params, nil
- }
- type SJDcloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SJDcloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("JDcloud"), "provider")
- return params, nil
- }
- type SCloudpodsCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- AuthURL string `help:"Cloudpods auth_url" positional:"true" json:"auth_url"`
- }
- func (opts *SCloudpodsCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Cloudpods"), "provider")
- return params, nil
- }
- // update credential options
- type SCloudAccountIdOptions struct {
- ID string `help:"ID or Name of cloud account" json:"-"`
- }
- func (opts *SCloudAccountIdOptions) GetId() string {
- return opts.ID
- }
- func (opts *SCloudAccountIdOptions) Params() (jsonutils.JSONObject, error) {
- return nil, nil
- }
- type SVMwareCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- Host string `help:"VMware VCenter/ESXi host"`
- Port string `help:"VMware VCenter/ESXi host port" default:"443"`
- }
- func (opts *SVMwareCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SAliyunCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SAliyunCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SApsaraCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- OrganizationId int
- }
- func (opts *SApsaraCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SAzureCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAzureCredential
- }
- func (opts *SAzureCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SQcloudCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SQcloudCredential
- }
- func (opts *SQcloudCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SAWSCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SAWSCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SOpenStackCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SOpenStackCredential
- }
- func (opts *SOpenStackCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SHuaweiCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SHuaweiCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SHCSOAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- cloudprovider.SHCSOEndpoints
- SAccessKeyCredential
- }
- func (opts *SHCSOAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SHCSAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SHCSAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SUcloudCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SUcloudCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SVolcengineCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- }
- func (opts *SVolcengineCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SZStackCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- }
- func (opts *SZStackCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SS3CloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SS3CloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCtyunCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SCtyunCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SJDcloudCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SJDcloudCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCloudpodsCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SCloudpodsCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts.SAccessKeyCredential), nil
- }
- type SGoogleCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- GoogleJsonFile string `help:"Google auth json file" positional:"true"`
- }
- func (opts *SGoogleCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return parseGcpCredential(opts.GoogleJsonFile)
- }
- // update
- type SCloudAccountUpdateBaseOptions struct {
- SCloudAccountIdOptions
- Name string `help:"New name to update"`
- SyncIntervalSeconds *int `help:"auto synchornize interval in seconds"`
- AutoCreateProject *bool `help:"automatically create local project for new remote project" negative:"no_auto_create_project"`
- EnableAutoSyncResource *bool `help:"automatically sync resources" negative:"disable_auto_sync_resource"`
- ProxySetting string `help:"proxy setting name or id" json:"proxy_setting"`
- SamlAuth string `help:"Enable or disable saml auth" choices:"true|false"`
- ReadOnly *bool `help:"is account read only" negative:"no_read_only"`
- CleanLakeOfPermissions bool `help:"clean lake of permissions"`
- SkipSyncResources []string
- AddSkipSyncResources []string
- RemoveSkipSyncResources []string
- Desc string `help:"Description" json:"description" token:"desc"`
- Currency string `choices:"CNY|USD"`
- }
- func (opts *SCloudAccountUpdateBaseOptions) Params() (jsonutils.JSONObject, error) {
- return nil, fmt.Errorf("obsolete, please try cloud-account-update-xxx, where xxx is vmware, aliyun, azure, qcloud, aws, openstack, huawei etc.")
- }
- type SVMwareCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SVMwareCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SAliyunCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update Aliyun S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove Aliyun S3 bucket that stores account billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"update id of account that can access bucket, blank if this account can access" json:"-"`
- RemoveOptionsBillingBucketAccount bool `help:"remove id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"update prefix of billing file name" json:"-"`
- RemoveOptionsBillingFilePrefix bool `help:"remove prefix of billing file name" json:"-"`
- OptionsBillingScope string `help:"update billing scope" choices:"all|managed" json:"-"`
- RemoveOptionsBillingScope bool `help:"remove billing scope" json:"-"`
- }
- func (opts *SAliyunCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if len(opts.OptionsBillingScope) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingScope), "billing_scope")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if opts.RemoveOptionsBillingBucketAccount {
- removeOptions = append(removeOptions, "billing_bucket_account")
- }
- if opts.RemoveOptionsBillingFilePrefix {
- removeOptions = append(removeOptions, "billing_file_prefix")
- }
- if opts.RemoveOptionsBillingScope {
- removeOptions = append(removeOptions, "billing_scope")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SAzureCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBalanceKey string `help:"update cloud balance account key, such as Azure EA key" json:"-"`
- RemoveOptionsBalanceKey bool `help:"remove cloud blance account key" json:"-"`
- RemoveOptionsBillingScope bool
- OptionsBillingReportBucket string `help:"update Azure bucket that stores account billing report" json:"-"`
- OptionsBillingScope string `help:"update billing scope" choices:"all|managed" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove Azure bucket that stores account billing report" json:"-"`
- }
- func (opts *SAzureCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBalanceKey) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBalanceKey), "balance_key")
- }
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingScope) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingScope), "billing_scope")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBalanceKey {
- removeOptions = append(removeOptions, "balance_key")
- removeOptions = append(removeOptions, "enrollment_number")
- }
- if opts.RemoveOptionsBillingScope {
- removeOptions = append(removeOptions, "billing_scope")
- }
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SQcloudCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update TencentCloud S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove TencentCloud S3 bucket that stores account billing report" json:"-"`
- }
- func (opts *SQcloudCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SGoogleCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBigqueryTable string `help:"update Google big query table that stores account billing report" json:"-"`
- OptionsBillingReportBigqueryAccount string `help:"update Google account for big query table" json:"-"`
- OptionsBillingReportBucket string `help:"update Google S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove Google S3 bucket that stores account billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"update id of account that can access bucket, blank if this account can access" json:"-"`
- RemoveOptionsBillingBucketAccount bool `help:"remove id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"update prefix of billing file name" json:"-"`
- RemoveOptionsBillingFilePrefix bool `help:"remove prefix of billing file name" json:"-"`
- OptionsUsageReportBucket string `help:"update Google S3 bucket that stores account usage report" json:"-"`
- RemoveOptionsUsageReportBucket bool `help:"remove Google S3 bucket that stores account usage report" json:"-"`
- OptionsUsageFilePrefix string `help:"update prefix of usage file name" json:"-"`
- RemoveOptionsUsageFilePrefix bool `help:"remove prefix of usage file name" json:"-"`
- }
- func (opts *SGoogleCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBigqueryTable) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBigqueryTable), "billing_bigquery_table")
- }
- if len(opts.OptionsBillingReportBigqueryAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBigqueryAccount), "billing_bigquery_account")
- }
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if len(opts.OptionsUsageReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsUsageReportBucket), "usage_report_bucket")
- }
- if len(opts.OptionsUsageFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsUsageFilePrefix), "usage_file_prefix")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if opts.RemoveOptionsBillingBucketAccount {
- removeOptions = append(removeOptions, "billing_bucket_account")
- }
- if opts.RemoveOptionsBillingFilePrefix {
- removeOptions = append(removeOptions, "billing_file_prefix")
- }
- if opts.RemoveOptionsUsageReportBucket {
- removeOptions = append(removeOptions, "usage_report_bucket")
- }
- if opts.RemoveOptionsUsageFilePrefix {
- removeOptions = append(removeOptions, "usage_file_prefix")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SAWSCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update AWS S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove AWS S3 bucket that stores account billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"update id of account that can access bucket, blank if this account can access" json:"-"`
- RemoveOptionsBillingBucketAccount bool `help:"remove id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"update prefix of billing file name" json:"-"`
- RemoveOptionsBillingFilePrefix bool `help:"remove prefix of billing file name" json:"-"`
- OptionsAssumeRoleName string `help:"name of assume role" json:"-"`
- RemoveOptionsAssumeRoleName bool `help:"remove option of aws_assume_role_name"`
- }
- func (opts *SAWSCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if len(opts.OptionsAssumeRoleName) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsAssumeRoleName), "aws_assume_role_name")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if opts.RemoveOptionsBillingBucketAccount {
- removeOptions = append(removeOptions, "billing_bucket_account")
- }
- if opts.RemoveOptionsBillingFilePrefix {
- removeOptions = append(removeOptions, "billing_file_prefix")
- }
- if opts.RemoveOptionsAssumeRoleName {
- removeOptions = append(removeOptions, "aws_assume_role_name")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SOpenStackCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SOpenStackCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SHuaweiCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update Huawei S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove Huawei S3 bucket that stores account billing report" json:"-"`
- OptionsBillingBucketAccount string `help:"update id of account that can access bucket, blank if this account can access" json:"-"`
- RemoveOptionsBillingBucketAccount bool `help:"remove id of account that can access bucket, blank if this account can access" json:"-"`
- OptionsBillingFilePrefix string `help:"update prefix of billing file name" json:"-"`
- RemoveOptionsBillingFilePrefix bool `help:"remove prefix of billing file name" json:"-"`
- }
- func (opts *SHuaweiCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if len(opts.OptionsBillingBucketAccount) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingBucketAccount), "billing_bucket_account")
- }
- if len(opts.OptionsBillingFilePrefix) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingFilePrefix), "billing_file_prefix")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if opts.RemoveOptionsBillingBucketAccount {
- removeOptions = append(removeOptions, "billing_bucket_account")
- }
- if opts.RemoveOptionsBillingFilePrefix {
- removeOptions = append(removeOptions, "billing_file_prefix")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SHCSOAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SHCSOAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SHCSAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- Account string
- Password string
- }
- func (opts *SHCSAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts.SCloudAccountUpdateBaseOptions).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.Account) > 0 {
- options.Set("account", jsonutils.NewString(opts.Account))
- }
- if len(opts.Password) > 0 {
- options.Set("password", jsonutils.NewString(opts.Password))
- }
- if options.Length() > 0 {
- params.Set("options", options)
- }
- return params, nil
- }
- type SUcloudCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SUcloudCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SVolcengineCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update VolcEngine S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove VolcEngine S3 bucket that stores account billing report" json:"-"`
- }
- func (opts *SVolcengineCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SZStackCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SZStackCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SS3CloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SS3CloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCtyunCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SCtyunCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- return params, nil
- }
- type SJDcloudCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SJDcloudCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCloudpodsCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SCloudpodsCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- /*type SVMwareCloudAccountPrepareNetsOptions struct {
- SVMwareCredentialWithEnvironment
- Zone string `help:"zone for this account"`
- Project string `help:"project for this account"`
- ProjectDomain string `help:"domain for this account"`
- WireLevel string `help:"wire level for this account" choices:"vcenter|datacenter|cluster" json:"wire_level_for_vmware"`
- Dvs bool `help:"whether to enable dvs corresponding wire"`
- NAME string `help:"name for this account"`
- }
- func (opts *SVMwareCloudAccountPrepareNetsOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("VMware"), "provider")
- return params, nil
- }*/
- type SApsaraCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- Endpoint string
- SAccessKeyCredential
- }
- func (opts *SApsaraCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Apsara"), "provider")
- return params, nil
- }
- type CloudaccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- AccessKeyID string `help:"Aiyun|HuaWei|Aws access_key_id"`
- AccessKeySecret string `help:"Aiyun|HuaWei|Aws access_key_secret"`
- AppID string `help:"Qcloud appid"`
- SecretID string `help:"Qcloud secret_id"`
- SecretKey string `help:"Qcloud secret_key"`
- ProjectName string `help:"OpenStack project_name"`
- Username string `help:"OpenStack|VMware username"`
- Password string `help:"OpenStack|VMware password"`
- EndpointType string `help:"OpenStack endpointType"`
- ClientID string `help:"Azure tenant_id"`
- ClientSecret string `help:"Azure clinet_secret"`
- }
- func (opts *CloudaccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return nil, fmt.Errorf("obsolete command, please try cloud-account-update-credential-xxx, where xxx is vmware, aliyun, azure, qcloud, aws, openstack, huawei, etc.")
- }
- type CloudaccountSyncOptions struct {
- SCloudAccountIdOptions
- api.SyncRangeInput
- }
- func (opts *CloudaccountSyncOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type CloudaccountEnableAutoSyncOptions struct {
- SCloudAccountIdOptions
- SyncIntervalSeconds int `help:"new sync interval in seconds"`
- }
- func (opts *CloudaccountEnableAutoSyncOptions) Params() (jsonutils.JSONObject, error) {
- return baseoptions.StructToParams(opts)
- }
- type CloudaccountPublicOptions struct {
- SCloudAccountIdOptions
- Scope string `help:"public_sccope" choices:"domain|system" json:"scope"`
- SharedDomains []string `help:"shared domains" json:"shared_domains"`
- ShareMode string `help:"share_mode" choices:"account_domain|provider_domain|system"`
- }
- func (opts *CloudaccountPublicOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type CloudaccountShareModeOptions struct {
- SCloudAccountIdOptions
- MODE string `help:"cloud account share mode" choices:"account_domain|system|provider_domain"`
- }
- func (opts *CloudaccountShareModeOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(map[string]string{"share_mode": opts.MODE}), nil
- }
- type CloudaccountSyncSkusOptions struct {
- SCloudAccountIdOptions
- RESOURCE string `help:"Resource of skus" choices:"serversku|elasticcachesku|dbinstance_sku|nat_sku|nas_sku"`
- Force bool `help:"Force sync no matter what"`
- Cloudprovider string `help:"provider to sync"`
- Region string `help:"region to sync"`
- }
- func (opts *CloudaccountSyncSkusOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.NewDict()
- params.Set("resource", jsonutils.NewString(opts.RESOURCE))
- if opts.Force {
- params.Add(jsonutils.JSONTrue, "force")
- }
- if len(opts.Cloudprovider) > 0 {
- params.Add(jsonutils.NewString(opts.Cloudprovider), "cloudprovider")
- }
- if len(opts.Region) > 0 {
- params.Add(jsonutils.NewString(opts.Region), "cloudregion")
- }
- return params, nil
- }
- type ClouaccountChangeOwnerOptions struct {
- SCloudAccountIdOptions
- ProjectDomain string `json:"project_domain" help:"target domain"`
- }
- func (opts *ClouaccountChangeOwnerOptions) Params() (jsonutils.JSONObject, error) {
- if len(opts.ProjectDomain) == 0 {
- return nil, fmt.Errorf("empty project_domain")
- }
- return jsonutils.Marshal(opts), nil
- }
- type ClouaccountChangeProjectOptions struct {
- SCloudAccountIdOptions
- PROJECT string `json:"project" help:"target domain"`
- }
- func (opts *ClouaccountChangeProjectOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SubscriptionCreateOptions struct {
- SCloudAccountIdOptions
- NAME string
- ENROLLMENTACCOUNT string
- OfferType string `choices:"MS-AZR-0148P|MS-AZR-0017P" default:"MS-AZR-0017P"`
- }
- func (opts *SubscriptionCreateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(map[string]string{
- "name": opts.NAME,
- "offer_type": opts.OfferType,
- "enrollment_account_id": opts.ENROLLMENTACCOUNT,
- }), nil
- }
- type ClouaccountProjectMappingOptions struct {
- SCloudAccountIdOptions
- ProjectId string `json:"project_id" help:"default project id"`
- AutoCreateProject bool `help:"auto create project"`
- ProjectMappingId string `json:"project_mapping_id" help:"project mapping id"`
- EnableProjectSync bool
- EnableResourceSync bool
- }
- func (opts *ClouaccountProjectMappingOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SNutanixCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SNutanixCredentialWithEnvironment
- }
- func (opts *SNutanixCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Nutanix"), "provider")
- return params, nil
- }
- type SNutanixCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- }
- func (opts *SNutanixCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts.SUserPasswordCredential), nil
- }
- type SNutanixCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SNutanixCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SBingoCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- Endpoint string
- SAccessKeyCredential
- }
- func (opts *SBingoCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("BingoCloud"), "provider")
- return params, nil
- }
- type SBingoCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SBingoCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SBingoCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SBingoCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts.SAccessKeyCredential), nil
- }
- type SInCloudSphereAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- HOST string
- SAccessKeyCredential
- }
- func (opts *SInCloudSphereAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString(api.CLOUD_PROVIDER_INCLOUD_SPHERE), "provider")
- return params, nil
- }
- type SInCloudSphereAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SInCloudSphereAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SInCloudSphereAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SInCloudSphereAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts.SAccessKeyCredential), nil
- }
- type SProxmoxAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SProxmoxCredentialWithEnvironment
- }
- func (opts *SProxmoxAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString(api.CLOUD_PROVIDER_PROXMOX), "provider")
- return params, nil
- }
- type SProxmoxAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SProxmoxAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SProxmoxAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- }
- func (opts *SProxmoxAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts.SUserPasswordCredential), nil
- }
- type SRemoteFileAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- AuthURL string
- }
- func (opts *SRemoteFileAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString(api.CLOUD_PROVIDER_REMOTEFILE), "provider")
- return params, nil
- }
- type SKsyunCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- OptionsBillingReportBucket string `help:"update Ksyun S3 bucket that stores account billing report" json:"-"`
- }
- func (opts *SKsyunCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- options := params.(*jsonutils.JSONDict)
- options.Add(jsonutils.NewString("Ksyun"), "provider")
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Set("billing_report_bucket", jsonutils.NewString(opts.OptionsBillingReportBucket))
- }
- return options, nil
- }
- type SKsyunCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- OptionsBillingReportBucket string `help:"update VolcEngine S3 bucket that stores account billing report" json:"-"`
- RemoveOptionsBillingReportBucket bool `help:"remove VolcEngine S3 bucket that stores account billing report" json:"-"`
- }
- func (opts *SKsyunCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- options := jsonutils.NewDict()
- if len(opts.OptionsBillingReportBucket) > 0 {
- options.Add(jsonutils.NewString(opts.OptionsBillingReportBucket), "billing_report_bucket")
- }
- if options.Size() > 0 {
- params.Add(options, "options")
- }
- removeOptions := make([]string, 0)
- if opts.RemoveOptionsBillingReportBucket {
- removeOptions = append(removeOptions, "billing_report_bucket")
- }
- if len(removeOptions) > 0 {
- params.Add(jsonutils.NewStringArray(removeOptions), "remove_options")
- }
- return params, nil
- }
- type SKsyunCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SKsyunCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SBaiduCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SBaiduCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Baidu"), "provider")
- return params, nil
- }
- type SBaiduCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SBaiduCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- return params, nil
- }
- type SBaiduCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SBaiduCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCucloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SCucloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("ChinaUnion"), "provider")
- return params, nil
- }
- type SCucloudCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SCucloudCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- return params, nil
- }
- type SCucloudCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SCucloudCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SQingCloudCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SQingCloudCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("QingCloud"), "provider")
- return params, nil
- }
- type SQingCloudCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SQingCloudCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- return params, nil
- }
- type SQingCloudCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SQingCloudCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SOracleCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- OraclePrivateKeyFile string `help:"Oracle private key" positional:"true"`
- OracleTenancyOCID string
- OracleUserOCID string
- }
- func (opts *SOracleCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- params.Add(jsonutils.NewString("OracleCloud"), "provider")
- data, err := os.ReadFile(opts.OraclePrivateKeyFile)
- if err != nil {
- return nil, err
- }
- params.Set("oracle_private_key", jsonutils.NewString(string(data)))
- return params, nil
- }
- type SCephFSCredentialWithEnvironment struct {
- SUserPasswordCredential
- Host string `help:"CephFS host" positional:"true"`
- Port string `help:"CephFS host port" default:"8443"`
- }
- type SCephFSCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SCephFSCredentialWithEnvironment
- }
- func (opts *SCephFSCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("CephFS"), "provider")
- return params, nil
- }
- type SCNwareCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SUserPasswordCredential
- AuthURL string `help:"CNware auth_url" positional:"true" json:"auth_url"`
- }
- func (opts *SCNwareCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("CNware"), "provider")
- return params, nil
- }
- type SCNwareCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SUserPasswordCredential
- }
- func (opts *SCNwareCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SCNwareCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SCNwareCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
- type SOceanbaseCloudAccountCreateOptions struct {
- SCloudAccountCreateBaseOptions
- SAccessKeyCredential
- }
- func (opts *SOceanbaseCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts)
- params.(*jsonutils.JSONDict).Add(jsonutils.NewString("OceanBase"), "provider")
- return params, nil
- }
- type SOceanbaseCloudAccountUpdateOptions struct {
- SCloudAccountUpdateBaseOptions
- }
- func (opts *SOceanbaseCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
- return params, nil
- }
- type SOceanbaseCloudAccountUpdateCredentialOptions struct {
- SCloudAccountIdOptions
- SAccessKeyCredential
- }
- func (opts *SOceanbaseCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(opts), nil
- }
|