From 4fb14a23c0ff2a58334ee22ee0078baef2db088e Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Wed, 10 Nov 2021 22:03:41 +0800 Subject: [PATCH 1/8] support alibaba cloud manual mode --- cmd/ccoctl/main.go | 2 + pkg/alibabacloud/client.go | 57 ++++ pkg/alibabacloud/mock/client_generated.go | 95 +++++++ pkg/apis/cloudcredential/v1/register.go | 1 + pkg/apis/cloudcredential/v1/types_alibaba.go | 51 ++++ .../v1/zz_generated.deepcopy.go | 78 ++++++ pkg/cmd/provisioning/alibabacloud/README.md | 83 ++++++ pkg/cmd/provisioning/alibabacloud/alibaba.go | 30 ++ .../alibabacloud/attach-ram-policy.go | 265 ++++++++++++++++++ .../alibabacloud/attach-ram-policy_test.go | 185 ++++++++++++ 10 files changed, 847 insertions(+) create mode 100644 pkg/alibabacloud/client.go create mode 100644 pkg/alibabacloud/mock/client_generated.go create mode 100644 pkg/apis/cloudcredential/v1/types_alibaba.go create mode 100644 pkg/cmd/provisioning/alibabacloud/README.md create mode 100644 pkg/cmd/provisioning/alibabacloud/alibaba.go create mode 100644 pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go create mode 100644 pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go diff --git a/cmd/ccoctl/main.go b/cmd/ccoctl/main.go index 2feff5007b..6ea2026738 100644 --- a/cmd/ccoctl/main.go +++ b/cmd/ccoctl/main.go @@ -8,6 +8,7 @@ import ( "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/aws" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/gcp" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/ibmcloud" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/alibabacloud" ) func main() { @@ -19,6 +20,7 @@ func main() { rootCmd.AddCommand(aws.NewAWSCmd()) rootCmd.AddCommand(gcp.NewGCPCmd()) rootCmd.AddCommand(ibmcloud.NewIBMCloudCmd()) + rootCmd.AddCommand(alibabacloud.NewAliababaCloudCmd()) if err := rootCmd.Execute(); err != nil { log.Fatal(err) diff --git a/pkg/alibabacloud/client.go b/pkg/alibabacloud/client.go new file mode 100644 index 0000000000..01a2a78d16 --- /dev/null +++ b/pkg/alibabacloud/client.go @@ -0,0 +1,57 @@ +/* +Copyright 2021 The OpenShift Authors. + +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 alibabacloud + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" +) + +//go:generate mockgen -source=./client.go -destination=./mock/client_generated.go -package=mock + +// Client is a wrapper object for actual Alibaba Cloud SDK clients to allow for easier testing. +type Client interface { + //RAM + CreatePolicy(*ram.CreatePolicyRequest) (*ram.CreatePolicyResponse, error) + AttachPolicyToUser(*ram.AttachPolicyToUserRequest) (*ram.AttachPolicyToUserResponse, error) + DeletePolicy(*ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) + DetachPolicyFromUser(*ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) +} + +type alibabaCloudClient struct { + ramClient ram.Client +} + +func (c *alibabaCloudClient) CreatePolicy(request *ram.CreatePolicyRequest) (response *ram.CreatePolicyResponse, err error) { + return c.ramClient.CreatePolicy(request) +} + +func (c *alibabaCloudClient) AttachPolicyToUser(input *ram.AttachPolicyToUserRequest) (*ram.AttachPolicyToUserResponse, error) { + return c.ramClient.AttachPolicyToUser(input) +} + +func (c *alibabaCloudClient) DeletePolicy(input *ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) { + return c.ramClient.DeletePolicy(input) +} + +func (c *alibabaCloudClient) DetachPolicyFromUser(input *ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) { + return c.ramClient.DetachPolicyFromUser(input) +} + +// NewClient creates our client wrapper object for the actual Alibaba Cloud clients we use. +func NewClient(accessKeyID, accessKeySecret, region string) (Client, error) { + return ram.NewClientWithAccessKey(region, accessKeyID, accessKeySecret) +} diff --git a/pkg/alibabacloud/mock/client_generated.go b/pkg/alibabacloud/mock/client_generated.go new file mode 100644 index 0000000000..5264866ac6 --- /dev/null +++ b/pkg/alibabacloud/mock/client_generated.go @@ -0,0 +1,95 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./client.go + +// Package mock is a generated GoMock package. +package mock + +import ( + reflect "reflect" + + ram "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + gomock "github.com/golang/mock/gomock" +) + +// MockClient is a mock of Client interface. +type MockClient struct { + ctrl *gomock.Controller + recorder *MockClientMockRecorder +} + +// MockClientMockRecorder is the mock recorder for MockClient. +type MockClientMockRecorder struct { + mock *MockClient +} + +// NewMockClient creates a new mock instance. +func NewMockClient(ctrl *gomock.Controller) *MockClient { + mock := &MockClient{ctrl: ctrl} + mock.recorder = &MockClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockClient) EXPECT() *MockClientMockRecorder { + return m.recorder +} + +// AttachPolicyToUser mocks base method. +func (m *MockClient) AttachPolicyToUser(arg0 *ram.AttachPolicyToUserRequest) (*ram.AttachPolicyToUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AttachPolicyToUser", arg0) + ret0, _ := ret[0].(*ram.AttachPolicyToUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AttachPolicyToUser indicates an expected call of AttachPolicyToUser. +func (mr *MockClientMockRecorder) AttachPolicyToUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttachPolicyToUser", reflect.TypeOf((*MockClient)(nil).AttachPolicyToUser), arg0) +} + +// CreatePolicy mocks base method. +func (m *MockClient) CreatePolicy(arg0 *ram.CreatePolicyRequest) (*ram.CreatePolicyResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreatePolicy", arg0) + ret0, _ := ret[0].(*ram.CreatePolicyResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreatePolicy indicates an expected call of CreatePolicy. +func (mr *MockClientMockRecorder) CreatePolicy(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePolicy", reflect.TypeOf((*MockClient)(nil).CreatePolicy), arg0) +} + +// DeletePolicy mocks base method. +func (m *MockClient) DeletePolicy(arg0 *ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeletePolicy", arg0) + ret0, _ := ret[0].(*ram.DeletePolicyResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeletePolicy indicates an expected call of DeletePolicy. +func (mr *MockClientMockRecorder) DeletePolicy(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockClient)(nil).DeletePolicy), arg0) +} + +// DetachPolicyFromUser mocks base method. +func (m *MockClient) DetachPolicyFromUser(arg0 *ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DetachPolicyFromUser", arg0) + ret0, _ := ret[0].(*ram.DetachPolicyFromUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DetachPolicyFromUser indicates an expected call of DetachPolicyFromUser. +func (mr *MockClientMockRecorder) DetachPolicyFromUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachPolicyFromUser", reflect.TypeOf((*MockClient)(nil).DetachPolicyFromUser), arg0) +} diff --git a/pkg/apis/cloudcredential/v1/register.go b/pkg/apis/cloudcredential/v1/register.go index 4f135da68a..7a01044f65 100644 --- a/pkg/apis/cloudcredential/v1/register.go +++ b/pkg/apis/cloudcredential/v1/register.go @@ -54,6 +54,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &CredentialsRequest{}, &CredentialsRequestList{}, + &AlibabaCloudProviderStatus{}, &AlibabaCloudProviderSpec{}, &AWSProviderStatus{}, &AWSProviderSpec{}, &AzureProviderStatus{}, &AzureProviderSpec{}, &GCPProviderStatus{}, &GCPProviderSpec{}, diff --git a/pkg/apis/cloudcredential/v1/types_alibaba.go b/pkg/apis/cloudcredential/v1/types_alibaba.go new file mode 100644 index 0000000000..4ee13eba04 --- /dev/null +++ b/pkg/apis/cloudcredential/v1/types_alibaba.go @@ -0,0 +1,51 @@ +/* +Copyright 2021 The OpenShift Authors. + +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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// TODO: these types should eventually be broken out, along with the actuator, to a separate repo. + +// AlibabaCloudProviderSpec contains the required information to create a user policy in AlibabaCloud. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type AlibabaCloudProviderSpec struct { + metav1.TypeMeta `json:",inline"` + // StatementEntries contains a list of policy statements that should be associated with this credentials access key. + StatementEntries []AlibabaStatementEntry `json:"statementEntries"` +} + +// StatementEntry models an AlibabaCloud policy statement entry. +type AlibabaStatementEntry struct { + // Effect indicates if this policy statement is to Allow or Deny. + Effect string `json:"effect"` + // Action describes the particular AlibabaCloud service actions that should be allowed or denied. + Action []string `json:"action"` + // Resource specifies the object(s) this statement should apply to. (or "*" for all) + Resource string `json:"resource"` +} + +// AlibabaCloudProviderStatus containes the status of the credentials request in AlibabaCloud. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type AlibabaCloudProviderStatus struct { + metav1.TypeMeta `json:",inline"` + // User is the name of the User created in AlibabaCloud for these credentials. + User string `json:"user"` + // Policy is the name of the policy attached to the user in AlibabaCloud. + Policy string `json:"policy"` +} diff --git a/pkg/apis/cloudcredential/v1/zz_generated.deepcopy.go b/pkg/apis/cloudcredential/v1/zz_generated.deepcopy.go index a032f1c332..079831eca9 100644 --- a/pkg/apis/cloudcredential/v1/zz_generated.deepcopy.go +++ b/pkg/apis/cloudcredential/v1/zz_generated.deepcopy.go @@ -92,6 +92,84 @@ func (in *AccessPolicy) DeepCopy() *AccessPolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AlibabaCloudProviderSpec) DeepCopyInto(out *AlibabaCloudProviderSpec) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.StatementEntries != nil { + in, out := &in.StatementEntries, &out.StatementEntries + *out = make([]AlibabaStatementEntry, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlibabaCloudProviderSpec. +func (in *AlibabaCloudProviderSpec) DeepCopy() *AlibabaCloudProviderSpec { + if in == nil { + return nil + } + out := new(AlibabaCloudProviderSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AlibabaCloudProviderSpec) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AlibabaCloudProviderStatus) DeepCopyInto(out *AlibabaCloudProviderStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlibabaCloudProviderStatus. +func (in *AlibabaCloudProviderStatus) DeepCopy() *AlibabaCloudProviderStatus { + if in == nil { + return nil + } + out := new(AlibabaCloudProviderStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AlibabaCloudProviderStatus) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AlibabaStatementEntry) DeepCopyInto(out *AlibabaStatementEntry) { + *out = *in + if in.Action != nil { + in, out := &in.Action, &out.Action + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlibabaStatementEntry. +func (in *AlibabaStatementEntry) DeepCopy() *AlibabaStatementEntry { + if in == nil { + return nil + } + out := new(AlibabaStatementEntry) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AzureProviderSpec) DeepCopyInto(out *AzureProviderSpec) { *out = *in diff --git a/pkg/cmd/provisioning/alibabacloud/README.md b/pkg/cmd/provisioning/alibabacloud/README.md new file mode 100644 index 0000000000..4199d78409 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/README.md @@ -0,0 +1,83 @@ +# Alibaba Cloud Manual Mode + +This is the guide for using manual mode on alibaba cloud, for more use info about manual mode, please reference to [cco-mode-manual](https://docs.openshift.com/container-platform/4.9/authentication/managing_cloud_provider_credentials/cco-mode-manual.html). + +In alibaba cloud manual mode, the CCO utility (`ccoctl`) binary would generate long-lived RAM AK credentials for individual OpenShift Container Platform cluster components. The ram user who owns the AK would be attached the ram policy with the permission defined in each components, and a root ram user who required `ram:CreatePolicy` and `ram:AttachPolicyToUser` pemission as least is needed for attaching the permission for each component. + +## Prerequisite + +1. Extract and prepare the ccoctl binary from the release image. + +2. [create a ram user](https://partners-intl.aliyun.com/help/doc-detail/93720.htm)(has no permission in default) for binding the cluster components permission, and get the ram accesskey id/accesskey secret/user name as the input parameters of the alibaba cloud ccoctl command. + +3. choose an existing ram user who required `ram:CreatePolicy` and `ram:AttachPolicyToUser` pemission as least, and get this ram user's accesskey id/accesskey secret for attaching the specific component permission to the ram user created in step 2. + + + +## Procedure + +1. Extract the list of CredentialsRequest custom resources (CRs) from the OpenShift Container Platform release image: + + ```bash + $ oc adm release extract --credentials-requests --cloud=alibabacloud --to=/credrequests quay.io//ocp-release: + + ``` + +2. For each CredentialsRequest CR in the release image, ensure that a namespace that matches the text in the spec.secretRef.namespace field exists in the cluster. This field is where the generated secrets that hold the credentials configuration are stored. + + Sample Alibaba Cloud CredentialsRequest object + + ```yaml + apiVersion: cloudcredential.openshift.io/v1 + kind: CredentialsRequest + metadata: + name: cloud-credential-operator-ram-ro + namespace: openshift-cloud-credential-operator + spec: + providerSpec: + apiVersion: cloudcredential.openshift.io/v1 + kind: AlibabaCloudProviderSpec + statementEntries: + - action: + - ecs:CopySnapshot + - ecs:DeleteDisk + - ecs:DescribeInstanceAttribute + - ecs:DescribeInstances + effect: Allow + resource: '*' + secretRef: + namespace: cloud-credential-operator-ram-ro-creds + name: openshift-cloud-credential-operator + ``` + +3. For any `CredentialsRequest` CR for which the cluster does not already have a namespace with the name specified in `spec.secretRef.namespace`, create the namespace: + + ``` + $ oc create namespace + ``` + +4. Use the `ccoctl` tool to process all `CredentialsRequest` objects in the `credrequests` directory: + + ```bash + $ ccoctl alibabacloud attach-ram-policy --name --region= --credentials-requests-dir=/credrequests --root-access-key=xxxxx --root-access-key-secret=xxxxx --user-name=testuser --component-access-key=xxxxxx --component-access-secret=xxxxxx --output-dir=xxxxxx + ``` + + where: + + - `name` is the name used to tag any cloud resources that are created for tracking. + - `region` is the Alibaba Cloud region in which cloud resources will be created. + - `credentials-requests-dir` is the directory containing files of component CredentialsRequests. + - `root-access-key` is the ram user ak with ram permission such as CreatePolicy/AttachPolicyToUser as least. + - `root-access-key-secret` is the ram user sk with ram permission such as CreatePolicy/AttachPolicyToUser as least. + - `user-name` is the ram user name who created for binding components required ram permission. + - `component-access-key` is the ram user ak who created for binding components required ram permission. + - `component-access-secret` is the ram user sk who created for binding components required ram permission. + - `output-dir`/manifests is the directory containing files of component credentials secret. + +5. Apply the secrets to your cluster: + + ```bash + $ ls /manifests/*-credentials.yaml | xargs -I{} oc apply -f {} + ``` + + \ No newline at end of file diff --git a/pkg/cmd/provisioning/alibabacloud/alibaba.go b/pkg/cmd/provisioning/alibabacloud/alibaba.go new file mode 100644 index 0000000000..b10e9f8ed8 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/alibaba.go @@ -0,0 +1,30 @@ +package alibabacloud + +import ( + "github.com/spf13/cobra" +) + +type options struct { + TargetDir string + Name string + Region string + RootAccessKeyId string + RootAccessKeySecret string + ComponentAccessKeyId string + ComponentAccessKeySecret string + CredRequestDir string + UserName string +} + +// NewAliababaCloudCmd implements the "alibabacloud" subcommand for the credentials provisioning +func NewAliababaCloudCmd() *cobra.Command { + createCmd := &cobra.Command{ + Use: "alibabacloud", + Short: "Manage credentials objects for alibaba cloud", + Long: "Creating/deleting cloud credentials objects for alibaba cloud", + } + + createCmd.AddCommand(NewAttachRAMPolicyCmd()) + + return createCmd +} diff --git a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go b/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go new file mode 100644 index 0000000000..f20d37de63 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go @@ -0,0 +1,265 @@ +package alibabacloud + +import ( + "encoding/json" + "fmt" + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + "io/ioutil" + "log" + "os" + "path/filepath" + + "github.com/openshift/cloud-credential-operator/pkg/alibabacloud" + credreqv1 "github.com/openshift/cloud-credential-operator/pkg/apis/cloudcredential/v1" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +const ( + secretManifestsTemplate = `apiVersion: v1 +data: + access_key_id: %s + access_key_secret: %s +kind: Secret +metadata: + name: %s + namespace: %s +type: Opaque` + + // Https for ram client scheme + Https = "https" + // Custom is ram policy type + Custom = "Custom" +) + +var ( + // AttachRAMPolicyOpts captures the options that affect creation/updating + // of the RAM Roles. + AttachRAMPolicyOpts = options{ + TargetDir: "", + } +) + +type ComponenntSecretInfo struct { + componentAccessKeyId string + componentAccessKeySecret string + targetDir string + userName string +} + +func attachRAMPolicy(client alibabacloud.Client, name, credReqDir string, componenntSecretInfo ComponenntSecretInfo) error { + // Process directory + credRequests, err := provisioning.GetListOfCredentialsRequests(credReqDir) + if err != nil { + return errors.Wrap(err, "Failed to process files containing CredentialsRequests") + } + + // Create RAM Roles (with policies) + if err := processCredentialsRequests(client, credRequests, name, componenntSecretInfo); err != nil { + return errors.Wrap(err, "Failed while processing each CredentialsRequest") + } + + return nil +} + +func processCredentialsRequests(client alibabacloud.Client, credReqs []*credreqv1.CredentialsRequest, name string, componenntSecretInfo ComponenntSecretInfo) error { + for _, cr := range credReqs { + // infraName-targetNamespace-targetSecretName + err := createAndAttachPolicy(client, name, cr, componenntSecretInfo) + if err != nil { + return err + } + } + return nil +} + +func attachRAMPolicyCmd(cmd *cobra.Command, args []string) { + client, err := alibabacloud.NewClient(AttachRAMPolicyOpts.Region, AttachRAMPolicyOpts.RootAccessKeyId, AttachRAMPolicyOpts.RootAccessKeySecret) + if err != nil { + log.Fatal(err) + } + var componentSecretInfo = ComponenntSecretInfo{ + componentAccessKeyId: AttachRAMPolicyOpts.ComponentAccessKeyId, + componentAccessKeySecret: AttachRAMPolicyOpts.ComponentAccessKeySecret, + targetDir: AttachRAMPolicyOpts.TargetDir, + userName: AttachRAMPolicyOpts.UserName, + } + if componentSecretInfo.componentAccessKeyId == "" || componentSecretInfo.componentAccessKeySecret == "" || componentSecretInfo.userName == "" { + log.Fatal(errors.New("invalid empty value for component-access-key/component-access-secret or user-name")) + } + err = attachRAMPolicy(client, AttachRAMPolicyOpts.Name, AttachRAMPolicyOpts.CredRequestDir, componentSecretInfo) + if err != nil { + log.Fatal(err) + } +} + +func createAndAttachPolicy(client alibabacloud.Client, name string, credReq *credreqv1.CredentialsRequest, componenntSecretInfo ComponenntSecretInfo) error { + policyName := fmt.Sprintf("%s-%s-policy", name, credReq.Spec.SecretRef.Name) + + // Decode Alibaba CloudProviderSpec + codec, err := credreqv1.NewCodec() + if err != nil { + return errors.Wrap(err, "Failed to create credReq codec") + } + + alibabaProviderSpec := credreqv1.AlibabaCloudProviderSpec{} + if err := codec.DecodeProviderSpec(credReq.Spec.ProviderSpec, &alibabaProviderSpec); err != nil { + return errors.Wrap(err, "Failed to decode the provider spec") + } + + if alibabaProviderSpec.Kind != "AlibabaCloudProviderSpec" { + return fmt.Errorf("CredentialsRequest %s/%s is not of type Alibaba Cloud", credReq.Namespace, credReq.Name) + } + + err = createComponentPolicy(client, policyName, alibabaProviderSpec.StatementEntries) + if err != nil { + return err + } + log.Printf("ram policy %s has created", policyName) + + err = attachComponentPolicy(client, componenntSecretInfo.userName, policyName) + if err != nil { + return err + } + log.Printf("policy %s has attached on user %s", policyName, componenntSecretInfo.userName) + + if err := writeCredReqSecret(credReq, componenntSecretInfo); err != nil { + return errors.Wrap(err, "failed to save Secret for install manifests") + } + return nil +} + +// StatementEntry is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. +type StatementEntry struct { + Effect string + Action []string + Resource string + // Must "omitempty" otherwise we send unacceptable JSON to the Alibaba Cloud API when no + // condition is defined. + Condition credreqv1.RAMPolicyCondition `json:",omitempty"` +} + +// PolicyDocument is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. +type PolicyDocument struct { + Version string + Statement []StatementEntry +} + +func createComponentPolicy(client alibabacloud.Client, policyName string, statements []credreqv1.AlibabaStatementEntry) error { + policyDocument := PolicyDocument{ + Version: "1", + Statement: []StatementEntry{}, + } + + for _, entry := range statements { + policyDocument.Statement = append(policyDocument.Statement, + StatementEntry{ + Effect: entry.Effect, + Action: entry.Action, + Resource: entry.Resource, + Condition: entry.PolicyCondition, + }) + } + + policyBytes, err := json.Marshal(&policyDocument) + if err != nil { + log.Fatalf("Failed to marshal the policy to JSON: %s", err) + } + + req := ram.CreatePolicyRequest{} + req.Scheme = Https + req.PolicyName = policyName + req.PolicyDocument = string(policyBytes) + _, err = client.CreatePolicy(&req) + return err +} + +func attachComponentPolicy(client alibabacloud.Client, user, policyName string) error { + req := ram.AttachPolicyToUserRequest{} + req.Scheme = Https + req.PolicyName = policyName + req.UserName = user + req.PolicyType = Custom + _, err := client.AttachPolicyToUser(&req) + return err +} + +// writeCredReqSecret will take a credentialsRequest and return +// a Secret with the AK/SK of a ram user who has grant component permission defined in credentialsRequest. +func writeCredReqSecret(cr *credreqv1.CredentialsRequest, componenntSecretInfo ComponenntSecretInfo) error { + manifestsDir := filepath.Join(componenntSecretInfo.targetDir, provisioning.ManifestsDirName) + + fileName := fmt.Sprintf("%s-%s-credentials.yaml", cr.Spec.SecretRef.Namespace, cr.Spec.SecretRef.Name) + filePath := filepath.Join(manifestsDir, fileName) + + fileData := fmt.Sprintf(secretManifestsTemplate, componenntSecretInfo.componentAccessKeyId, componenntSecretInfo.componentAccessKeySecret, cr.Spec.SecretRef.Name, cr.Spec.SecretRef.Namespace) + + if err := ioutil.WriteFile(filePath, []byte(fileData), 0600); err != nil { + return errors.Wrap(err, "Failed to save Secret file") + } + + log.Printf("Saved credentials configuration to: %s", filePath) + + return nil +} + +// initEnvForAttachRAMPolicyCmd will ensure the destination directory is ready to receive the generated +// files, and will create the directory if necessary. +func initEnvForAttachRAMPolicyCmd(cmd *cobra.Command, args []string) { + if AttachRAMPolicyOpts.TargetDir == "" { + pwd, err := os.Getwd() + if err != nil { + log.Fatalf("Failed to get current directory: %s", err) + } + + AttachRAMPolicyOpts.TargetDir = pwd + } + + fPath, err := filepath.Abs(AttachRAMPolicyOpts.TargetDir) + if err != nil { + log.Fatalf("Failed to resolve full path: %s", err) + } + + // create target dir if necessary + err = provisioning.EnsureDir(fPath) + if err != nil { + log.Fatalf("failed to create target directory at %s", fPath) + } + + // create manifests dir if necessary + manifestsDir := filepath.Join(fPath, provisioning.ManifestsDirName) + err = provisioning.EnsureDir(manifestsDir) + if err != nil { + log.Fatalf("failed to create manifests directory at %s", manifestsDir) + } +} + +// NewCreateRAMPolicyCmd provides the "attach-ram-policy" subcommand +func NewAttachRAMPolicyCmd() *cobra.Command { + attachRAMPolicyCmd := &cobra.Command{ + Use: "attach-ram-policy", + Short: "Attach RAM Policy", + Run: attachRAMPolicyCmd, + PersistentPreRun: initEnvForAttachRAMPolicyCmd, + } + + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.Name, "name", "", "User-define name for all created Alibaba Cloud resources (can be separate from the cluster's infra-id)") + attachRAMPolicyCmd.MarkPersistentFlagRequired("name") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.CredRequestDir, "credentials-requests-dir", "", "Directory containing files of CredentialsRequests to create RAM AK for (can be created by running 'oc adm release extract --credentials-requests --cloud=alibabacloud' against an OpenShift release image)") + attachRAMPolicyCmd.MarkPersistentFlagRequired("credentials-requests-dir") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.RootAccessKeyId, "root-access-key", "", "The root user ak with ram permission such as CreatePolicy/AttachPolicyToUser") + attachRAMPolicyCmd.MarkPersistentFlagRequired("root-access-key") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.RootAccessKeySecret, "root-access-key-secret", "", "The root user sk with ram permission such as CreatePolicy/AttachPolicyToUser") + attachRAMPolicyCmd.MarkPersistentFlagRequired("root-access-key-secret") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.UserName, "user-name", "", "The specific ram user name, the user would attach all permission defined in CredentialsRequests") + attachRAMPolicyCmd.MarkPersistentFlagRequired("user-name") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.ComponentAccessKeyId, "component-access-key", "", "The created component user ak with ram permission defined in CredentialsRequests") + attachRAMPolicyCmd.MarkPersistentFlagRequired("component-access-key") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.ComponentAccessKeySecret, "component-access-secret", "", "The created component user sk with ram permission defined in CredentialsRequests") + attachRAMPolicyCmd.MarkPersistentFlagRequired("component-access-secret") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.Region, "region", "", "Alibaba Cloud region endpoint only required for GovCloud") + attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.TargetDir, "output-dir", "", "Directory to place generated files (defaults to current directory)") + + return attachRAMPolicyCmd +} diff --git a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go b/pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go new file mode 100644 index 0000000000..d4f094dadd --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go @@ -0,0 +1,185 @@ +package alibabacloud + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + + mockalibaba "github.com/openshift/cloud-credential-operator/pkg/alibabacloud/mock" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" +) + +const ( + testNamePrefix = "test-cluster1" + testUserName = "test-user" + testDirPrefix = "ramtestdir" + testComponentAccessKeyId = "testAK" + testComponentAccessKeySecret = "testSK" +) + +var mockPolicyInCreatePolicy = ram.PolicyInCreatePolicy{ + PolicyName: "alibaba-mock-test", + PolicyType: "Custom", + Description: "alibaba-mock-test", + DefaultVersion: "v1", + CreateDate: "2021-01-23T12:33:18Z", +} + +func TestAttachRAMPolicy(t *testing.T) { + tests := []struct { + name string + mockAlibabaClient func(mockCtrl *gomock.Controller) *mockalibaba.MockClient + setup func(*testing.T) string + verify func(t *testing.T, manifestDir string) + cleanup func(*testing.T) + generateOnly bool + expectError bool + }{ + { + name: "No CredReqs", + generateOnly: true, + mockAlibabaClient: func(mockCtrl *gomock.Controller) *mockalibaba.MockClient { + mockAlibabaClient := mockalibaba.NewMockClient(mockCtrl) + mockCreatePolicy(mockAlibabaClient) + return mockAlibabaClient + }, + setup: func(t *testing.T) string { + tempDirName, err := ioutil.TempDir(os.TempDir(), testDirPrefix) + require.NoError(t, err, "Failed to create temp directory") + return tempDirName + }, + verify: func(t *testing.T, manifestDir string) { + files, err := ioutil.ReadDir(manifestDir) + require.NoError(t, err, "unexpected error listing files in manifestDir") + assert.Zero(t, len(files), "Should be no files in manifestDir when no CredReqs to process") + + }, + }, + { + name: "Generate for one CredReq", + generateOnly: true, + mockAlibabaClient: func(mockCtrl *gomock.Controller) *mockalibaba.MockClient { + mockAlibabaClient := mockalibaba.NewMockClient(mockCtrl) + mockCreatePolicy(mockAlibabaClient) + mockAttachPolicyToUser(mockAlibabaClient) + return mockAlibabaClient + }, + setup: func(t *testing.T) string { + tempDirName, err := ioutil.TempDir(os.TempDir(), testDirPrefix) + require.NoError(t, err, "Failed to create temp directory") + + err = testCredentialsRequest(t, "firstcredreq", "namespace1", "secretName1", tempDirName) + require.NoError(t, err, "errored while setting up test CredReq files") + + return tempDirName + }, + verify: func(t *testing.T, manifestDir string) { + files, err := ioutil.ReadDir(manifestDir) + require.NoError(t, err, "unexpected error listing files in manifestDir") + + assert.Equal(t, 1, len(files), "The target user ak/sk secret manifest file should created for each CredReq") + + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + mockAlibabaClient := test.mockAlibabaClient(mockCtrl) + + credReqDir := test.setup(t) + defer os.RemoveAll(credReqDir) + + targetDir, err := ioutil.TempDir(os.TempDir(), "rampolicytest") + require.NoError(t, err, "unexpected error creating target dir for test") + defer os.RemoveAll(targetDir) + + manifestsDir := filepath.Join(targetDir, provisioning.ManifestsDirName) + err = provisioning.EnsureDir(manifestsDir) + require.NoError(t, err, "unexpected error creating manifests dir for test") + defer os.RemoveAll(manifestsDir) + + var componentSecretInfo = ComponenntSecretInfo{ + componentAccessKeyId: testComponentAccessKeyId, + componentAccessKeySecret: testComponentAccessKeySecret, + targetDir: targetDir, + userName: testUserName, + } + err = attachRAMPolicy(mockAlibabaClient, testNamePrefix, credReqDir, componentSecretInfo) + + if test.expectError { + require.Error(t, err, "expected error returned") + } else { + test.verify(t, manifestsDir) + } + }) + } +} + +func testCredentialsRequest(t *testing.T, crName, targetSecretNamespace, targetSecretName, targetDir string) error { + credReqTemplate := `--- +apiVersion: cloudcredential.openshift.io/v1 +kind: CredentialsRequest +metadata: + name: %s + namespace: openshift-cloud-credential-operator +spec: + providerSpec: + apiVersion: cloudcredential.openshift.io/v1 + kind: AlibabaCloudProviderSpec + statementEntries: + - action: + - ecs:CopySnapshot + - ecs:DeleteDisk + - ecs:DescribeInstanceAttribute + - ecs:DescribeInstances + effect: Allow + resource: '*' + - action: + - nas:DescribeFileSystems + - nas:DescribeMountTargets + - nas:AddTags + - nas:DescribeTags + - nas:RemoveTags + - nas:CreateFileSystem + effect: Allow + resource: '*' + secretRef: + namespace: %s + name: %s` + + credReq := fmt.Sprintf(credReqTemplate, crName, targetSecretNamespace, targetSecretName) + + f, err := ioutil.TempFile(targetDir, "testCredReq") + require.NoError(t, err, "error creating temp file for CredentialsRequest") + defer f.Close() + + _, err = f.Write([]byte(credReq)) + require.NoError(t, err, "error while writing out contents of CredentialsRequest file") + + return nil +} + +func mockCreatePolicy(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().CreatePolicy(gomock.Any()).Return( + &ram.CreatePolicyResponse{ + Policy: mockPolicyInCreatePolicy, + }, nil).Times(1) +} + +func mockAttachPolicyToUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().AttachPolicyToUser(gomock.Any()).Return( + &ram.AttachPolicyToUserResponse{}, nil, + ).Times(1) +} From 4f2a8959fac2ebb2e0d80e680291c7e2686b56a2 Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Tue, 23 Nov 2021 23:21:43 +0800 Subject: [PATCH 2/8] vendor alibaba cloud ram sdk --- go.mod | 4 +- go.sum | 11 + .../aliyun/alibaba-cloud-sdk-go/LICENSE | 201 + .../alibaba-cloud-sdk-go/sdk/api_timeout.go | 249 + .../sdk/auth/credential.go | 18 + .../auth/credentials/access_key_credential.go | 34 + .../credentials/bearer_token_credential.go | 12 + .../sdk/auth/credentials/ecs_ram_role.go | 29 + .../sdk/auth/credentials/provider/env.go | 30 + .../provider/instance_credentials.go | 92 + .../provider/profile_credentials.go | 159 + .../sdk/auth/credentials/provider/provider.go | 19 + .../credentials/provider/provider_chain.go | 34 + .../credentials/rsa_key_pair_credential.go | 15 + .../sdk/auth/credentials/sts_credential.go | 15 + .../credentials/sts_role_arn_credential.go | 62 + .../sdk/auth/roa_signature_composer.go | 140 + .../sdk/auth/rpc_signature_composer.go | 94 + .../alibaba-cloud-sdk-go/sdk/auth/signer.go | 98 + .../sdk/auth/signers/algorithms.go | 57 + .../sdk/auth/signers/credential_updater.go | 54 + .../sdk/auth/signers/session_credential.go | 7 + .../sdk/auth/signers/signer_access_key.go | 54 + .../sdk/auth/signers/signer_bearer_token.go | 35 + .../sdk/auth/signers/signer_ecs_ram_role.go | 167 + .../sdk/auth/signers/signer_key_pair.go | 148 + .../sdk/auth/signers/signer_ram_role_arn.go | 180 + .../sdk/auth/signers/signer_sts_token.go | 54 + .../sdk/auth/signers/signer_v2.go | 54 + .../aliyun/alibaba-cloud-sdk-go/sdk/client.go | 852 ++++ .../aliyun/alibaba-cloud-sdk-go/sdk/config.go | 92 + .../sdk/endpoints/endpoints_config.go | 4078 +++++++++++++++++ .../sdk/endpoints/local_global_resolver.go | 43 + .../sdk/endpoints/local_regional_resolver.go | 48 + .../sdk/endpoints/location_resolver.go | 176 + .../sdk/endpoints/mapping_resolver.go | 49 + .../sdk/endpoints/resolver.go | 96 + .../sdk/errors/client_error.go | 92 + .../alibaba-cloud-sdk-go/sdk/errors/error.go | 23 + .../sdk/errors/server_error.go | 123 + .../signature_does_not_match_wrapper.go | 45 + .../aliyun/alibaba-cloud-sdk-go/sdk/logger.go | 117 + .../sdk/requests/acs_request.go | 525 +++ .../sdk/requests/common_request.go | 112 + .../sdk/requests/roa_request.go | 148 + .../sdk/requests/rpc_request.go | 81 + .../sdk/requests/types.go | 53 + .../sdk/responses/json_parser.go | 333 ++ .../sdk/responses/response.go | 144 + .../alibaba-cloud-sdk-go/sdk/utils/debug.go | 36 + .../alibaba-cloud-sdk-go/sdk/utils/utils.go | 141 + .../services/ram/add_user_to_group.go | 104 + .../services/ram/attach_policy_to_group.go | 105 + .../services/ram/attach_policy_to_role.go | 105 + .../services/ram/attach_policy_to_user.go | 105 + .../services/ram/bind_mfa_device.go | 106 + .../services/ram/change_password.go | 104 + .../services/ram/clear_account_alias.go | 102 + .../services/ram/client.go | 129 + .../services/ram/create_access_key.go | 104 + .../services/ram/create_group.go | 105 + .../services/ram/create_login_profile.go | 107 + .../services/ram/create_policy.go | 106 + .../services/ram/create_policy_version.go | 107 + .../services/ram/create_role.go | 107 + .../services/ram/create_user.go | 108 + .../services/ram/create_virtual_mfa_device.go | 104 + .../services/ram/delete_access_key.go | 104 + .../services/ram/delete_group.go | 103 + .../services/ram/delete_login_profile.go | 103 + .../services/ram/delete_policy.go | 103 + .../services/ram/delete_policy_version.go | 104 + .../services/ram/delete_role.go | 103 + .../services/ram/delete_user.go | 103 + .../services/ram/delete_virtual_mfa_device.go | 103 + .../services/ram/detach_policy_from_group.go | 105 + .../services/ram/detach_policy_from_role.go | 105 + .../services/ram/detach_policy_from_user.go | 105 + .../services/ram/endpoint.go | 20 + .../services/ram/get_access_key_last_used.go | 105 + .../services/ram/get_account_alias.go | 103 + .../services/ram/get_group.go | 104 + .../services/ram/get_login_profile.go | 104 + .../services/ram/get_password_policy.go | 103 + .../services/ram/get_policy.go | 106 + .../services/ram/get_policy_version.go | 106 + .../services/ram/get_role.go | 104 + .../services/ram/get_security_preference.go | 103 + .../services/ram/get_user.go | 104 + .../services/ram/get_user_mfa_info.go | 104 + .../services/ram/list_access_keys.go | 104 + .../services/ram/list_entities_for_policy.go | 107 + .../services/ram/list_groups.go | 107 + .../services/ram/list_groups_for_user.go | 104 + .../services/ram/list_policies.go | 108 + .../services/ram/list_policies_for_group.go | 104 + .../services/ram/list_policies_for_role.go | 104 + .../services/ram/list_policies_for_user.go | 104 + .../services/ram/list_policy_versions.go | 105 + .../services/ram/list_roles.go | 107 + .../services/ram/list_users.go | 107 + .../services/ram/list_users_for_group.go | 108 + .../services/ram/list_virtual_mfa_devices.go | 103 + .../services/ram/remove_user_from_group.go | 104 + .../services/ram/set_account_alias.go | 103 + .../ram/set_default_policy_version.go | 104 + .../services/ram/set_password_policy.go | 112 + .../services/ram/set_security_preference.go | 110 + .../struct_access_key_in_create_access_key.go | 24 + .../struct_access_key_in_list_access_keys.go | 23 + .../ram/struct_access_key_last_used.go | 21 + ...y_preference_in_get_security_preference.go | 21 + ...y_preference_in_set_security_preference.go | 21 + .../services/ram/struct_access_keys.go | 21 + .../ram/struct_default_policy_version.go | 24 + .../ram/struct_group_in_create_group.go | 23 + .../services/ram/struct_group_in_get_group.go | 24 + ...truct_group_in_list_entities_for_policy.go | 23 + .../ram/struct_group_in_list_groups.go | 24 + .../struct_group_in_list_groups_for_user.go | 23 + .../ram/struct_group_in_update_group.go | 24 + ...ruct_groups_in_list_entities_for_policy.go | 21 + .../ram/struct_groups_in_list_groups.go | 21 + .../struct_groups_in_list_groups_for_user.go | 21 + ...t_login_profile_in_create_login_profile.go | 24 + ...ruct_login_profile_in_get_login_profile.go | 24 + ...e_preference_in_get_security_preference.go | 24 + ...e_preference_in_set_security_preference.go | 24 + .../struct_mfa_device_in_get_user_mfa_info.go | 21 + .../struct_mfa_device_in_unbind_mfa_device.go | 21 + ...a_preference_in_get_security_preference.go | 21 + ...a_preference_in_set_security_preference.go | 21 + ..._password_policy_in_get_password_policy.go | 29 + ..._password_policy_in_set_password_policy.go | 29 + .../ram/struct_policies_in_list_policies.go | 21 + ...uct_policies_in_list_policies_for_group.go | 21 + ...ruct_policies_in_list_policies_for_role.go | 21 + ...ruct_policies_in_list_policies_for_user.go | 21 + .../ram/struct_policy_in_create_policy.go | 25 + .../ram/struct_policy_in_get_policy.go | 28 + .../ram/struct_policy_in_list_policies.go | 27 + ...truct_policy_in_list_policies_for_group.go | 25 + ...struct_policy_in_list_policies_for_role.go | 25 + ...struct_policy_in_list_policies_for_user.go | 25 + ...policy_version_in_create_policy_version.go | 24 + ...ct_policy_version_in_get_policy_version.go | 24 + ..._policy_version_in_list_policy_versions.go | 24 + .../services/ram/struct_policy_versions.go | 21 + ...y_preference_in_get_security_preference.go | 21 + ...y_preference_in_set_security_preference.go | 21 + .../ram/struct_role_in_create_role.go | 27 + .../services/ram/struct_role_in_get_role.go | 28 + ...struct_role_in_list_entities_for_policy.go | 25 + .../services/ram/struct_role_in_list_roles.go | 27 + .../ram/struct_role_in_update_role.go | 28 + ...truct_roles_in_list_entities_for_policy.go | 21 + .../ram/struct_roles_in_list_roles.go | 21 + ...y_preference_in_get_security_preference.go | 24 + ...y_preference_in_set_security_preference.go | 24 + .../ram/struct_user_in_create_user.go | 27 + .../services/ram/struct_user_in_get_user.go | 29 + ...struct_user_in_list_entities_for_policy.go | 24 + .../services/ram/struct_user_in_list_users.go | 28 + .../struct_user_in_list_users_for_group.go | 23 + ...struct_user_in_list_virtual_mfa_devices.go | 23 + .../ram/struct_user_in_update_user.go | 28 + ...truct_users_in_list_entities_for_policy.go | 21 + .../ram/struct_users_in_list_users.go | 21 + .../struct_users_in_list_users_for_group.go | 21 + ...mfa_device_in_create_virtual_mfa_device.go | 23 + ..._mfa_device_in_list_virtual_mfa_devices.go | 23 + .../ram/struct_virtual_mfa_devices.go | 21 + .../services/ram/unbind_mfa_device.go | 104 + .../services/ram/update_access_key.go | 105 + .../services/ram/update_group.go | 106 + .../services/ram/update_login_profile.go | 106 + .../services/ram/update_role.go | 106 + .../services/ram/update_user.go | 109 + vendor/gopkg.in/ini.v1/.gitignore | 6 + vendor/gopkg.in/ini.v1/LICENSE | 191 + vendor/gopkg.in/ini.v1/Makefile | 15 + vendor/gopkg.in/ini.v1/README.md | 43 + vendor/gopkg.in/ini.v1/codecov.yml | 9 + vendor/gopkg.in/ini.v1/data_source.go | 76 + vendor/gopkg.in/ini.v1/deprecated.go | 25 + vendor/gopkg.in/ini.v1/error.go | 34 + vendor/gopkg.in/ini.v1/file.go | 517 +++ vendor/gopkg.in/ini.v1/helper.go | 24 + vendor/gopkg.in/ini.v1/ini.go | 176 + vendor/gopkg.in/ini.v1/key.go | 829 ++++ vendor/gopkg.in/ini.v1/parser.go | 535 +++ vendor/gopkg.in/ini.v1/section.go | 256 ++ vendor/gopkg.in/ini.v1/struct.go | 747 +++ vendor/modules.txt | 16 + 194 files changed, 21095 insertions(+), 1 deletion(-) create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/LICENSE create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/api_timeout.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/access_key_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/bearer_token_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/ecs_ram_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/env.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/instance_credentials.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/profile_credentials.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider_chain.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/rsa_key_pair_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_role_arn_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/roa_signature_composer.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/rpc_signature_composer.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signer.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/algorithms.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/credential_updater.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/session_credential.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_access_key.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_bearer_token.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ecs_ram_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_key_pair.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ram_role_arn.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_sts_token.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_v2.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/client.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/config.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/endpoints_config.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_global_resolver.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_regional_resolver.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/mapping_resolver.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/resolver.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/client_error.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/error.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/server_error.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/signature_does_not_match_wrapper.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/logger.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/acs_request.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/common_request.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/roa_request.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/rpc_request.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/types.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/json_parser.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/response.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/debug.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/utils.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/add_user_to_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/bind_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/change_password.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/clear_account_alias.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/client.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_access_key.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_virtual_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_access_key.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_virtual_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/endpoint.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_access_key_last_used.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_account_alias.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_password_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user_mfa_info.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_access_keys.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policy_versions.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_roles.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_virtual_mfa_devices.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/remove_user_from_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_account_alias.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_default_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_password_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_create_access_key.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_list_access_keys.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_last_used.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_keys.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_default_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_create_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_get_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_update_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_create_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_get_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_get_user_mfa_info.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_unbind_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_get_password_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_set_password_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_create_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_get_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_create_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_get_policy_version.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_list_policy_versions.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_versions.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_create_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_get_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_roles.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_update_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_roles.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_get_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_set_security_preference.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_create_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_get_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_virtual_mfa_devices.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_update_user.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_entities_for_policy.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users_for_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_create_virtual_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_list_virtual_mfa_devices.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_devices.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/unbind_mfa_device.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_access_key.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_group.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_login_profile.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_role.go create mode 100644 vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_user.go create mode 100644 vendor/gopkg.in/ini.v1/.gitignore create mode 100644 vendor/gopkg.in/ini.v1/LICENSE create mode 100644 vendor/gopkg.in/ini.v1/Makefile create mode 100644 vendor/gopkg.in/ini.v1/README.md create mode 100644 vendor/gopkg.in/ini.v1/codecov.yml create mode 100644 vendor/gopkg.in/ini.v1/data_source.go create mode 100644 vendor/gopkg.in/ini.v1/deprecated.go create mode 100644 vendor/gopkg.in/ini.v1/error.go create mode 100644 vendor/gopkg.in/ini.v1/file.go create mode 100644 vendor/gopkg.in/ini.v1/helper.go create mode 100644 vendor/gopkg.in/ini.v1/ini.go create mode 100644 vendor/gopkg.in/ini.v1/key.go create mode 100644 vendor/gopkg.in/ini.v1/parser.go create mode 100644 vendor/gopkg.in/ini.v1/section.go create mode 100644 vendor/gopkg.in/ini.v1/struct.go diff --git a/go.mod b/go.mod index 553d58669d..f64dead24c 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,8 @@ require ( github.com/Azure/go-autorest/autorest/to v0.3.0 github.com/IBM/go-sdk-core/v5 v5.6.3 github.com/IBM/platform-services-go-sdk v0.19.4 + github.com/aliyun/alibaba-cloud-sdk-go v1.61.1323 + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/aws/aws-sdk-go v1.37.14 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/go-bindata/go-bindata v3.1.2+incompatible @@ -61,7 +63,6 @@ require ( github.com/Azure/go-autorest/tracing v0.5.0 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver v3.5.0+incompatible // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect @@ -120,6 +121,7 @@ require ( google.golang.org/protobuf v1.27.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect k8s.io/apiextensions-apiserver v0.19.2 // indirect k8s.io/component-base v0.19.2 // indirect diff --git a/go.sum b/go.sum index 136d4a3aa9..f9d548615d 100644 --- a/go.sum +++ b/go.sum @@ -105,6 +105,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.1323 h1:QSfS1AsgI1wwGhDeCEXC2LqjEssBCchiaUW+fHX5bFA= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.1323/go.mod h1:9CMdKNL3ynIGPpfTcdwTvIm8SGuAZYYC4jFVSSvE1YQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -317,6 +319,7 @@ github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5 github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -419,6 +422,7 @@ github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3i github.com/googleapis/gnostic v0.5.1 h1:A8Yhf6EtqTv9RMsU6MQTyrtV1TjWlR6xU9BsZIwuTCM= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v0.0.0-20191024121256-f395758b854c/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -471,6 +475,7 @@ github.com/imdario/mergo v0.3.10 h1:6q5mVkdH/vYmqngx7kZQTjJ5HRsx+ImorDIEQ+beJgc= github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -478,6 +483,7 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -485,6 +491,7 @@ github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= @@ -658,7 +665,9 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -1218,6 +1227,8 @@ gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWd gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/LICENSE b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/LICENSE new file mode 100644 index 0000000000..0c44dcefe3 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + + 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. diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/api_timeout.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/api_timeout.go new file mode 100644 index 0000000000..d7968dab70 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/api_timeout.go @@ -0,0 +1,249 @@ +package sdk + +import ( + "encoding/json" + "strings" + "time" +) + +var apiTimeouts = `{ + "ecs": { + "ActivateRouterInterface": 10, + "AddTags": 61, + "AllocateDedicatedHosts": 10, + "AllocateEipAddress": 17, + "AllocatePublicIpAddress": 36, + "ApplyAutoSnapshotPolicy": 10, + "AssignIpv6Addresses": 10, + "AssignPrivateIpAddresses": 10, + "AssociateEipAddress": 17, + "AttachClassicLinkVpc": 14, + "AttachDisk": 36, + "AttachInstanceRamRole": 11, + "AttachKeyPair": 16, + "AttachNetworkInterface": 16, + "AuthorizeSecurityGroupEgress": 16, + "AuthorizeSecurityGroup": 16, + "CancelAutoSnapshotPolicy": 10, + "CancelCopyImage": 10, + "CancelPhysicalConnection": 10, + "CancelSimulatedSystemEvents": 10, + "CancelTask": 10, + "ConnectRouterInterface": 10, + "ConvertNatPublicIpToEip": 12, + "CopyImage": 10, + "CreateAutoSnapshotPolicy": 10, + "CreateCommand": 16, + "CreateDeploymentSet": 16, + "CreateDisk": 36, + "CreateHpcCluster": 10, + "CreateImage": 36, + "CreateInstance": 86, + "CreateKeyPair": 10, + "CreateLaunchTemplate": 10, + "CreateLaunchTemplateVersion": 10, + "CreateNatGateway": 36, + "CreateNetworkInterfacePermission": 13, + "CreateNetworkInterface": 16, + "CreatePhysicalConnection": 10, + "CreateRouteEntry": 17, + "CreateRouterInterface": 10, + "CreateSecurityGroup": 86, + "CreateSimulatedSystemEvents": 10, + "CreateSnapshot": 86, + "CreateVirtualBorderRouter": 10, + "CreateVpc": 16, + "CreateVSwitch": 17, + "DeactivateRouterInterface": 10, + "DeleteAutoSnapshotPolicy": 10, + "DeleteBandwidthPackage": 10, + "DeleteCommand": 16, + "DeleteDeploymentSet": 12, + "DeleteDisk": 16, + "DeleteHpcCluster": 10, + "DeleteImage": 36, + "DeleteInstance": 66, + "DeleteKeyPairs": 10, + "DeleteLaunchTemplate": 10, + "DeleteLaunchTemplateVersion": 10, + "DeleteNatGateway": 10, + "DeleteNetworkInterfacePermission": 10, + "DeleteNetworkInterface": 16, + "DeletePhysicalConnection": 10, + "DeleteRouteEntry": 16, + "DeleteRouterInterface": 10, + "DeleteSecurityGroup": 87, + "DeleteSnapshot": 17, + "DeleteVirtualBorderRouter": 10, + "DeleteVpc": 17, + "DeleteVSwitch": 17, + "DescribeAccessPoints": 10, + "DescribeAccountAttributes": 10, + "DescribeAutoSnapshotPolicyEx": 16, + "DescribeAvailableResource": 10, + "DescribeBandwidthLimitation": 16, + "DescribeBandwidthPackages": 10, + "DescribeClassicLinkInstances": 15, + "DescribeCloudAssistantStatus": 16, + "DescribeClusters": 10, + "DescribeCommands": 16, + "DescribeDedicatedHosts": 10, + "DescribeDedicatedHostTypes": 10, + "DescribeDeploymentSets": 26, + "DescribeDiskMonitorData": 16, + "DescribeDisksFullStatus": 14, + "DescribeDisks": 19, + "DescribeEipAddresses": 16, + "DescribeEipMonitorData": 16, + "DescribeEniMonitorData": 10, + "DescribeHaVips": 10, + "DescribeHpcClusters": 16, + "DescribeImageSharePermission": 10, + "DescribeImages": 38, + "DescribeImageSupportInstanceTypes": 16, + "DescribeInstanceAttribute": 36, + "DescribeInstanceAutoRenewAttribute": 17, + "DescribeInstanceHistoryEvents": 19, + "DescribeInstanceMonitorData": 19, + "DescribeInstancePhysicalAttribute": 10, + "DescribeInstanceRamRole": 11, + "DescribeInstancesFullStatus": 14, + "DescribeInstances": 10, + "DescribeInstanceStatus": 26, + "DescribeInstanceTopology": 12, + "DescribeInstanceTypeFamilies": 17, + "DescribeInstanceTypes": 17, + "DescribeInstanceVncPasswd": 10, + "DescribeInstanceVncUrl": 36, + "DescribeInvocationResults": 16, + "DescribeInvocations": 16, + "DescribeKeyPairs": 12, + "DescribeLaunchTemplates": 16, + "DescribeLaunchTemplateVersions": 16, + "DescribeLimitation": 36, + "DescribeNatGateways": 10, + "DescribeNetworkInterfacePermissions": 13, + "DescribeNetworkInterfaces": 16, + "DescribeNewProjectEipMonitorData": 16, + "DescribePhysicalConnections": 10, + "DescribePrice": 16, + "DescribeRecommendInstanceType": 10, + "DescribeRegions": 19, + "DescribeRenewalPrice": 16, + "DescribeResourceByTags": 10, + "DescribeResourcesModification": 17, + "DescribeRouterInterfaces": 10, + "DescribeRouteTables": 17, + "DescribeSecurityGroupAttribute": 133, + "DescribeSecurityGroupReferences": 16, + "DescribeSecurityGroups": 25, + "DescribeSnapshotLinks": 17, + "DescribeSnapshotMonitorData": 12, + "DescribeSnapshotPackage": 10, + "DescribeSnapshots": 26, + "DescribeSnapshotsUsage": 26, + "DescribeSpotPriceHistory": 22, + "DescribeTags": 17, + "DescribeTaskAttribute": 10, + "DescribeTasks": 11, + "DescribeUserBusinessBehavior": 13, + "DescribeUserData": 10, + "DescribeVirtualBorderRoutersForPhysicalConnection": 10, + "DescribeVirtualBorderRouters": 10, + "DescribeVpcs": 41, + "DescribeVRouters": 17, + "DescribeVSwitches": 17, + "DescribeZones": 103, + "DetachClassicLinkVpc": 14, + "DetachDisk": 17, + "DetachInstanceRamRole": 10, + "DetachKeyPair": 10, + "DetachNetworkInterface": 16, + "EipFillParams": 19, + "EipFillProduct": 13, + "EipNotifyPaid": 10, + "EnablePhysicalConnection": 10, + "ExportImage": 10, + "GetInstanceConsoleOutput": 14, + "GetInstanceScreenshot": 14, + "ImportImage": 29, + "ImportKeyPair": 10, + "InstallCloudAssistant": 10, + "InvokeCommand": 16, + "JoinResourceGroup": 10, + "JoinSecurityGroup": 66, + "LeaveSecurityGroup": 66, + "ModifyAutoSnapshotPolicyEx": 10, + "ModifyBandwidthPackageSpec": 11, + "ModifyCommand": 10, + "ModifyDeploymentSetAttribute": 10, + "ModifyDiskAttribute": 16, + "ModifyDiskChargeType": 13, + "ModifyEipAddressAttribute": 14, + "ModifyImageAttribute": 10, + "ModifyImageSharePermission": 16, + "ModifyInstanceAttribute": 22, + "ModifyInstanceAutoReleaseTime": 15, + "ModifyInstanceAutoRenewAttribute": 16, + "ModifyInstanceChargeType": 22, + "ModifyInstanceDeployment": 10, + "ModifyInstanceNetworkSpec": 36, + "ModifyInstanceSpec": 62, + "ModifyInstanceVncPasswd": 35, + "ModifyInstanceVpcAttribute": 15, + "ModifyLaunchTemplateDefaultVersion": 10, + "ModifyNetworkInterfaceAttribute": 10, + "ModifyPhysicalConnectionAttribute": 10, + "ModifyPrepayInstanceSpec": 13, + "ModifyRouterInterfaceAttribute": 10, + "ModifySecurityGroupAttribute": 10, + "ModifySecurityGroupEgressRule": 10, + "ModifySecurityGroupPolicy": 10, + "ModifySecurityGroupRule": 16, + "ModifySnapshotAttribute": 10, + "ModifyUserBusinessBehavior": 10, + "ModifyVirtualBorderRouterAttribute": 10, + "ModifyVpcAttribute": 10, + "ModifyVRouterAttribute": 10, + "ModifyVSwitchAttribute": 10, + "ReActivateInstances": 10, + "RebootInstance": 27, + "RedeployInstance": 14, + "ReInitDisk": 16, + "ReleaseDedicatedHost": 10, + "ReleaseEipAddress": 16, + "ReleasePublicIpAddress": 10, + "RemoveTags": 10, + "RenewInstance": 19, + "ReplaceSystemDisk": 36, + "ResetDisk": 36, + "ResizeDisk": 11, + "RevokeSecurityGroupEgress": 13, + "RevokeSecurityGroup": 16, + "RunInstances": 86, + "StartInstance": 46, + "StopInstance": 27, + "StopInvocation": 10, + "TerminatePhysicalConnection": 10, + "TerminateVirtualBorderRouter": 10, + "UnassignIpv6Addresses": 10, + "UnassignPrivateIpAddresses": 10, + "UnassociateEipAddress": 16 + } +} +` + +func getAPIMaxTimeout(product, actionName string) (time.Duration, bool) { + timeout := make(map[string]map[string]int) + err := json.Unmarshal([]byte(apiTimeouts), &timeout) + if err != nil { + return 0 * time.Millisecond, false + } + + obj := timeout[strings.ToLower(product)] + if obj != nil && obj[actionName] != 0 { + return time.Duration(obj[actionName]) * time.Second, true + } + + return 0 * time.Millisecond, false +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credential.go new file mode 100644 index 0000000000..7f20b7a40c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credential.go @@ -0,0 +1,18 @@ +/* + * 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 auth + +type Credential interface { +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/access_key_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/access_key_credential.go new file mode 100644 index 0000000000..68f8226330 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/access_key_credential.go @@ -0,0 +1,34 @@ +package credentials + +// Deprecated: Use AccessKeyCredential in this package instead. +type BaseCredential struct { + AccessKeyId string + AccessKeySecret string +} + +type AccessKeyCredential struct { + AccessKeyId string + AccessKeySecret string +} + +// Deprecated: Use NewAccessKeyCredential in this package instead. +func NewBaseCredential(accessKeyId, accessKeySecret string) *BaseCredential { + return &BaseCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + } +} + +func (baseCred *BaseCredential) ToAccessKeyCredential() *AccessKeyCredential { + return &AccessKeyCredential{ + AccessKeyId: baseCred.AccessKeyId, + AccessKeySecret: baseCred.AccessKeySecret, + } +} + +func NewAccessKeyCredential(accessKeyId, accessKeySecret string) *AccessKeyCredential { + return &AccessKeyCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/bearer_token_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/bearer_token_credential.go new file mode 100644 index 0000000000..6d4763e663 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/bearer_token_credential.go @@ -0,0 +1,12 @@ +package credentials + +type BearerTokenCredential struct { + BearerToken string +} + +// NewBearerTokenCredential return a BearerTokenCredential object +func NewBearerTokenCredential(token string) *BearerTokenCredential { + return &BearerTokenCredential{ + BearerToken: token, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/ecs_ram_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/ecs_ram_role.go new file mode 100644 index 0000000000..55a5c2da03 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/ecs_ram_role.go @@ -0,0 +1,29 @@ +package credentials + +func (oldCred *StsRoleNameOnEcsCredential) ToEcsRamRoleCredential() *EcsRamRoleCredential { + return &EcsRamRoleCredential{ + RoleName: oldCred.RoleName, + } +} + +type EcsRamRoleCredential struct { + RoleName string +} + +func NewEcsRamRoleCredential(roleName string) *EcsRamRoleCredential { + return &EcsRamRoleCredential{ + RoleName: roleName, + } +} + +// Deprecated: Use EcsRamRoleCredential in this package instead. +type StsRoleNameOnEcsCredential struct { + RoleName string +} + +// Deprecated: Use NewEcsRamRoleCredential in this package instead. +func NewStsRoleNameOnEcsCredential(roleName string) *StsRoleNameOnEcsCredential { + return &StsRoleNameOnEcsCredential{ + RoleName: roleName, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/env.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/env.go new file mode 100644 index 0000000000..3cd0d020a7 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/env.go @@ -0,0 +1,30 @@ +package provider + +import ( + "errors" + "os" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" +) + +type EnvProvider struct{} + +var ProviderEnv = new(EnvProvider) + +func NewEnvProvider() Provider { + return &EnvProvider{} +} + +func (p *EnvProvider) Resolve() (auth.Credential, error) { + accessKeyID, ok1 := os.LookupEnv(ENVAccessKeyID) + accessKeySecret, ok2 := os.LookupEnv(ENVAccessKeySecret) + if !ok1 || !ok2 { + return nil, nil + } + if accessKeyID == "" || accessKeySecret == "" { + return nil, errors.New("Environmental variable (ALIBABACLOUD_ACCESS_KEY_ID or ALIBABACLOUD_ACCESS_KEY_SECRET) is empty") + } + return credentials.NewAccessKeyCredential(accessKeyID, accessKeySecret), nil +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/instance_credentials.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/instance_credentials.go new file mode 100644 index 0000000000..074f6350b2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/instance_credentials.go @@ -0,0 +1,92 @@ +package provider + +import ( + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "os" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" +) + +var securityCredURL = "http://100.100.100.200/latest/meta-data/ram/security-credentials/" + +type InstanceCredentialsProvider struct{} + +var ProviderInstance = new(InstanceCredentialsProvider) + +var HookGet = func(fn func(string) (int, []byte, error)) func(string) (int, []byte, error) { + return fn +} + +func NewInstanceCredentialsProvider() Provider { + return &InstanceCredentialsProvider{} +} + +func (p *InstanceCredentialsProvider) Resolve() (auth.Credential, error) { + roleName, ok := os.LookupEnv(ENVEcsMetadata) + if !ok { + return nil, nil + } + if roleName == "" { + return nil, errors.New("Environmental variable 'ALIBABA_CLOUD_ECS_METADATA' are empty") + } + status, content, err := HookGet(get)(securityCredURL + roleName) + if err != nil { + return nil, err + } + if status != 200 { + if status == 404 { + return nil, fmt.Errorf("The role was not found in the instance") + } + return nil, fmt.Errorf("Received %d when getting security credentials for %s", status, roleName) + } + body := make(map[string]interface{}) + + if err := json.Unmarshal(content, &body); err != nil { + return nil, err + } + + accessKeyID, err := extractString(body, "AccessKeyId") + if err != nil { + return nil, err + } + accessKeySecret, err := extractString(body, "AccessKeySecret") + if err != nil { + return nil, err + } + securityToken, err := extractString(body, "SecurityToken") + if err != nil { + return nil, err + } + + return credentials.NewStsTokenCredential(accessKeyID, accessKeySecret, securityToken), nil +} + +func get(url string) (status int, content []byte, err error) { + httpClient := http.DefaultClient + httpClient.Timeout = 1 * time.Second + resp, err := httpClient.Get(url) + if err != nil { + return + } + defer resp.Body.Close() + content, err = ioutil.ReadAll(resp.Body) + return resp.StatusCode, content, err +} + +func extractString(m map[string]interface{}, key string) (string, error) { + raw, ok := m[key] + if !ok { + return "", fmt.Errorf("%s not in map", key) + } + str, ok := raw.(string) + if !ok { + return "", fmt.Errorf("%s is not a string in map", key) + } + return str, nil +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/profile_credentials.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/profile_credentials.go new file mode 100644 index 0000000000..146b97945b --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/profile_credentials.go @@ -0,0 +1,159 @@ +package provider + +import ( + "bufio" + "errors" + "os" + "runtime" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + + ini "gopkg.in/ini.v1" +) + +type ProfileProvider struct { + Profile string +} + +var ProviderProfile = NewProfileProvider() + +// NewProfileProvider receive zero or more parameters, +// when length of name is 0, the value of field Profile will be "default", +// and when there are multiple inputs, the function will take the +// first one and discard the other values. +func NewProfileProvider(name ...string) Provider { + p := new(ProfileProvider) + if len(name) == 0 { + p.Profile = "default" + } else { + p.Profile = name[0] + } + return p +} + +// Resolve implements the Provider interface +// when credential type is rsa_key_pair, the content of private_key file +// must be able to be parsed directly into the required string +// that NewRsaKeyPairCredential function needed +func (p *ProfileProvider) Resolve() (auth.Credential, error) { + path, ok := os.LookupEnv(ENVCredentialFile) + if !ok { + var err error + path, err = checkDefaultPath() + if err != nil { + return nil, err + } + if path == "" { + return nil, nil + } + } else if path == "" { + return nil, errors.New("Environment variable '" + ENVCredentialFile + "' cannot be empty") + } + + ini, err := ini.Load(path) + if err != nil { + return nil, errors.New("ERROR: Can not open file" + err.Error()) + } + + section, err := ini.GetSection(p.Profile) + if err != nil { + return nil, errors.New("ERROR: Can not load section" + err.Error()) + } + + value, err := section.GetKey("type") + if err != nil { + return nil, errors.New("ERROR: Can not find credential type" + err.Error()) + } + + switch value.String() { + case "access_key": + value1, err1 := section.GetKey("access_key_id") + value2, err2 := section.GetKey("access_key_secret") + if err1 != nil || err2 != nil { + return nil, errors.New("ERROR: Failed to get value") + } + if value1.String() == "" || value2.String() == "" { + return nil, errors.New("ERROR: Value can't be empty") + } + return credentials.NewAccessKeyCredential(value1.String(), value2.String()), nil + case "ecs_ram_role": + value1, err1 := section.GetKey("role_name") + if err1 != nil { + return nil, errors.New("ERROR: Failed to get value") + } + if value1.String() == "" { + return nil, errors.New("ERROR: Value can't be empty") + } + return credentials.NewEcsRamRoleCredential(value1.String()), nil + case "ram_role_arn": + value1, err1 := section.GetKey("access_key_id") + value2, err2 := section.GetKey("access_key_secret") + value3, err3 := section.GetKey("role_arn") + value4, err4 := section.GetKey("role_session_name") + if err1 != nil || err2 != nil || err3 != nil || err4 != nil { + return nil, errors.New("ERROR: Failed to get value") + } + if value1.String() == "" || value2.String() == "" || value3.String() == "" || value4.String() == "" { + return nil, errors.New("ERROR: Value can't be empty") + } + return credentials.NewRamRoleArnCredential(value1.String(), value2.String(), value3.String(), value4.String(), 3600), nil + case "rsa_key_pair": + value1, err1 := section.GetKey("public_key_id") + value2, err2 := section.GetKey("private_key_file") + if err1 != nil || err2 != nil { + return nil, errors.New("ERROR: Failed to get value") + } + if value1.String() == "" || value2.String() == "" { + return nil, errors.New("ERROR: Value can't be empty") + } + file, err := os.Open(value2.String()) + if err != nil { + return nil, errors.New("ERROR: Can not get private_key") + } + defer file.Close() + var privateKey string + scan := bufio.NewScanner(file) + var data string + for scan.Scan() { + if strings.HasPrefix(scan.Text(), "----") { + continue + } + data += scan.Text() + "\n" + } + return credentials.NewRsaKeyPairCredential(privateKey, value1.String(), 3600), nil + default: + return nil, errors.New("ERROR: Failed to get credential") + } +} + +// GetHomePath return home directory according to the system. +// if the environmental virables does not exist, will return empty +func GetHomePath() string { + if runtime.GOOS == "windows" { + path, ok := os.LookupEnv("USERPROFILE") + if !ok { + return "" + } + return path + } + path, ok := os.LookupEnv("HOME") + if !ok { + return "" + } + return path +} + +func checkDefaultPath() (path string, err error) { + path = GetHomePath() + if path == "" { + return "", errors.New("The default credential file path is invalid") + } + path = strings.Replace("~/.alibabacloud/credentials", "~", path, 1) + _, err = os.Stat(path) + if err != nil { + return "", nil + } + return path, nil +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider.go new file mode 100644 index 0000000000..ae4e168eb1 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider.go @@ -0,0 +1,19 @@ +package provider + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" +) + +//Environmental virables that may be used by the provider +const ( + ENVAccessKeyID = "ALIBABA_CLOUD_ACCESS_KEY_ID" + ENVAccessKeySecret = "ALIBABA_CLOUD_ACCESS_KEY_SECRET" + ENVCredentialFile = "ALIBABA_CLOUD_CREDENTIALS_FILE" + ENVEcsMetadata = "ALIBABA_CLOUD_ECS_METADATA" + PATHCredentialFile = "~/.alibabacloud/credentials" +) + +// When you want to customize the provider, you only need to implement the method of the interface. +type Provider interface { + Resolve() (auth.Credential, error) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider_chain.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider_chain.go new file mode 100644 index 0000000000..3f9315d138 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider/provider_chain.go @@ -0,0 +1,34 @@ +package provider + +import ( + "errors" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" +) + +type ProviderChain struct { + Providers []Provider +} + +var defaultproviders = []Provider{ProviderEnv, ProviderProfile, ProviderInstance} +var DefaultChain = NewProviderChain(defaultproviders) + +func NewProviderChain(providers []Provider) Provider { + return &ProviderChain{ + Providers: providers, + } +} + +func (p *ProviderChain) Resolve() (auth.Credential, error) { + for _, provider := range p.Providers { + creds, err := provider.Resolve() + if err != nil { + return nil, err + } else if err == nil && creds == nil { + continue + } + return creds, err + } + return nil, errors.New("No credential found") + +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/rsa_key_pair_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/rsa_key_pair_credential.go new file mode 100644 index 0000000000..00d688eb8d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/rsa_key_pair_credential.go @@ -0,0 +1,15 @@ +package credentials + +type RsaKeyPairCredential struct { + PrivateKey string + PublicKeyId string + SessionExpiration int +} + +func NewRsaKeyPairCredential(privateKey, publicKeyId string, sessionExpiration int) *RsaKeyPairCredential { + return &RsaKeyPairCredential{ + PrivateKey: privateKey, + PublicKeyId: publicKeyId, + SessionExpiration: sessionExpiration, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_credential.go new file mode 100644 index 0000000000..554431ff0b --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_credential.go @@ -0,0 +1,15 @@ +package credentials + +type StsTokenCredential struct { + AccessKeyId string + AccessKeySecret string + AccessKeyStsToken string +} + +func NewStsTokenCredential(accessKeyId, accessKeySecret, accessKeyStsToken string) *StsTokenCredential { + return &StsTokenCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + AccessKeyStsToken: accessKeyStsToken, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_role_arn_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_role_arn_credential.go new file mode 100644 index 0000000000..3507bdf9d6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/sts_role_arn_credential.go @@ -0,0 +1,62 @@ +package credentials + +// Deprecated: Use RamRoleArnCredential in this package instead. +type StsRoleArnCredential struct { + AccessKeyId string + AccessKeySecret string + RoleArn string + RoleSessionName string + RoleSessionExpiration int +} + +type RamRoleArnCredential struct { + AccessKeyId string + AccessKeySecret string + RoleArn string + RoleSessionName string + RoleSessionExpiration int + Policy string + StsRegion string +} + +// Deprecated: Use RamRoleArnCredential in this package instead. +func NewStsRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName string, roleSessionExpiration int) *StsRoleArnCredential { + return &StsRoleArnCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + RoleArn: roleArn, + RoleSessionName: roleSessionName, + RoleSessionExpiration: roleSessionExpiration, + } +} + +func (oldCred *StsRoleArnCredential) ToRamRoleArnCredential() *RamRoleArnCredential { + return &RamRoleArnCredential{ + AccessKeyId: oldCred.AccessKeyId, + AccessKeySecret: oldCred.AccessKeySecret, + RoleArn: oldCred.RoleArn, + RoleSessionName: oldCred.RoleSessionName, + RoleSessionExpiration: oldCred.RoleSessionExpiration, + } +} + +func NewRamRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName string, roleSessionExpiration int) *RamRoleArnCredential { + return &RamRoleArnCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + RoleArn: roleArn, + RoleSessionName: roleSessionName, + RoleSessionExpiration: roleSessionExpiration, + } +} + +func NewRamRoleArnWithPolicyCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string, roleSessionExpiration int) *RamRoleArnCredential { + return &RamRoleArnCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + RoleArn: roleArn, + RoleSessionName: roleSessionName, + RoleSessionExpiration: roleSessionExpiration, + Policy: policy, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/roa_signature_composer.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/roa_signature_composer.go new file mode 100644 index 0000000000..9c55811d6c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/roa_signature_composer.go @@ -0,0 +1,140 @@ +/* + * 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 auth + +import ( + "bytes" + "sort" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +var debug utils.Debug + +var hookGetDate = func(fn func() string) string { + return fn() +} + +func init() { + debug = utils.Init("sdk") +} + +func signRoaRequest(request requests.AcsRequest, signer Signer, regionId string) (err error) { + // 先获取 accesskey,确保刷新 credential + accessKeyId, err := signer.GetAccessKeyId() + if err != nil { + return err + } + + completeROASignParams(request, signer, regionId) + stringToSign := buildRoaStringToSign(request) + request.SetStringToSign(stringToSign) + + signature := signer.Sign(stringToSign, "") + request.GetHeaders()["Authorization"] = "acs " + accessKeyId + ":" + signature + + return +} + +func completeROASignParams(request requests.AcsRequest, signer Signer, regionId string) { + headerParams := request.GetHeaders() + + // complete query params + queryParams := request.GetQueryParams() + //if _, ok := queryParams["RegionId"]; !ok { + // queryParams["RegionId"] = regionId + //} + if extraParam := signer.GetExtraParam(); extraParam != nil { + for key, value := range extraParam { + if key == "SecurityToken" { + headerParams["x-acs-security-token"] = value + continue + } + if key == "BearerToken" { + headerParams["x-acs-bearer-token"] = value + continue + } + queryParams[key] = value + } + } + + // complete header params + headerParams["Date"] = hookGetDate(utils.GetTimeInFormatRFC2616) + headerParams["x-acs-signature-method"] = signer.GetName() + headerParams["x-acs-signature-version"] = signer.GetVersion() + if request.GetFormParams() != nil && len(request.GetFormParams()) > 0 { + formString := utils.GetUrlFormedMap(request.GetFormParams()) + request.SetContent([]byte(formString)) + if headerParams["Content-Type"] == "" { + headerParams["Content-Type"] = requests.Form + } + } + contentMD5 := utils.GetMD5Base64(request.GetContent()) + headerParams["Content-MD5"] = contentMD5 + if _, contains := headerParams["Content-Type"]; !contains { + headerParams["Content-Type"] = requests.Raw + } + switch format := request.GetAcceptFormat(); format { + case "JSON": + headerParams["Accept"] = requests.Json + case "XML": + headerParams["Accept"] = requests.Xml + default: + headerParams["Accept"] = requests.Raw + } +} + +func buildRoaStringToSign(request requests.AcsRequest) (stringToSign string) { + + headers := request.GetHeaders() + + stringToSignBuilder := bytes.Buffer{} + stringToSignBuilder.WriteString(request.GetMethod()) + stringToSignBuilder.WriteString(requests.HeaderSeparator) + + // append header keys for sign + appendIfContain(headers, &stringToSignBuilder, "Accept", requests.HeaderSeparator) + appendIfContain(headers, &stringToSignBuilder, "Content-MD5", requests.HeaderSeparator) + appendIfContain(headers, &stringToSignBuilder, "Content-Type", requests.HeaderSeparator) + appendIfContain(headers, &stringToSignBuilder, "Date", requests.HeaderSeparator) + + // sort and append headers witch starts with 'x-acs-' + var acsHeaders []string + for key := range headers { + if strings.HasPrefix(key, "x-acs-") { + acsHeaders = append(acsHeaders, key) + } + } + sort.Strings(acsHeaders) + for _, key := range acsHeaders { + stringToSignBuilder.WriteString(key + ":" + headers[key]) + stringToSignBuilder.WriteString(requests.HeaderSeparator) + } + + // append query params + stringToSignBuilder.WriteString(request.BuildQueries()) + stringToSign = stringToSignBuilder.String() + debug("stringToSign: %s", stringToSign) + return +} + +func appendIfContain(sourceMap map[string]string, target *bytes.Buffer, key, separator string) { + if value, contain := sourceMap[key]; contain && len(value) > 0 { + target.WriteString(sourceMap[key]) + target.WriteString(separator) + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/rpc_signature_composer.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/rpc_signature_composer.go new file mode 100644 index 0000000000..33967b9efb --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/rpc_signature_composer.go @@ -0,0 +1,94 @@ +/* + * 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 auth + +import ( + "net/url" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +var hookGetNonce = func(fn func() string) string { + return fn() +} + +func signRpcRequest(request requests.AcsRequest, signer Signer, regionId string) (err error) { + err = completeRpcSignParams(request, signer, regionId) + if err != nil { + return + } + // remove while retry + if _, containsSign := request.GetQueryParams()["Signature"]; containsSign { + delete(request.GetQueryParams(), "Signature") + } + stringToSign := buildRpcStringToSign(request) + request.SetStringToSign(stringToSign) + signature := signer.Sign(stringToSign, "&") + request.GetQueryParams()["Signature"] = signature + + return +} + +func completeRpcSignParams(request requests.AcsRequest, signer Signer, regionId string) (err error) { + queryParams := request.GetQueryParams() + queryParams["Version"] = request.GetVersion() + queryParams["Action"] = request.GetActionName() + queryParams["Format"] = request.GetAcceptFormat() + queryParams["Timestamp"] = hookGetDate(utils.GetTimeInFormatISO8601) + queryParams["SignatureMethod"] = signer.GetName() + queryParams["SignatureType"] = signer.GetType() + queryParams["SignatureVersion"] = signer.GetVersion() + queryParams["SignatureNonce"] = hookGetNonce(utils.GetUUID) + queryParams["AccessKeyId"], err = signer.GetAccessKeyId() + + if err != nil { + return + } + + if _, contains := queryParams["RegionId"]; !contains { + queryParams["RegionId"] = regionId + } + if extraParam := signer.GetExtraParam(); extraParam != nil { + for key, value := range extraParam { + queryParams[key] = value + } + } + + request.GetHeaders()["Content-Type"] = requests.Form + formString := utils.GetUrlFormedMap(request.GetFormParams()) + request.SetContent([]byte(formString)) + + return +} + +func buildRpcStringToSign(request requests.AcsRequest) (stringToSign string) { + signParams := make(map[string]string) + for key, value := range request.GetQueryParams() { + signParams[key] = value + } + for key, value := range request.GetFormParams() { + signParams[key] = value + } + + stringToSign = utils.GetUrlFormedMap(signParams) + stringToSign = strings.Replace(stringToSign, "+", "%20", -1) + stringToSign = strings.Replace(stringToSign, "*", "%2A", -1) + stringToSign = strings.Replace(stringToSign, "%7E", "~", -1) + stringToSign = url.QueryEscape(stringToSign) + stringToSign = request.GetMethod() + "&%2F&" + stringToSign + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signer.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signer.go new file mode 100644 index 0000000000..cbbc3cef7d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signer.go @@ -0,0 +1,98 @@ +/* + * 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 auth + +import ( + "fmt" + "reflect" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +type Signer interface { + GetName() string + GetType() string + GetVersion() string + GetAccessKeyId() (string, error) + GetExtraParam() map[string]string + Sign(stringToSign, secretSuffix string) string +} + +func NewSignerWithCredential(credential Credential, commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)) (signer Signer, err error) { + switch instance := credential.(type) { + case *credentials.AccessKeyCredential: + { + signer = signers.NewAccessKeySigner(instance) + } + case *credentials.StsTokenCredential: + { + signer = signers.NewStsTokenSigner(instance) + } + case *credentials.BearerTokenCredential: + { + signer = signers.NewBearerTokenSigner(instance) + } + case *credentials.RamRoleArnCredential: + { + signer, err = signers.NewRamRoleArnSigner(instance, commonApi) + } + case *credentials.RsaKeyPairCredential: + { + signer, err = signers.NewSignerKeyPair(instance, commonApi) + } + case *credentials.EcsRamRoleCredential: + { + signer = signers.NewEcsRamRoleSigner(instance, commonApi) + } + case *credentials.BaseCredential: // deprecated user interface + { + signer = signers.NewAccessKeySigner(instance.ToAccessKeyCredential()) + } + case *credentials.StsRoleArnCredential: // deprecated user interface + { + signer, err = signers.NewRamRoleArnSigner(instance.ToRamRoleArnCredential(), commonApi) + } + case *credentials.StsRoleNameOnEcsCredential: // deprecated user interface + { + signer = signers.NewEcsRamRoleSigner(instance.ToEcsRamRoleCredential(), commonApi) + } + default: + message := fmt.Sprintf(errors.UnsupportedCredentialErrorMessage, reflect.TypeOf(credential)) + err = errors.NewClientError(errors.UnsupportedCredentialErrorCode, message, nil) + } + return +} + +func Sign(request requests.AcsRequest, signer Signer, regionId string) (err error) { + switch request.GetStyle() { + case requests.ROA: + { + err = signRoaRequest(request, signer, regionId) + } + case requests.RPC: + { + err = signRpcRequest(request, signer, regionId) + } + default: + message := fmt.Sprintf(errors.UnknownRequestTypeErrorMessage, reflect.TypeOf(request)) + err = errors.NewClientError(errors.UnknownRequestTypeErrorCode, message, nil) + } + + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/algorithms.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/algorithms.go new file mode 100644 index 0000000000..887f502094 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/algorithms.go @@ -0,0 +1,57 @@ +/* + * 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 signers + +import ( + "crypto" + "crypto/hmac" + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "encoding/base64" +) + +func ShaHmac1(source, secret string) string { + key := []byte(secret) + hmac := hmac.New(sha1.New, key) + hmac.Write([]byte(source)) + signedBytes := hmac.Sum(nil) + signedString := base64.StdEncoding.EncodeToString(signedBytes) + return signedString +} + +func Sha256WithRsa(source, secret string) string { + // block, _ := pem.Decode([]byte(secret)) + decodeString, err := base64.StdEncoding.DecodeString(secret) + if err != nil { + panic(err) + } + private, err := x509.ParsePKCS8PrivateKey(decodeString) + if err != nil { + panic(err) + } + + h := crypto.Hash.New(crypto.SHA256) + h.Write([]byte(source)) + hashed := h.Sum(nil) + signature, err := rsa.SignPKCS1v15(rand.Reader, private.(*rsa.PrivateKey), + crypto.SHA256, hashed) + if err != nil { + panic(err) + } + + return base64.StdEncoding.EncodeToString(signature) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/credential_updater.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/credential_updater.go new file mode 100644 index 0000000000..ba291a41e8 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/credential_updater.go @@ -0,0 +1,54 @@ +/* + * 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 signers + +import ( + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +const defaultInAdvanceScale = 0.95 + +type credentialUpdater struct { + credentialExpiration int + lastUpdateTimestamp int64 + inAdvanceScale float64 + buildRequestMethod func() (*requests.CommonRequest, error) + responseCallBack func(response *responses.CommonResponse) error + refreshApi func(request *requests.CommonRequest) (response *responses.CommonResponse, err error) +} + +func (updater *credentialUpdater) needUpdateCredential() (result bool) { + if updater.inAdvanceScale == 0 { + updater.inAdvanceScale = defaultInAdvanceScale + } + return time.Now().Unix()-updater.lastUpdateTimestamp >= int64(float64(updater.credentialExpiration)*updater.inAdvanceScale) +} + +func (updater *credentialUpdater) updateCredential() (err error) { + request, err := updater.buildRequestMethod() + if err != nil { + return + } + response, err := updater.refreshApi(request) + if err != nil { + return + } + updater.lastUpdateTimestamp = time.Now().Unix() + err = updater.responseCallBack(response) + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/session_credential.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/session_credential.go new file mode 100644 index 0000000000..99c624c880 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/session_credential.go @@ -0,0 +1,7 @@ +package signers + +type SessionCredential struct { + AccessKeyId string + AccessKeySecret string + StsToken string +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_access_key.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_access_key.go new file mode 100644 index 0000000000..bc4f35b856 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_access_key.go @@ -0,0 +1,54 @@ +/* + * 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 signers + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" +) + +type AccessKeySigner struct { + credential *credentials.AccessKeyCredential +} + +func (signer *AccessKeySigner) GetExtraParam() map[string]string { + return nil +} + +func NewAccessKeySigner(credential *credentials.AccessKeyCredential) *AccessKeySigner { + return &AccessKeySigner{ + credential: credential, + } +} + +func (*AccessKeySigner) GetName() string { + return "HMAC-SHA1" +} + +func (*AccessKeySigner) GetType() string { + return "" +} + +func (*AccessKeySigner) GetVersion() string { + return "1.0" +} + +func (signer *AccessKeySigner) GetAccessKeyId() (accessKeyId string, err error) { + return signer.credential.AccessKeyId, nil +} + +func (signer *AccessKeySigner) Sign(stringToSign, secretSuffix string) string { + secret := signer.credential.AccessKeySecret + secretSuffix + return ShaHmac1(stringToSign, secret) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_bearer_token.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_bearer_token.go new file mode 100644 index 0000000000..75b78433ad --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_bearer_token.go @@ -0,0 +1,35 @@ +package signers + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" +) + +type BearerTokenSigner struct { + credential *credentials.BearerTokenCredential +} + +func NewBearerTokenSigner(credential *credentials.BearerTokenCredential) *BearerTokenSigner { + return &BearerTokenSigner{ + credential: credential, + } +} + +func (signer *BearerTokenSigner) GetExtraParam() map[string]string { + return map[string]string{"BearerToken": signer.credential.BearerToken} +} + +func (*BearerTokenSigner) GetName() string { + return "" +} +func (*BearerTokenSigner) GetType() string { + return "BEARERTOKEN" +} +func (*BearerTokenSigner) GetVersion() string { + return "1.0" +} +func (signer *BearerTokenSigner) GetAccessKeyId() (accessKeyId string, err error) { + return "", nil +} +func (signer *BearerTokenSigner) Sign(stringToSign, secretSuffix string) string { + return "" +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ecs_ram_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ecs_ram_role.go new file mode 100644 index 0000000000..73788429e9 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ecs_ram_role.go @@ -0,0 +1,167 @@ +/* + * 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 signers + +import ( + "encoding/json" + "fmt" + "net/http" + "strings" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" + jmespath "github.com/jmespath/go-jmespath" +) + +var securityCredURL = "http://100.100.100.200/latest/meta-data/ram/security-credentials/" + +type EcsRamRoleSigner struct { + *credentialUpdater + sessionCredential *SessionCredential + credential *credentials.EcsRamRoleCredential + commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error) +} + +func NewEcsRamRoleSigner(credential *credentials.EcsRamRoleCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *EcsRamRoleSigner) { + signer = &EcsRamRoleSigner{ + credential: credential, + commonApi: commonApi, + } + + signer.credentialUpdater = &credentialUpdater{ + credentialExpiration: defaultDurationSeconds / 60, + buildRequestMethod: signer.buildCommonRequest, + responseCallBack: signer.refreshCredential, + refreshApi: signer.refreshApi, + } + + return signer +} + +func (*EcsRamRoleSigner) GetName() string { + return "HMAC-SHA1" +} + +func (*EcsRamRoleSigner) GetType() string { + return "" +} + +func (*EcsRamRoleSigner) GetVersion() string { + return "1.0" +} + +func (signer *EcsRamRoleSigner) GetAccessKeyId() (accessKeyId string, err error) { + if signer.sessionCredential == nil || signer.needUpdateCredential() { + err = signer.updateCredential() + if err != nil { + return + } + } + if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 { + return "", nil + } + return signer.sessionCredential.AccessKeyId, nil +} + +func (signer *EcsRamRoleSigner) GetExtraParam() map[string]string { + if signer.sessionCredential == nil { + return make(map[string]string) + } + if len(signer.sessionCredential.StsToken) <= 0 { + return make(map[string]string) + } + return map[string]string{"SecurityToken": signer.sessionCredential.StsToken} +} + +func (signer *EcsRamRoleSigner) Sign(stringToSign, secretSuffix string) string { + secret := signer.sessionCredential.AccessKeySecret + secretSuffix + return ShaHmac1(stringToSign, secret) +} + +func (signer *EcsRamRoleSigner) buildCommonRequest() (request *requests.CommonRequest, err error) { + return +} + +func (signer *EcsRamRoleSigner) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) { + requestUrl := securityCredURL + signer.credential.RoleName + httpRequest, err := http.NewRequest(requests.GET, requestUrl, strings.NewReader("")) + if err != nil { + err = fmt.Errorf("refresh Ecs sts token err: %s", err.Error()) + return + } + httpClient := &http.Client{} + httpResponse, err := httpClient.Do(httpRequest) + if err != nil { + err = fmt.Errorf("refresh Ecs sts token err: %s", err.Error()) + return + } + + response = responses.NewCommonResponse() + err = responses.Unmarshal(response, httpResponse, "") + return +} + +func (signer *EcsRamRoleSigner) refreshCredential(response *responses.CommonResponse) (err error) { + if response.GetHttpStatus() != http.StatusOK { + return fmt.Errorf("refresh Ecs sts token err, httpStatus: %d, message = %s", response.GetHttpStatus(), response.GetHttpContentString()) + } + var data interface{} + err = json.Unmarshal(response.GetHttpContentBytes(), &data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, json.Unmarshal fail: %s", err.Error()) + } + code, err := jmespath.Search("Code", data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, fail to get Code: %s", err.Error()) + } + if code.(string) != "Success" { + return fmt.Errorf("refresh Ecs sts token err, Code is not Success") + } + accessKeyId, err := jmespath.Search("AccessKeyId", data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, fail to get AccessKeyId: %s", err.Error()) + } + accessKeySecret, err := jmespath.Search("AccessKeySecret", data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, fail to get AccessKeySecret: %s", err.Error()) + } + securityToken, err := jmespath.Search("SecurityToken", data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, fail to get SecurityToken: %s", err.Error()) + } + expiration, err := jmespath.Search("Expiration", data) + if err != nil { + return fmt.Errorf("refresh Ecs sts token err, fail to get Expiration: %s", err.Error()) + } + if accessKeyId == nil || accessKeySecret == nil || securityToken == nil || expiration == nil { + return + } + + expirationTime, err := time.Parse("2006-01-02T15:04:05Z", expiration.(string)) + signer.credentialExpiration = int(expirationTime.Unix() - time.Now().Unix()) + signer.sessionCredential = &SessionCredential{ + AccessKeyId: accessKeyId.(string), + AccessKeySecret: accessKeySecret.(string), + StsToken: securityToken.(string), + } + + return +} + +func (signer *EcsRamRoleSigner) GetSessionCredential() *SessionCredential { + return signer.sessionCredential +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_key_pair.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_key_pair.go new file mode 100644 index 0000000000..19273d5a69 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_key_pair.go @@ -0,0 +1,148 @@ +/* + * 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 signers + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" + jmespath "github.com/jmespath/go-jmespath" +) + +type SignerKeyPair struct { + *credentialUpdater + sessionCredential *SessionCredential + credential *credentials.RsaKeyPairCredential + commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error) +} + +func NewSignerKeyPair(credential *credentials.RsaKeyPairCredential, commonApi func(*requests.CommonRequest, interface{}) (response *responses.CommonResponse, err error)) (signer *SignerKeyPair, err error) { + signer = &SignerKeyPair{ + credential: credential, + commonApi: commonApi, + } + + signer.credentialUpdater = &credentialUpdater{ + credentialExpiration: credential.SessionExpiration, + buildRequestMethod: signer.buildCommonRequest, + responseCallBack: signer.refreshCredential, + refreshApi: signer.refreshApi, + } + + if credential.SessionExpiration > 0 { + if credential.SessionExpiration >= 900 && credential.SessionExpiration <= 3600 { + signer.credentialExpiration = credential.SessionExpiration + } else { + err = errors.NewClientError(errors.InvalidParamErrorCode, "Key Pair session duration should be in the range of 15min - 1Hr", nil) + } + } else { + signer.credentialExpiration = defaultDurationSeconds + } + return +} + +func (*SignerKeyPair) GetName() string { + return "HMAC-SHA1" +} + +func (*SignerKeyPair) GetType() string { + return "" +} + +func (*SignerKeyPair) GetVersion() string { + return "1.0" +} + +func (signer *SignerKeyPair) ensureCredential() error { + if signer.sessionCredential == nil || signer.needUpdateCredential() { + return signer.updateCredential() + } + return nil +} + +func (signer *SignerKeyPair) GetAccessKeyId() (accessKeyId string, err error) { + err = signer.ensureCredential() + if err != nil { + return + } + if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 { + accessKeyId = "" + return + } + + accessKeyId = signer.sessionCredential.AccessKeyId + return +} + +func (signer *SignerKeyPair) GetExtraParam() map[string]string { + return make(map[string]string) +} + +func (signer *SignerKeyPair) Sign(stringToSign, secretSuffix string) string { + secret := signer.sessionCredential.AccessKeySecret + secretSuffix + return ShaHmac1(stringToSign, secret) +} + +func (signer *SignerKeyPair) buildCommonRequest() (request *requests.CommonRequest, err error) { + request = requests.NewCommonRequest() + request.Product = "Sts" + request.Version = "2015-04-01" + request.ApiName = "GenerateSessionAccessKey" + request.Scheme = requests.HTTPS + request.SetDomain("sts.ap-northeast-1.aliyuncs.com") + request.QueryParams["PublicKeyId"] = signer.credential.PublicKeyId + request.QueryParams["DurationSeconds"] = strconv.Itoa(signer.credentialExpiration) + return +} + +func (signer *SignerKeyPair) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) { + signerV2 := NewSignerV2(signer.credential) + return signer.commonApi(request, signerV2) +} + +func (signer *SignerKeyPair) refreshCredential(response *responses.CommonResponse) (err error) { + if response.GetHttpStatus() != http.StatusOK { + message := "refresh session AccessKey failed" + err = errors.NewServerError(response.GetHttpStatus(), response.GetHttpContentString(), message) + return + } + var data interface{} + err = json.Unmarshal(response.GetHttpContentBytes(), &data) + if err != nil { + return fmt.Errorf("refresh KeyPair err, json.Unmarshal fail: %s", err.Error()) + } + accessKeyId, err := jmespath.Search("SessionAccessKey.SessionAccessKeyId", data) + if err != nil { + return fmt.Errorf("refresh KeyPair err, fail to get SessionAccessKeyId: %s", err.Error()) + } + accessKeySecret, err := jmespath.Search("SessionAccessKey.SessionAccessKeySecret", data) + if err != nil { + return fmt.Errorf("refresh KeyPair err, fail to get SessionAccessKeySecret: %s", err.Error()) + } + if accessKeyId == nil || accessKeySecret == nil { + return + } + signer.sessionCredential = &SessionCredential{ + AccessKeyId: accessKeyId.(string), + AccessKeySecret: accessKeySecret.(string), + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ram_role_arn.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ram_role_arn.go new file mode 100644 index 0000000000..a01001bc12 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_ram_role_arn.go @@ -0,0 +1,180 @@ +/* + * 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 signers + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" + jmespath "github.com/jmespath/go-jmespath" +) + +const ( + defaultDurationSeconds = 3600 +) + +type RamRoleArnSigner struct { + *credentialUpdater + roleSessionName string + sessionCredential *SessionCredential + credential *credentials.RamRoleArnCredential + commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error) +} + +func NewRamRoleArnSigner(credential *credentials.RamRoleArnCredential, commonApi func(request *requests.CommonRequest, signer interface{}) (response *responses.CommonResponse, err error)) (signer *RamRoleArnSigner, err error) { + signer = &RamRoleArnSigner{ + credential: credential, + commonApi: commonApi, + } + + signer.credentialUpdater = &credentialUpdater{ + credentialExpiration: credential.RoleSessionExpiration, + buildRequestMethod: signer.buildCommonRequest, + responseCallBack: signer.refreshCredential, + refreshApi: signer.refreshApi, + } + + if len(credential.RoleSessionName) > 0 { + signer.roleSessionName = credential.RoleSessionName + } else { + signer.roleSessionName = "aliyun-go-sdk-" + strconv.FormatInt(time.Now().UnixNano()/1000, 10) + } + if credential.RoleSessionExpiration > 0 { + if credential.RoleSessionExpiration >= 900 && credential.RoleSessionExpiration <= 3600 { + signer.credentialExpiration = credential.RoleSessionExpiration + } else { + err = errors.NewClientError(errors.InvalidParamErrorCode, "Assume Role session duration should be in the range of 15min - 1Hr", nil) + } + } else { + signer.credentialExpiration = defaultDurationSeconds + } + return +} + +func (*RamRoleArnSigner) GetName() string { + return "HMAC-SHA1" +} + +func (*RamRoleArnSigner) GetType() string { + return "" +} + +func (*RamRoleArnSigner) GetVersion() string { + return "1.0" +} + +func (signer *RamRoleArnSigner) GetAccessKeyId() (accessKeyId string, err error) { + if signer.sessionCredential == nil || signer.needUpdateCredential() { + err = signer.updateCredential() + if err != nil { + return + } + } + + if signer.sessionCredential == nil || len(signer.sessionCredential.AccessKeyId) <= 0 { + return "", err + } + + return signer.sessionCredential.AccessKeyId, nil +} + +func (signer *RamRoleArnSigner) GetExtraParam() map[string]string { + if signer.sessionCredential == nil || signer.needUpdateCredential() { + signer.updateCredential() + } + if signer.sessionCredential == nil || len(signer.sessionCredential.StsToken) <= 0 { + return make(map[string]string) + } + return map[string]string{"SecurityToken": signer.sessionCredential.StsToken} +} + +func (signer *RamRoleArnSigner) Sign(stringToSign, secretSuffix string) string { + secret := signer.sessionCredential.AccessKeySecret + secretSuffix + return ShaHmac1(stringToSign, secret) +} + +func (signer *RamRoleArnSigner) buildCommonRequest() (request *requests.CommonRequest, err error) { + request = requests.NewCommonRequest() + if signer.credential.StsRegion != "" { + request.Domain = fmt.Sprintf("sts.%s.aliyuncs.com", signer.credential.StsRegion) + } else { + request.Domain = "sts.aliyuncs.com" + } + request.Product = "Sts" + request.Version = "2015-04-01" + request.ApiName = "AssumeRole" + request.Scheme = requests.HTTPS + request.QueryParams["RoleArn"] = signer.credential.RoleArn + if signer.credential.Policy != "" { + request.QueryParams["Policy"] = signer.credential.Policy + } + request.QueryParams["RoleSessionName"] = signer.credential.RoleSessionName + request.QueryParams["DurationSeconds"] = strconv.Itoa(signer.credentialExpiration) + return +} + +func (signer *RamRoleArnSigner) refreshApi(request *requests.CommonRequest) (response *responses.CommonResponse, err error) { + credential := &credentials.AccessKeyCredential{ + AccessKeyId: signer.credential.AccessKeyId, + AccessKeySecret: signer.credential.AccessKeySecret, + } + signerV1 := NewAccessKeySigner(credential) + return signer.commonApi(request, signerV1) +} + +func (signer *RamRoleArnSigner) refreshCredential(response *responses.CommonResponse) (err error) { + if response.GetHttpStatus() != http.StatusOK { + message := "refresh session token failed" + err = errors.NewServerError(response.GetHttpStatus(), response.GetHttpContentString(), message) + return + } + var data interface{} + err = json.Unmarshal(response.GetHttpContentBytes(), &data) + if err != nil { + return fmt.Errorf("refresh RoleArn sts token err, json.Unmarshal fail: %s", err.Error()) + } + accessKeyId, err := jmespath.Search("Credentials.AccessKeyId", data) + if err != nil { + return fmt.Errorf("refresh RoleArn sts token err, fail to get AccessKeyId: %s", err.Error()) + } + accessKeySecret, err := jmespath.Search("Credentials.AccessKeySecret", data) + if err != nil { + return fmt.Errorf("refresh RoleArn sts token err, fail to get AccessKeySecret: %s", err.Error()) + } + securityToken, err := jmespath.Search("Credentials.SecurityToken", data) + if err != nil { + return fmt.Errorf("refresh RoleArn sts token err, fail to get SecurityToken: %s", err.Error()) + } + if accessKeyId == nil || accessKeySecret == nil || securityToken == nil { + return + } + signer.sessionCredential = &SessionCredential{ + AccessKeyId: accessKeyId.(string), + AccessKeySecret: accessKeySecret.(string), + StsToken: securityToken.(string), + } + return +} + +func (signer *RamRoleArnSigner) GetSessionCredential() *SessionCredential { + return signer.sessionCredential +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_sts_token.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_sts_token.go new file mode 100644 index 0000000000..d0ce36c38d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_sts_token.go @@ -0,0 +1,54 @@ +/* + * 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 signers + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" +) + +type StsTokenSigner struct { + credential *credentials.StsTokenCredential +} + +func NewStsTokenSigner(credential *credentials.StsTokenCredential) *StsTokenSigner { + return &StsTokenSigner{ + credential: credential, + } +} + +func (*StsTokenSigner) GetName() string { + return "HMAC-SHA1" +} + +func (*StsTokenSigner) GetType() string { + return "" +} + +func (*StsTokenSigner) GetVersion() string { + return "1.0" +} + +func (signer *StsTokenSigner) GetAccessKeyId() (accessKeyId string, err error) { + return signer.credential.AccessKeyId, nil +} + +func (signer *StsTokenSigner) GetExtraParam() map[string]string { + return map[string]string{"SecurityToken": signer.credential.AccessKeyStsToken} +} + +func (signer *StsTokenSigner) Sign(stringToSign, secretSuffix string) string { + secret := signer.credential.AccessKeySecret + secretSuffix + return ShaHmac1(stringToSign, secret) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_v2.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_v2.go new file mode 100644 index 0000000000..9734852982 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers/signer_v2.go @@ -0,0 +1,54 @@ +/* + * 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 signers + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" +) + +type SignerV2 struct { + credential *credentials.RsaKeyPairCredential +} + +func (signer *SignerV2) GetExtraParam() map[string]string { + return nil +} + +func NewSignerV2(credential *credentials.RsaKeyPairCredential) *SignerV2 { + return &SignerV2{ + credential: credential, + } +} + +func (*SignerV2) GetName() string { + return "SHA256withRSA" +} + +func (*SignerV2) GetType() string { + return "PRIVATEKEY" +} + +func (*SignerV2) GetVersion() string { + return "1.0" +} + +func (signer *SignerV2) GetAccessKeyId() (accessKeyId string, err error) { + return signer.credential.PublicKeyId, err +} + +func (signer *SignerV2) Sign(stringToSign, secretSuffix string) string { + secret := signer.credential.PrivateKey + return Sha256WithRsa(stringToSign, secret) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/client.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/client.go new file mode 100644 index 0000000000..56376b5840 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/client.go @@ -0,0 +1,852 @@ +/* + * 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 sdk + +import ( + "context" + "crypto/tls" + "fmt" + "net" + "net/http" + "net/url" + "os" + "reflect" + "regexp" + "runtime" + "strconv" + "strings" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +var debug utils.Debug + +func init() { + debug = utils.Init("sdk") +} + +// Version this value will be replaced while build: -ldflags="-X sdk.version=x.x.x" +var Version = "0.0.1" +var defaultConnectTimeout = 5 * time.Second +var defaultReadTimeout = 10 * time.Second + +var DefaultUserAgent = fmt.Sprintf("AlibabaCloud (%s; %s) Golang/%s Core/%s", runtime.GOOS, runtime.GOARCH, strings.Trim(runtime.Version(), "go"), Version) + +var hookDo = func(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) { + return fn +} + +// Client the type Client +type Client struct { + SourceIp string + SecureTransport string + isInsecure bool + regionId string + config *Config + httpProxy string + httpsProxy string + noProxy string + logger *Logger + userAgent map[string]string + signer auth.Signer + httpClient *http.Client + asyncTaskQueue chan func() + readTimeout time.Duration + connectTimeout time.Duration + EndpointMap map[string]string + EndpointType string + Network string + Domain string + isOpenAsync bool +} + +func (client *Client) Init() (err error) { + panic("not support yet") +} + +func (client *Client) SetEndpointRules(endpointMap map[string]string, endpointType string, netWork string) { + client.EndpointMap = endpointMap + client.Network = netWork + client.EndpointType = endpointType +} + +func (client *Client) SetHTTPSInsecure(isInsecure bool) { + client.isInsecure = isInsecure +} + +func (client *Client) GetHTTPSInsecure() bool { + return client.isInsecure +} + +func (client *Client) SetHttpsProxy(httpsProxy string) { + client.httpsProxy = httpsProxy +} + +func (client *Client) GetHttpsProxy() string { + return client.httpsProxy +} + +func (client *Client) SetHttpProxy(httpProxy string) { + client.httpProxy = httpProxy +} + +func (client *Client) GetHttpProxy() string { + return client.httpProxy +} + +func (client *Client) SetNoProxy(noProxy string) { + client.noProxy = noProxy +} + +func (client *Client) GetNoProxy() string { + return client.noProxy +} + +func (client *Client) SetTransport(transport http.RoundTripper) { + if client.httpClient == nil { + client.httpClient = &http.Client{} + } + client.httpClient.Transport = transport +} + +// InitWithProviderChain will get credential from the providerChain, +// the RsaKeyPairCredential Only applicable to regionID `ap-northeast-1`, +// if your providerChain may return a credential type with RsaKeyPairCredential, +// please ensure your regionID is `ap-northeast-1`. +func (client *Client) InitWithProviderChain(regionId string, provider provider.Provider) (err error) { + config := client.InitClientConfig() + credential, err := provider.Resolve() + if err != nil { + return + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithOptions(regionId string, config *Config, credential auth.Credential) (err error) { + if regionId != "" { + match, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", regionId) + if !match { + return fmt.Errorf("regionId contains invalid characters") + } + } + + client.regionId = regionId + client.config = config + client.httpClient = &http.Client{} + + if config.Transport != nil { + client.httpClient.Transport = config.Transport + } else if config.HttpTransport != nil { + client.httpClient.Transport = config.HttpTransport + } + + if config.Timeout > 0 { + client.httpClient.Timeout = config.Timeout + } + + if config.EnableAsync { + client.EnableAsync(config.GoRoutinePoolSize, config.MaxTaskQueueSize) + } + + client.signer, err = auth.NewSignerWithCredential(credential, client.ProcessCommonRequestWithSigner) + + return +} + +func (client *Client) SetReadTimeout(readTimeout time.Duration) { + client.readTimeout = readTimeout +} + +func (client *Client) SetConnectTimeout(connectTimeout time.Duration) { + client.connectTimeout = connectTimeout +} + +func (client *Client) GetReadTimeout() time.Duration { + return client.readTimeout +} + +func (client *Client) GetConnectTimeout() time.Duration { + return client.connectTimeout +} + +func (client *Client) getHttpProxy(scheme string) (proxy *url.URL, err error) { + if scheme == "https" { + if client.GetHttpsProxy() != "" { + proxy, err = url.Parse(client.httpsProxy) + } else if rawurl := os.Getenv("HTTPS_PROXY"); rawurl != "" { + proxy, err = url.Parse(rawurl) + } else if rawurl := os.Getenv("https_proxy"); rawurl != "" { + proxy, err = url.Parse(rawurl) + } + } else { + if client.GetHttpProxy() != "" { + proxy, err = url.Parse(client.httpProxy) + } else if rawurl := os.Getenv("HTTP_PROXY"); rawurl != "" { + proxy, err = url.Parse(rawurl) + } else if rawurl := os.Getenv("http_proxy"); rawurl != "" { + proxy, err = url.Parse(rawurl) + } + } + + return proxy, err +} + +func (client *Client) getNoProxy(scheme string) []string { + var urls []string + if client.GetNoProxy() != "" { + urls = strings.Split(client.noProxy, ",") + } else if rawurl := os.Getenv("NO_PROXY"); rawurl != "" { + urls = strings.Split(rawurl, ",") + } else if rawurl := os.Getenv("no_proxy"); rawurl != "" { + urls = strings.Split(rawurl, ",") + } + + return urls +} + +// EnableAsync enable the async task queue +func (client *Client) EnableAsync(routinePoolSize, maxTaskQueueSize int) { + if client.isOpenAsync { + fmt.Println("warning: Please not call EnableAsync repeatedly") + return + } + client.isOpenAsync = true + client.asyncTaskQueue = make(chan func(), maxTaskQueueSize) + for i := 0; i < routinePoolSize; i++ { + go func() { + for { + task, notClosed := <-client.asyncTaskQueue + if !notClosed { + return + } else { + task() + } + } + }() + } +} + +func (client *Client) InitWithAccessKey(regionId, accessKeyId, accessKeySecret string) (err error) { + config := client.InitClientConfig() + credential := &credentials.AccessKeyCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithStsToken(regionId, accessKeyId, accessKeySecret, securityToken string) (err error) { + config := client.InitClientConfig() + credential := &credentials.StsTokenCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + AccessKeyStsToken: securityToken, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (err error) { + config := client.InitClientConfig() + credential := &credentials.RamRoleArnCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + RoleArn: roleArn, + RoleSessionName: roleSessionName, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (err error) { + config := client.InitClientConfig() + credential := &credentials.RamRoleArnCredential{ + AccessKeyId: accessKeyId, + AccessKeySecret: accessKeySecret, + RoleArn: roleArn, + RoleSessionName: roleSessionName, + Policy: policy, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithRsaKeyPair(regionId, publicKeyId, privateKey string, sessionExpiration int) (err error) { + config := client.InitClientConfig() + credential := &credentials.RsaKeyPairCredential{ + PrivateKey: privateKey, + PublicKeyId: publicKeyId, + SessionExpiration: sessionExpiration, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithEcsRamRole(regionId, roleName string) (err error) { + config := client.InitClientConfig() + credential := &credentials.EcsRamRoleCredential{ + RoleName: roleName, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitWithBearerToken(regionId, bearerToken string) (err error) { + config := client.InitClientConfig() + credential := &credentials.BearerTokenCredential{ + BearerToken: bearerToken, + } + return client.InitWithOptions(regionId, config, credential) +} + +func (client *Client) InitClientConfig() (config *Config) { + if client.config != nil { + return client.config + } else { + return NewConfig() + } +} + +func (client *Client) DoAction(request requests.AcsRequest, response responses.AcsResponse) (err error) { + if (client.SecureTransport == "false" || client.SecureTransport == "true") && client.SourceIp != "" { + t := reflect.TypeOf(request).Elem() + v := reflect.ValueOf(request).Elem() + for i := 0; i < t.NumField(); i++ { + value := v.FieldByName(t.Field(i).Name) + if t.Field(i).Name == "requests.RoaRequest" { + request.GetHeaders()["x-acs-proxy-source-ip"] = client.SourceIp + request.GetHeaders()["x-acs-proxy-secure-transport"] = client.SecureTransport + return client.DoActionWithSigner(request, response, nil) + } else if t.Field(i).Name == "PathPattern" && !value.IsZero() { + request.GetHeaders()["x-acs-proxy-source-ip"] = client.SourceIp + request.GetHeaders()["x-acs-proxy-secure-transport"] = client.SecureTransport + return client.DoActionWithSigner(request, response, nil) + } else if i == t.NumField()-1 { + request.GetQueryParams()["SourceIp"] = client.SourceIp + request.GetQueryParams()["SecureTransport"] = client.SecureTransport + return client.DoActionWithSigner(request, response, nil) + } + } + } + return client.DoActionWithSigner(request, response, nil) +} +func (client *Client) GetEndpointRules(regionId string, product string) (endpointRaw string, err error) { + if client.EndpointType == "regional" { + if regionId == "" { + err = fmt.Errorf("RegionId is empty, please set a valid RegionId.") + return "", err + } + endpointRaw = strings.Replace("..aliyuncs.com", "", regionId, 1) + } else { + endpointRaw = ".aliyuncs.com" + } + endpointRaw = strings.Replace(endpointRaw, "", strings.ToLower(product), 1) + if client.Network == "" || client.Network == "public" { + endpointRaw = strings.Replace(endpointRaw, "", "", 1) + } else { + endpointRaw = strings.Replace(endpointRaw, "", "-"+client.Network, 1) + } + return endpointRaw, nil +} + +func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (httpRequest *http.Request, err error) { + // add clientVersion + request.GetHeaders()["x-sdk-core-version"] = Version + + regionId := client.regionId + if len(request.GetRegionId()) > 0 { + regionId = request.GetRegionId() + } + + // resolve endpoint + endpoint := request.GetDomain() + + if endpoint == "" && client.Domain != "" { + endpoint = client.Domain + } + + if endpoint == "" { + endpoint = endpoints.GetEndpointFromMap(regionId, request.GetProduct()) + } + + if endpoint == "" && client.EndpointType != "" && + (request.GetProduct() != "Sts" || len(request.GetQueryParams()) == 0) { + if client.EndpointMap != nil && client.Network == "" || client.Network == "public" { + endpoint = client.EndpointMap[regionId] + } + + if endpoint == "" { + endpoint, err = client.GetEndpointRules(regionId, request.GetProduct()) + if err != nil { + return + } + } + } + + if endpoint == "" { + resolveParam := &endpoints.ResolveParam{ + Domain: request.GetDomain(), + Product: request.GetProduct(), + RegionId: regionId, + LocationProduct: request.GetLocationServiceCode(), + LocationEndpointType: request.GetLocationEndpointType(), + CommonApi: client.ProcessCommonRequest, + } + endpoint, err = endpoints.Resolve(resolveParam) + if err != nil { + return + } + } + + request.SetDomain(endpoint) + if request.GetScheme() == "" { + request.SetScheme(client.config.Scheme) + } + // init request params + err = requests.InitParams(request) + if err != nil { + return + } + + // signature + var finalSigner auth.Signer + if signer != nil { + finalSigner = signer + } else { + finalSigner = client.signer + } + httpRequest, err = buildHttpRequest(request, finalSigner, regionId) + if err == nil { + userAgent := DefaultUserAgent + getSendUserAgent(client.config.UserAgent, client.userAgent, request.GetUserAgent()) + httpRequest.Header.Set("User-Agent", userAgent) + } + + return +} + +func getSendUserAgent(configUserAgent string, clientUserAgent, requestUserAgent map[string]string) string { + realUserAgent := "" + for key1, value1 := range clientUserAgent { + for key2 := range requestUserAgent { + if key1 == key2 { + key1 = "" + } + } + if key1 != "" { + realUserAgent += fmt.Sprintf(" %s/%s", key1, value1) + + } + } + for key, value := range requestUserAgent { + realUserAgent += fmt.Sprintf(" %s/%s", key, value) + } + if configUserAgent != "" { + return realUserAgent + fmt.Sprintf(" Extra/%s", configUserAgent) + } + return realUserAgent +} + +func (client *Client) AppendUserAgent(key, value string) { + newkey := true + + if client.userAgent == nil { + client.userAgent = make(map[string]string) + } + if strings.ToLower(key) != "core" && strings.ToLower(key) != "go" { + for tag := range client.userAgent { + if tag == key { + client.userAgent[tag] = value + newkey = false + } + } + if newkey { + client.userAgent[key] = value + } + } +} + +func (client *Client) BuildRequestWithSigner(request requests.AcsRequest, signer auth.Signer) (err error) { + _, err = client.buildRequestWithSigner(request, signer) + return +} + +func (client *Client) getTimeout(request requests.AcsRequest) (time.Duration, time.Duration) { + readTimeout := defaultReadTimeout + connectTimeout := defaultConnectTimeout + + reqReadTimeout := request.GetReadTimeout() + reqConnectTimeout := request.GetConnectTimeout() + if reqReadTimeout != 0*time.Millisecond { + readTimeout = reqReadTimeout + } else if client.readTimeout != 0*time.Millisecond { + readTimeout = client.readTimeout + } else if client.httpClient.Timeout != 0 { + readTimeout = client.httpClient.Timeout + } else if timeout, ok := getAPIMaxTimeout(request.GetProduct(), request.GetActionName()); ok { + readTimeout = timeout + } + + if reqConnectTimeout != 0*time.Millisecond { + connectTimeout = reqConnectTimeout + } else if client.connectTimeout != 0*time.Millisecond { + connectTimeout = client.connectTimeout + } + return readTimeout, connectTimeout +} + +func Timeout(connectTimeout time.Duration) func(cxt context.Context, net, addr string) (c net.Conn, err error) { + return func(ctx context.Context, network, address string) (net.Conn, error) { + return (&net.Dialer{ + Timeout: connectTimeout, + DualStack: true, + }).DialContext(ctx, network, address) + } +} + +func (client *Client) setTimeout(request requests.AcsRequest) { + readTimeout, connectTimeout := client.getTimeout(request) + client.httpClient.Timeout = readTimeout + if trans, ok := client.httpClient.Transport.(*http.Transport); ok && trans != nil { + trans.DialContext = Timeout(connectTimeout) + client.httpClient.Transport = trans + } else if client.httpClient.Transport == nil { + client.httpClient.Transport = &http.Transport{ + DialContext: Timeout(connectTimeout), + } + } +} + +func (client *Client) getHTTPSInsecure(request requests.AcsRequest) (insecure bool) { + if request.GetHTTPSInsecure() != nil { + insecure = *request.GetHTTPSInsecure() + } else { + insecure = client.GetHTTPSInsecure() + } + return insecure +} + +func (client *Client) DoActionWithSigner(request requests.AcsRequest, response responses.AcsResponse, signer auth.Signer) (err error) { + if client.Network != "" { + match, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", client.Network) + if !match { + return fmt.Errorf("netWork contains invalid characters") + } + } + fieldMap := make(map[string]string) + initLogMsg(fieldMap) + defer func() { + client.printLog(fieldMap, err) + }() + httpRequest, err := client.buildRequestWithSigner(request, signer) + if err != nil { + return + } + + client.setTimeout(request) + proxy, err := client.getHttpProxy(httpRequest.URL.Scheme) + if err != nil { + return err + } + + noProxy := client.getNoProxy(httpRequest.URL.Scheme) + + var flag bool + for _, value := range noProxy { + if strings.HasPrefix(value, "*") { + value = fmt.Sprintf(".%s", value) + } + noProxyReg, err := regexp.Compile(value) + if err != nil { + return err + } + if noProxyReg.MatchString(httpRequest.Host) { + flag = true + break + } + } + + // Set whether to ignore certificate validation. + // Default InsecureSkipVerify is false. + if trans, ok := client.httpClient.Transport.(*http.Transport); ok && trans != nil { + if trans.TLSClientConfig != nil { + trans.TLSClientConfig.InsecureSkipVerify = client.getHTTPSInsecure(request) + } else { + trans.TLSClientConfig = &tls.Config{ + InsecureSkipVerify: client.getHTTPSInsecure(request), + } + } + if proxy != nil && !flag { + trans.Proxy = http.ProxyURL(proxy) + } + client.httpClient.Transport = trans + } + + var httpResponse *http.Response + for retryTimes := 0; retryTimes <= client.config.MaxRetryTime; retryTimes++ { + if proxy != nil && proxy.User != nil { + if password, passwordSet := proxy.User.Password(); passwordSet { + httpRequest.SetBasicAuth(proxy.User.Username(), password) + } + } + if retryTimes > 0 { + client.printLog(fieldMap, err) + initLogMsg(fieldMap) + } + putMsgToMap(fieldMap, httpRequest) + debug("> %s %s %s", httpRequest.Method, httpRequest.URL.RequestURI(), httpRequest.Proto) + debug("> Host: %s", httpRequest.Host) + for key, value := range httpRequest.Header { + debug("> %s: %v", key, strings.Join(value, "")) + } + debug(">") + debug(" Retry Times: %d.", retryTimes) + + startTime := time.Now() + fieldMap["{start_time}"] = startTime.Format("2006-01-02 15:04:05") + httpResponse, err = hookDo(client.httpClient.Do)(httpRequest) + fieldMap["{cost}"] = time.Since(startTime).String() + if err == nil { + fieldMap["{code}"] = strconv.Itoa(httpResponse.StatusCode) + fieldMap["{res_headers}"] = TransToString(httpResponse.Header) + debug("< %s %s", httpResponse.Proto, httpResponse.Status) + for key, value := range httpResponse.Header { + debug("< %s: %v", key, strings.Join(value, "")) + } + } + debug("<") + // receive error + if err != nil { + debug(" Error: %s.", err.Error()) + if !client.config.AutoRetry { + return + } else if retryTimes >= client.config.MaxRetryTime { + // timeout but reached the max retry times, return + times := strconv.Itoa(retryTimes + 1) + timeoutErrorMsg := fmt.Sprintf(errors.TimeoutErrorMessage, times, times) + if strings.Contains(err.Error(), "Client.Timeout") { + timeoutErrorMsg += " Read timeout. Please set a valid ReadTimeout." + } else { + timeoutErrorMsg += " Connect timeout. Please set a valid ConnectTimeout." + } + err = errors.NewClientError(errors.TimeoutErrorCode, timeoutErrorMsg, err) + return + } + } + if isCertificateError(err) { + return + } + + // if status code >= 500 or timeout, will trigger retry + if client.config.AutoRetry && (err != nil || isServerError(httpResponse)) { + client.setTimeout(request) + // rewrite signatureNonce and signature + httpRequest, err = client.buildRequestWithSigner(request, signer) + // buildHttpRequest(request, finalSigner, regionId) + if err != nil { + return + } + continue + } + break + } + + err = responses.Unmarshal(response, httpResponse, request.GetAcceptFormat()) + fieldMap["{res_body}"] = response.GetHttpContentString() + debug("%s", response.GetHttpContentString()) + // wrap server errors + if serverErr, ok := err.(*errors.ServerError); ok { + var wrapInfo = map[string]string{} + wrapInfo["StringToSign"] = request.GetStringToSign() + err = errors.WrapServerError(serverErr, wrapInfo) + } + return +} + +func isCertificateError(err error) bool { + if err != nil && strings.Contains(err.Error(), "x509: certificate signed by unknown authority") { + return true + } + return false +} + +func putMsgToMap(fieldMap map[string]string, request *http.Request) { + fieldMap["{host}"] = request.Host + fieldMap["{method}"] = request.Method + fieldMap["{uri}"] = request.URL.RequestURI() + fieldMap["{pid}"] = strconv.Itoa(os.Getpid()) + fieldMap["{version}"] = strings.Split(request.Proto, "/")[1] + hostname, _ := os.Hostname() + fieldMap["{hostname}"] = hostname + fieldMap["{req_headers}"] = TransToString(request.Header) + fieldMap["{target}"] = request.URL.Path + request.URL.RawQuery +} + +func buildHttpRequest(request requests.AcsRequest, singer auth.Signer, regionId string) (httpRequest *http.Request, err error) { + err = auth.Sign(request, singer, regionId) + if err != nil { + return + } + requestMethod := request.GetMethod() + requestUrl := request.BuildUrl() + body := request.GetBodyReader() + httpRequest, err = http.NewRequest(requestMethod, requestUrl, body) + if err != nil { + return + } + for key, value := range request.GetHeaders() { + httpRequest.Header[key] = []string{value} + } + // host is a special case + if host, containsHost := request.GetHeaders()["Host"]; containsHost { + httpRequest.Host = host + } + return +} + +func isServerError(httpResponse *http.Response) bool { + return httpResponse.StatusCode >= http.StatusInternalServerError +} + +/** +only block when any one of the following occurs: +1. the asyncTaskQueue is full, increase the queue size to avoid this +2. Shutdown() in progressing, the client is being closed +**/ +func (client *Client) AddAsyncTask(task func()) (err error) { + if client.asyncTaskQueue != nil { + if client.isOpenAsync { + client.asyncTaskQueue <- task + } + } else { + err = errors.NewClientError(errors.AsyncFunctionNotEnabledCode, errors.AsyncFunctionNotEnabledMessage, nil) + } + return +} + +func (client *Client) GetConfig() *Config { + return client.config +} + +func (client *Client) GetSigner() auth.Signer { + return client.signer +} + +func (client *Client) SetSigner(signer auth.Signer) { + client.signer = signer +} + +func NewClient() (client *Client, err error) { + client = &Client{} + err = client.Init() + return +} + +func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) { + client = &Client{} + var pc provider.Provider + if len(providers) == 0 { + pc = provider.DefaultChain + } else { + pc = provider.NewProviderChain(providers) + } + err = client.InitWithProviderChain(regionId, pc) + return +} + +func NewClientWithOptions(regionId string, config *Config, credential auth.Credential) (client *Client, err error) { + client = &Client{} + err = client.InitWithOptions(regionId, config, credential) + return +} + +func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) { + client = &Client{} + err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret) + return +} + +func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) { + client = &Client{} + err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken) + return +} + +func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) { + client = &Client{} + err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName) + return +} + +func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) { + client = &Client{} + err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy) + return +} + +func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) { + client = &Client{} + err = client.InitWithEcsRamRole(regionId, roleName) + return +} + +func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) { + client = &Client{} + err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration) + return +} + +func NewClientWithBearerToken(regionId, bearerToken string) (client *Client, err error) { + client = &Client{} + err = client.InitWithBearerToken(regionId, bearerToken) + return +} + +func (client *Client) ProcessCommonRequest(request *requests.CommonRequest) (response *responses.CommonResponse, err error) { + request.TransToAcsRequest() + response = responses.NewCommonResponse() + err = client.DoAction(request, response) + return +} + +func (client *Client) ProcessCommonRequestWithSigner(request *requests.CommonRequest, signerInterface interface{}) (response *responses.CommonResponse, err error) { + if signer, isSigner := signerInterface.(auth.Signer); isSigner { + request.TransToAcsRequest() + response = responses.NewCommonResponse() + err = client.DoActionWithSigner(request, response, signer) + return + } + panic("should not be here") +} + +func (client *Client) Shutdown() { + if client.asyncTaskQueue != nil { + close(client.asyncTaskQueue) + } + + client.isOpenAsync = false +} + +// Deprecated: Use NewClientWithRamRoleArn in this package instead. +func NewClientWithStsRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) { + return NewClientWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName) +} + +// Deprecated: Use NewClientWithEcsRamRole in this package instead. +func NewClientWithStsRoleNameOnEcs(regionId string, roleName string) (client *Client, err error) { + return NewClientWithEcsRamRole(regionId, roleName) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/config.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/config.go new file mode 100644 index 0000000000..29b7cc35b7 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/config.go @@ -0,0 +1,92 @@ +/* + * 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 sdk + +import ( + "net/http" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +type Config struct { + AutoRetry bool `default:"false"` + MaxRetryTime int `default:"3"` + UserAgent string `default:""` + Debug bool `default:"false"` + HttpTransport *http.Transport `default:""` + Transport http.RoundTripper `default:""` + EnableAsync bool `default:"false"` + MaxTaskQueueSize int `default:"1000"` + GoRoutinePoolSize int `default:"5"` + Scheme string `default:"HTTP"` + Timeout time.Duration +} + +func NewConfig() (config *Config) { + config = &Config{} + utils.InitStructWithDefaultTag(config) + return +} + +func (c *Config) WithAutoRetry(isAutoRetry bool) *Config { + c.AutoRetry = isAutoRetry + return c +} + +func (c *Config) WithMaxRetryTime(maxRetryTime int) *Config { + c.MaxRetryTime = maxRetryTime + return c +} + +func (c *Config) WithUserAgent(userAgent string) *Config { + c.UserAgent = userAgent + return c +} + +func (c *Config) WithDebug(isDebug bool) *Config { + c.Debug = isDebug + return c +} + +func (c *Config) WithTimeout(timeout time.Duration) *Config { + c.Timeout = timeout + return c +} + +func (c *Config) WithHttpTransport(httpTransport *http.Transport) *Config { + c.HttpTransport = httpTransport + return c +} + +func (c *Config) WithEnableAsync(isEnableAsync bool) *Config { + c.EnableAsync = isEnableAsync + return c +} + +func (c *Config) WithMaxTaskQueueSize(maxTaskQueueSize int) *Config { + c.MaxTaskQueueSize = maxTaskQueueSize + return c +} + +func (c *Config) WithGoRoutinePoolSize(goRoutinePoolSize int) *Config { + c.GoRoutinePoolSize = goRoutinePoolSize + return c +} + +func (c *Config) WithScheme(scheme string) *Config { + c.Scheme = scheme + return c +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/endpoints_config.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/endpoints_config.go new file mode 100644 index 0000000000..8ee0ec53f6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/endpoints_config.go @@ -0,0 +1,4078 @@ +package endpoints + +import ( + "encoding/json" + "fmt" + "sync" +) + +const endpointsJson = `{ + "products": [ + { + "code": "emr", + "document_id": "28140", + "location_service_code": "emr", + "regional_endpoints": [ + { + "region": "cn-qingdao", + "endpoint": "emr.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "emr.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "emr.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "emr.eu-west-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "emr.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "emr.me-east-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "emr.ap-northeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "emr.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "emr.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "emr.ap-south-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "emr.us-east-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "emr.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "emr.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "emr.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "emr.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "emr.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "emr.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "emr.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "emr.aliyuncs.com" + } + ], + "global_endpoint": "emr.aliyuncs.com", + "regional_endpoint_pattern": "emr.[RegionId].aliyuncs.com" + }, + { + "code": "petadata", + "document_id": "", + "location_service_code": "petadata", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "petadata.me-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "petadata.ap-southeast-2.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "petadata.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "petadata.ap-southeast-5.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "petadata.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "petadata.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "petadata.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "petadata.aliyuncs.com" + } + ], + "global_endpoint": "petadata.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "dbs", + "document_id": "", + "location_service_code": "dbs", + "regional_endpoints": [ + { + "region": "cn-shenzhen", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "dbs-api.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "dbs-api.ap-northeast-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "dbs-api.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "alidnsgtm", + "document_id": "", + "location_service_code": "alidnsgtm", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "alidns.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "alidns.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "elasticsearch", + "document_id": "", + "location_service_code": "elasticsearch", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "elasticsearch.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "elasticsearch.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "elasticsearch.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "elasticsearch.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "elasticsearch.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "elasticsearch.ap-southeast-3.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "elasticsearch.us-west-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "elasticsearch.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "elasticsearch.ap-southeast-5.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "elasticsearch.eu-central-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "elasticsearch.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "elasticsearch.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "elasticsearch.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "elasticsearch.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "elasticsearch.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "baas", + "document_id": "", + "location_service_code": "baas", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "baas.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "baas.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "baas.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "baas.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "baas.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "baas.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cr", + "document_id": "60716", + "location_service_code": "cr", + "regional_endpoints": null, + "global_endpoint": "cr.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudap", + "document_id": "", + "location_service_code": "cloudap", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cloudwf.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "imagesearch", + "document_id": "", + "location_service_code": "imagesearch", + "regional_endpoints": [ + { + "region": "ap-southeast-2", + "endpoint": "imagesearch.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "imagesearch.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "imagesearch.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "imagesearch.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "pts", + "document_id": "", + "location_service_code": "pts", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "pts.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ehs", + "document_id": "", + "location_service_code": "ehs", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "ehpc.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ehpc.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "ehpc.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ehpc.cn-qingdao.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "ehpc.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ehpc.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "ehpc.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ehpc.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ehpc.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ehpc.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ehpc.ap-southeast-2.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "polardb", + "document_id": "58764", + "location_service_code": "polardb", + "regional_endpoints": [ + { + "region": "ap-south-1", + "endpoint": "polardb.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "polardb.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "polardb.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "polardb.ap-southeast-5.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "polardb.aliyuncs.com" + }, + { + "code": "r-kvstore", + "document_id": "60831", + "location_service_code": "redisa", + "regional_endpoints": [ + { + "region": "cn-shenzhen", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "r-kvstore.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "r-kvstore.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "r-kvstore.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "r-kvstore.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "r-kvstore.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "r-kvstore.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "r-kvstore.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "r-kvstore.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "r-kvstore.eu-west-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "r-kvstore.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "r-kvstore.me-east-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "r-kvstore.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "r-kvstore.ap-southeast-5.aliyuncs.com" + } + ], + "global_endpoint": "r-kvstore.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "xianzhi", + "document_id": "", + "location_service_code": "xianzhi", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "xianzhi.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "pcdn", + "document_id": "", + "location_service_code": "pcdn", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "pcdn.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cdn", + "document_id": "27148", + "location_service_code": "cdn", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cdn.aliyuncs.com" + } + ], + "global_endpoint": "cdn.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudauth", + "document_id": "60687", + "location_service_code": "cloudauth", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cloudauth.aliyuncs.com" + } + ], + "global_endpoint": "cloudauth.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "nas", + "document_id": "62598", + "location_service_code": "nas", + "regional_endpoints": [ + { + "region": "ap-southeast-2", + "endpoint": "nas.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "nas.ap-south-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "nas.eu-central-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "nas.us-west-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "nas.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "nas.cn-qingdao.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "nas.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "nas.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "nas.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "nas.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "nas.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "nas.ap-northeast-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "nas.us-east-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "nas.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "nas.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "nas.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "nas.ap-southeast-3.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "alidns", + "document_id": "29739", + "location_service_code": "alidns", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "alidns.aliyuncs.com" + } + ], + "global_endpoint": "alidns.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "dts", + "document_id": "", + "location_service_code": "dts", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "dts.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "dts.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "emas", + "document_id": "", + "location_service_code": "emas", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "mhub.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "mhub.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "dysmsapi", + "document_id": "", + "location_service_code": "dysmsapi", + "regional_endpoints": [ + { + "region": "ap-southeast-3", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "cn-chengdu", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "dysmsapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "dysmsapi.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "dysmsapi.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudwf", + "document_id": "58111", + "location_service_code": "cloudwf", + "regional_endpoints": null, + "global_endpoint": "cloudwf.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "fc", + "document_id": "", + "location_service_code": "fc", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "cn-beijing.fc.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ap-southeast-2.fc.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "cn-huhehaote.fc.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "cn-shanghai.fc.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "cn-hangzhou.fc.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "cn-shenzhen.fc.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "saf", + "document_id": "", + "location_service_code": "saf", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "saf.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "saf.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "saf.cn-shenzhen.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "rds", + "document_id": "26223", + "location_service_code": "rds", + "regional_endpoints": [ + { + "region": "ap-northeast-1", + "endpoint": "rds.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "rds.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "rds.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "rds.eu-west-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "rds.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "rds.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "rds.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "rds.ap-southeast-5.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "rds.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "rds.me-east-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "rds.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "rds.aliyuncs.com" + } + ], + "global_endpoint": "rds.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "vpc", + "document_id": "34962", + "location_service_code": "vpc", + "regional_endpoints": [ + { + "region": "ap-south-1", + "endpoint": "vpc.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "vpc.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "vpc.ap-northeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "vpc.cn-huhehaote.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "vpc.me-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "vpc.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "vpc.ap-southeast-3.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "vpc.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "vpc.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "vpc.eu-west-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "vpc.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "vpc.aliyuncs.com" + } + ], + "global_endpoint": "vpc.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "gpdb", + "document_id": "", + "location_service_code": "gpdb", + "regional_endpoints": [ + { + "region": "ap-southeast-3", + "endpoint": "gpdb.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "gpdb.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "gpdb.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "gpdb.ap-southeast-2.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "gpdb.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "gpdb.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "gpdb.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "gpdb.ap-northeast-1.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "gpdb.eu-west-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "gpdb.ap-south-1.aliyuncs.com" + } + ], + "global_endpoint": "gpdb.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "yunmarket", + "document_id": "", + "location_service_code": "yunmarket", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "market.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "pvtz", + "document_id": "", + "location_service_code": "pvtz", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "pvtz.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "pvtz.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "oss", + "document_id": "", + "location_service_code": "oss", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "oss-cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "oss-cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "oss-cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "oss-cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "oss-cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "oss-ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "oss-us-west-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "oss-cn-qingdao.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "foas", + "document_id": "", + "location_service_code": "foas", + "regional_endpoints": [ + { + "region": "cn-qingdao", + "endpoint": "foas.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "foas.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "foas.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "foas.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "foas.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "foas.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "foas.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ddos", + "document_id": "", + "location_service_code": "ddos", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ddospro.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ddospro.cn-hongkong.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cbn", + "document_id": "", + "location_service_code": "cbn", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "cbn.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "cbn.aliyuncs.com" + } + ], + "global_endpoint": "cbn.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "nlp", + "document_id": "", + "location_service_code": "nlp", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "nlp.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "hsm", + "document_id": "", + "location_service_code": "hsm", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "hsm.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "hsm.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "hsm.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "hsm.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "hsm.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "hsm.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ons", + "document_id": "44416", + "location_service_code": "ons", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "ons.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "ons.cn-huhehaote.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "ons.us-east-1.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ons.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ons.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "ons.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ons.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ons.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ons.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "ons.me-east-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "ons.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ons.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "ons.cn-hangzhou.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "ons.eu-central-1.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "ons.eu-west-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "ons.us-west-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ons.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ons.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "kms", + "document_id": "", + "location_service_code": "kms", + "regional_endpoints": [ + { + "region": "cn-hongkong", + "endpoint": "kms.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "kms.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "kms.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "kms.cn-qingdao.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "kms.eu-west-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "kms.us-east-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "kms.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "kms.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "kms.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "kms.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "kms.cn-huhehaote.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "kms.me-east-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "kms.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "kms.ap-southeast-3.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "kms.us-west-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "kms.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "kms.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "kms.eu-central-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "kms.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cps", + "document_id": "", + "location_service_code": "cps", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cloudpush.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ensdisk", + "document_id": "", + "location_service_code": "ensdisk", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ens.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudapi", + "document_id": "43590", + "location_service_code": "apigateway", + "regional_endpoints": [ + { + "region": "ap-southeast-2", + "endpoint": "apigateway.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "apigateway.ap-south-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "apigateway.us-east-1.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "apigateway.me-east-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "apigateway.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "apigateway.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "apigateway.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "apigateway.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "apigateway.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "apigateway.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "apigateway.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "apigateway.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "apigateway.cn-hangzhou.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "apigateway.us-west-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "apigateway.cn-shenzhen.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "apigateway.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "apigateway.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "apigateway.ap-northeast-1.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "apigateway.cn-hongkong.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "apigateway.[RegionId].aliyuncs.com" + }, + { + "code": "eci", + "document_id": "", + "location_service_code": "eci", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "eci.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "eci.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "eci.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "eci.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "eci.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "eci.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "onsvip", + "document_id": "", + "location_service_code": "onsvip", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "ons.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ons.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ons.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ons.cn-shenzhen.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "ons.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ons.cn-qingdao.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "linkwan", + "document_id": "", + "location_service_code": "linkwan", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "linkwan.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "linkwan.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ddosdip", + "document_id": "", + "location_service_code": "ddosdip", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "ddosdip.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "batchcompute", + "document_id": "44717", + "location_service_code": "batchcompute", + "regional_endpoints": [ + { + "region": "us-west-1", + "endpoint": "batchcompute.us-west-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "batchcompute.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "batchcompute.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "batchcompute.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "batchcompute.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "batchcompute.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "batchcompute.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "batchcompute.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "batchcompute.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "batchcompute.[RegionId].aliyuncs.com" + }, + { + "code": "aegis", + "document_id": "28449", + "location_service_code": "vipaegis", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "aegis.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "aegis.ap-southeast-3.aliyuncs.com" + } + ], + "global_endpoint": "aegis.cn-hangzhou.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "arms", + "document_id": "42924", + "location_service_code": "arms", + "regional_endpoints": [ + { + "region": "cn-hongkong", + "endpoint": "arms.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "arms.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "arms.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "arms.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "arms.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "arms.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "arms.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "arms.[RegionId].aliyuncs.com" + }, + { + "code": "live", + "document_id": "48207", + "location_service_code": "live", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "live.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "live.aliyuncs.com" + } + ], + "global_endpoint": "live.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "alimt", + "document_id": "", + "location_service_code": "alimt", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "mt.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "actiontrail", + "document_id": "", + "location_service_code": "actiontrail", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "actiontrail.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "actiontrail.cn-qingdao.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "actiontrail.us-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "actiontrail.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "actiontrail.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "actiontrail.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "actiontrail.ap-south-1.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "actiontrail.me-east-1.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "actiontrail.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "actiontrail.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "actiontrail.cn-hangzhou.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "actiontrail.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "actiontrail.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "actiontrail.ap-northeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "actiontrail.us-west-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "actiontrail.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "actiontrail.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "actiontrail.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "actiontrail.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "smartag", + "document_id": "", + "location_service_code": "smartag", + "regional_endpoints": [ + { + "region": "ap-southeast-3", + "endpoint": "smartag.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "smartag.ap-southeast-5.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "smartag.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "smartag.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "smartag.cn-hongkong.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "smartag.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "smartag.ap-southeast-2.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "vod", + "document_id": "60574", + "location_service_code": "vod", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "vod.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "vod.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "vod.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "vod.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "vod.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "vod.eu-central-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "domain", + "document_id": "42875", + "location_service_code": "domain", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "domain-intl.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "domain.aliyuncs.com" + } + ], + "global_endpoint": "domain.aliyuncs.com", + "regional_endpoint_pattern": "domain.aliyuncs.com" + }, + { + "code": "ros", + "document_id": "28899", + "location_service_code": "ros", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ros.aliyuncs.com" + } + ], + "global_endpoint": "ros.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudphoto", + "document_id": "59902", + "location_service_code": "cloudphoto", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "cloudphoto.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "cloudphoto.[RegionId].aliyuncs.com" + }, + { + "code": "rtc", + "document_id": "", + "location_service_code": "rtc", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "rtc.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "odpsmayi", + "document_id": "", + "location_service_code": "odpsmayi", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "bsb.cloud.alipay.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "bsb.cloud.alipay.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ims", + "document_id": "", + "location_service_code": "ims", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ims.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "csb", + "document_id": "64837", + "location_service_code": "csb", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "csb.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "csb.cn-beijing.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "csb.[RegionId].aliyuncs.com" + }, + { + "code": "cds", + "document_id": "62887", + "location_service_code": "codepipeline", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "cds.cn-beijing.aliyuncs.com" + } + ], + "global_endpoint": "cds.cn-beijing.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "ddosbgp", + "document_id": "", + "location_service_code": "ddosbgp", + "regional_endpoints": [ + { + "region": "cn-huhehaote", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ddosbgp.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "ddosbgp.us-west-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ddosbgp.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "dybaseapi", + "document_id": "", + "location_service_code": "dybaseapi", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "cn-chengdu", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "dybaseapi.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "dybaseapi.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ecs", + "document_id": "25484", + "location_service_code": "ecs", + "regional_endpoints": [ + { + "region": "cn-huhehaote", + "endpoint": "ecs.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "ecs.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ecs.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "ecs.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "ecs.ap-southeast-3.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "ecs.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ecs.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "ecs.eu-west-1.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "ecs.me-east-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "ecs.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "ecs-cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "ecs-cn-hangzhou.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "ccc", + "document_id": "63027", + "location_service_code": "ccc", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ccc.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ccc.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "ccc.[RegionId].aliyuncs.com" + }, + { + "code": "cs", + "document_id": "26043", + "location_service_code": "cs", + "regional_endpoints": null, + "global_endpoint": "cs.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "drdspre", + "document_id": "", + "location_service_code": "drdspre", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "drds.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "drds.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "drds.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "drds.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "drds.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "drds.cn-qingdao.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "drds.cn-beijing.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "dcdn", + "document_id": "", + "location_service_code": "dcdn", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "dcdn.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "dcdn.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "linkedmall", + "document_id": "", + "location_service_code": "linkedmall", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "linkedmall.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "linkedmall.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "trademark", + "document_id": "", + "location_service_code": "trademark", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "trademark.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "openanalytics", + "document_id": "", + "location_service_code": "openanalytics", + "regional_endpoints": [ + { + "region": "cn-shenzhen", + "endpoint": "openanalytics.cn-shenzhen.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "openanalytics.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "openanalytics.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "openanalytics.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "openanalytics.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "openanalytics.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "openanalytics.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "openanalytics.cn-zhangjiakou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "sts", + "document_id": "28756", + "location_service_code": "sts", + "regional_endpoints": null, + "global_endpoint": "sts.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "waf", + "document_id": "62847", + "location_service_code": "waf", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "wafopenapi.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ots", + "document_id": "", + "location_service_code": "ots", + "regional_endpoints": [ + { + "region": "me-east-1", + "endpoint": "ots.me-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "ots.ap-southeast-5.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "ots.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "ots.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ots.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ots.ap-southeast-2.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "ots.us-west-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "ots.us-east-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "ots.ap-south-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "ots.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ots.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ots.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "ots.ap-northeast-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ots.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "ots.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "ots.ap-southeast-3.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cloudfirewall", + "document_id": "", + "location_service_code": "cloudfirewall", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cloudfw.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "dm", + "document_id": "29434", + "location_service_code": "dm", + "regional_endpoints": [ + { + "region": "ap-southeast-2", + "endpoint": "dm.ap-southeast-2.aliyuncs.com" + } + ], + "global_endpoint": "dm.aliyuncs.com", + "regional_endpoint_pattern": "dm.[RegionId].aliyuncs.com" + }, + { + "code": "oas", + "document_id": "", + "location_service_code": "oas", + "regional_endpoints": [ + { + "region": "cn-shenzhen", + "endpoint": "cn-shenzhen.oas.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "cn-beijing.oas.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "cn-hangzhou.oas.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ddoscoo", + "document_id": "", + "location_service_code": "ddoscoo", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ddoscoo.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "jaq", + "document_id": "35037", + "location_service_code": "jaq", + "regional_endpoints": null, + "global_endpoint": "jaq.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "iovcc", + "document_id": "", + "location_service_code": "iovcc", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "iovcc.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "sas-api", + "document_id": "28498", + "location_service_code": "sas", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "sas.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "chatbot", + "document_id": "60760", + "location_service_code": "beebot", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "chatbot.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "chatbot.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "chatbot.[RegionId].aliyuncs.com" + }, + { + "code": "airec", + "document_id": "", + "location_service_code": "airec", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "airec.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "airec.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "airec.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "dmsenterprise", + "document_id": "", + "location_service_code": "dmsenterprise", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "dms-enterprise.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "dms-enterprise.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "dms-enterprise.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "dms-enterprise.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "dms-enterprise.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "dms-enterprise.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ivision", + "document_id": "", + "location_service_code": "ivision", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ivision.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ivision.cn-beijing.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "odpsplusmayi", + "document_id": "", + "location_service_code": "odpsplusmayi", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "bsb.cloud.alipay.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "bsb.cloud.alipay.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "bsb.cloud.alipay.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "gameshield", + "document_id": "", + "location_service_code": "gameshield", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "gameshield.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "gameshield.cn-zhangjiakou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "scdn", + "document_id": "", + "location_service_code": "scdn", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "scdn.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "hitsdb", + "document_id": "", + "location_service_code": "hitsdb", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "hitsdb.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "hdm", + "document_id": "", + "location_service_code": "hdm", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "hdm-api.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "slb", + "document_id": "27565", + "location_service_code": "slb", + "regional_endpoints": [ + { + "region": "cn-shenzhen", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "slb.eu-west-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "slb.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "slb.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "slb.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "slb.ap-south-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "slb.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "slb.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "slb.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "slb.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "slb.me-east-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "slb.cn-zhangjiakou.aliyuncs.com" + } + ], + "global_endpoint": "slb.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "green", + "document_id": "28427", + "location_service_code": "green", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "green.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "green.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "green.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "green.cn-hangzhou.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "green.us-west-1.aliyuncs.com" + } + ], + "global_endpoint": "green.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "cccvn", + "document_id": "", + "location_service_code": "cccvn", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "voicenavigator.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ddosrewards", + "document_id": "", + "location_service_code": "ddosrewards", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ddosright.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "iot", + "document_id": "30557", + "location_service_code": "iot", + "regional_endpoints": [ + { + "region": "us-east-1", + "endpoint": "iot.us-east-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "iot.ap-northeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "iot.us-west-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "iot.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "iot.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "iot.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "iot.[RegionId].aliyuncs.com" + }, + { + "code": "bssopenapi", + "document_id": "", + "location_service_code": "bssopenapi", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "business.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "business.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "sca", + "document_id": "", + "location_service_code": "sca", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "qualitycheck.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "luban", + "document_id": "", + "location_service_code": "luban", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "luban.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "luban.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "drdspost", + "document_id": "", + "location_service_code": "drdspost", + "regional_endpoints": [ + { + "region": "cn-shanghai", + "endpoint": "drds.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "drds.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "drds.ap-southeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "drds", + "document_id": "51111", + "location_service_code": "drds", + "regional_endpoints": [ + { + "region": "ap-southeast-1", + "endpoint": "drds.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "drds.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "drds.aliyuncs.com", + "regional_endpoint_pattern": "drds.aliyuncs.com" + }, + { + "code": "httpdns", + "document_id": "52679", + "location_service_code": "httpdns", + "regional_endpoints": null, + "global_endpoint": "httpdns-api.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "cas", + "document_id": "", + "location_service_code": "cas", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "cas.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "cas.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "cas.ap-northeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "cas.eu-central-1.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "cas.me-east-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "hpc", + "document_id": "35201", + "location_service_code": "hpc", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "hpc.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "hpc.aliyuncs.com" + } + ], + "global_endpoint": "hpc.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "ddosbasic", + "document_id": "", + "location_service_code": "ddosbasic", + "regional_endpoints": [ + { + "region": "ap-south-1", + "endpoint": "antiddos-openapi.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "antiddos-openapi.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "antiddos-openapi.ap-southeast-3.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "antiddos-openapi.me-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "antiddos-openapi.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "antiddos-openapi.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "antiddos-openapi.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "antiddos-openapi.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "antiddos-openapi.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "antiddos.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "antiddos-openapi.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "antiddos.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "clouddesktop", + "document_id": "", + "location_service_code": "clouddesktop", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "clouddesktop.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "clouddesktop.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "clouddesktop.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "clouddesktop.cn-shenzhen.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "uis", + "document_id": "", + "location_service_code": "uis", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "uis.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "imm", + "document_id": "", + "location_service_code": "imm", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "imm.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "imm.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "imm.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "imm.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "imm.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "imm.cn-shenzhen.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ens", + "document_id": "", + "location_service_code": "ens", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ens.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ram", + "document_id": "28672", + "location_service_code": "ram", + "regional_endpoints": null, + "global_endpoint": "ram.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "hcs_mgw", + "document_id": "", + "location_service_code": "hcs_mgw", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "mgw.cn-hangzhou.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "mgw.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "mgw.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "itaas", + "document_id": "55759", + "location_service_code": "itaas", + "regional_endpoints": null, + "global_endpoint": "itaas.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "qualitycheck", + "document_id": "50807", + "location_service_code": "qualitycheck", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "qualitycheck.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "alikafka", + "document_id": "", + "location_service_code": "alikafka", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "alikafka.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "alikafka.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "alikafka.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "alikafka.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "alikafka.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "alikafka.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "alikafka.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "alikafka.cn-qingdao.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "faas", + "document_id": "", + "location_service_code": "faas", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "faas.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "faas.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "faas.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "faas.cn-beijing.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "alidfs", + "document_id": "", + "location_service_code": "alidfs", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "dfs.cn-beijing.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "dfs.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "cms", + "document_id": "28615", + "location_service_code": "cms", + "regional_endpoints": [ + { + "region": "ap-southeast-3", + "endpoint": "metrics.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "metrics.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "metrics.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "metrics.cn-hangzhou.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "metrics.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "metrics.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "metrics.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "domain-intl", + "document_id": "", + "location_service_code": "domain-intl", + "regional_endpoints": null, + "global_endpoint": "domain-intl.aliyuncs.com", + "regional_endpoint_pattern": "domain-intl.aliyuncs.com" + }, + { + "code": "kvstore", + "document_id": "", + "location_service_code": "kvstore", + "regional_endpoints": [ + { + "region": "ap-northeast-1", + "endpoint": "r-kvstore.ap-northeast-1.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ccs", + "document_id": "", + "location_service_code": "ccs", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "ccs.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "ess", + "document_id": "25925", + "location_service_code": "ess", + "regional_endpoints": [ + { + "region": "cn-huhehaote", + "endpoint": "ess.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "ess.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "ess.eu-west-1.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "ess.ap-southeast-5.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "ess.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "ess.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "ess.me-east-1.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "ess.ap-northeast-1.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "ess.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "ess.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "ess.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "ess.aliyuncs.com" + } + ], + "global_endpoint": "ess.aliyuncs.com", + "regional_endpoint_pattern": "ess.[RegionId].aliyuncs.com" + }, + { + "code": "dds", + "document_id": "61715", + "location_service_code": "dds", + "regional_endpoints": [ + { + "region": "me-east-1", + "endpoint": "mongodb.me-east-1.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "mongodb.ap-southeast-3.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "mongodb.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "mongodb.ap-northeast-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "mongodb.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "mongodb.eu-west-1.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "cn-huhehaote", + "endpoint": "mongodb.cn-huhehaote.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "mongodb.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "mongodb.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "mongodb.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "mongodb.ap-south-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "mongodb.aliyuncs.com" + } + ], + "global_endpoint": "mongodb.aliyuncs.com", + "regional_endpoint_pattern": "mongodb.[RegionId].aliyuncs.com" + }, + { + "code": "mts", + "document_id": "29212", + "location_service_code": "mts", + "regional_endpoints": [ + { + "region": "cn-beijing", + "endpoint": "mts.cn-beijing.aliyuncs.com" + }, + { + "region": "ap-northeast-1", + "endpoint": "mts.ap-northeast-1.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "mts.cn-hongkong.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "mts.cn-shenzhen.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "mts.cn-zhangjiakou.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "mts.ap-south-1.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "mts.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "mts.ap-southeast-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "mts.us-west-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "mts.eu-central-1.aliyuncs.com" + }, + { + "region": "eu-west-1", + "endpoint": "mts.eu-west-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "mts.cn-hangzhou.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "push", + "document_id": "30074", + "location_service_code": "push", + "regional_endpoints": null, + "global_endpoint": "cloudpush.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "hcs_sgw", + "document_id": "", + "location_service_code": "hcs_sgw", + "regional_endpoints": [ + { + "region": "eu-central-1", + "endpoint": "sgw.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-zhangjiakou", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "sgw.ap-southeast-1.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-hongkong", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "sgw.ap-southeast-2.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "sgw.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "hbase", + "document_id": "", + "location_service_code": "hbase", + "regional_endpoints": [ + { + "region": "cn-huhehaote", + "endpoint": "hbase.cn-huhehaote.aliyuncs.com" + }, + { + "region": "ap-south-1", + "endpoint": "hbase.ap-south-1.aliyuncs.com" + }, + { + "region": "us-west-1", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "me-east-1", + "endpoint": "hbase.me-east-1.aliyuncs.com" + }, + { + "region": "eu-central-1", + "endpoint": "hbase.eu-central-1.aliyuncs.com" + }, + { + "region": "cn-qingdao", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "cn-shenzhen", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "ap-southeast-2", + "endpoint": "hbase.ap-southeast-2.aliyuncs.com" + }, + { + "region": "ap-southeast-3", + "endpoint": "hbase.ap-southeast-3.aliyuncs.com" + }, + { + "region": "cn-hangzhou", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "us-east-1", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "ap-southeast-5", + "endpoint": "hbase.ap-southeast-5.aliyuncs.com" + }, + { + "region": "cn-beijing", + "endpoint": "hbase.aliyuncs.com" + }, + { + "region": "ap-southeast-1", + "endpoint": "hbase.aliyuncs.com" + } + ], + "global_endpoint": "hbase.aliyuncs.com", + "regional_endpoint_pattern": "" + }, + { + "code": "bastionhost", + "document_id": "", + "location_service_code": "bastionhost", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "yundun-bastionhost.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + }, + { + "code": "vs", + "document_id": "", + "location_service_code": "vs", + "regional_endpoints": [ + { + "region": "cn-hangzhou", + "endpoint": "vs.cn-hangzhou.aliyuncs.com" + }, + { + "region": "cn-shanghai", + "endpoint": "vs.cn-shanghai.aliyuncs.com" + } + ], + "global_endpoint": "", + "regional_endpoint_pattern": "" + } + ] +}` + +var initOnce sync.Once +var data interface{} + +func getEndpointConfigData() interface{} { + initOnce.Do(func() { + err := json.Unmarshal([]byte(endpointsJson), &data) + if err != nil { + panic(fmt.Sprintf("init endpoint config data failed. %s", err)) + } + }) + return data +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_global_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_global_resolver.go new file mode 100644 index 0000000000..160e62cb64 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_global_resolver.go @@ -0,0 +1,43 @@ +/* + * 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 endpoints + +import ( + "fmt" + "strings" + + "github.com/jmespath/go-jmespath" +) + +type LocalGlobalResolver struct { +} + +func (resolver *LocalGlobalResolver) GetName() (name string) { + name = "local global resolver" + return +} + +func (resolver *LocalGlobalResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) { + // get the global endpoints configs + endpointExpression := fmt.Sprintf("products[?code=='%s'].global_endpoint", strings.ToLower(param.Product)) + endpointData, err := jmespath.Search(endpointExpression, getEndpointConfigData()) + if err == nil && endpointData != nil && len(endpointData.([]interface{})) > 0 { + endpoint = endpointData.([]interface{})[0].(string) + support = len(endpoint) > 0 + return + } + support = false + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_regional_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_regional_resolver.go new file mode 100644 index 0000000000..7fee64d42a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/local_regional_resolver.go @@ -0,0 +1,48 @@ +/* + * 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 endpoints + +import ( + "fmt" + "strings" + + "github.com/jmespath/go-jmespath" +) + +type LocalRegionalResolver struct { +} + +func (resolver *LocalRegionalResolver) GetName() (name string) { + name = "local regional resolver" + return +} + +func (resolver *LocalRegionalResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) { + // get the regional endpoints configs + regionalExpression := fmt.Sprintf("products[?code=='%s'].regional_endpoints", strings.ToLower(param.Product)) + regionalData, err := jmespath.Search(regionalExpression, getEndpointConfigData()) + if err == nil && regionalData != nil && len(regionalData.([]interface{})) > 0 { + endpointExpression := fmt.Sprintf("[0][?region=='%s'].endpoint", strings.ToLower(param.RegionId)) + var endpointData interface{} + endpointData, err = jmespath.Search(endpointExpression, regionalData) + if err == nil && endpointData != nil && len(endpointData.([]interface{})) > 0 { + endpoint = endpointData.([]interface{})[0].(string) + support = len(endpoint) > 0 + return + } + } + support = false + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go new file mode 100644 index 0000000000..cc354cc4d9 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/location_resolver.go @@ -0,0 +1,176 @@ +/* + * 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 endpoints + +import ( + "encoding/json" + "sync" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" +) + +const ( + // EndpointCacheExpireTime ... + EndpointCacheExpireTime = 3600 //Seconds +) + +// Cache caches endpoint for specific product and region +type Cache struct { + sync.RWMutex + cache map[string]interface{} +} + +// Get ... +func (c *Cache) Get(k string) (v interface{}) { + c.RLock() + v = c.cache[k] + c.RUnlock() + return +} + +// Set ... +func (c *Cache) Set(k string, v interface{}) { + c.Lock() + c.cache[k] = v + c.Unlock() +} + +var lastClearTimePerProduct = &Cache{cache: make(map[string]interface{})} +var endpointCache = &Cache{cache: make(map[string]interface{})} + +// LocationResolver ... +type LocationResolver struct { +} + +func (resolver *LocationResolver) GetName() (name string) { + name = "location resolver" + return +} + +// TryResolve resolves endpoint giving product and region +func (resolver *LocationResolver) TryResolve(param *ResolveParam) (endpoint string, support bool, err error) { + if len(param.LocationProduct) <= 0 { + support = false + return + } + + //get from cache + cacheKey := param.Product + "#" + param.RegionId + var ok bool + endpoint, ok = endpointCache.Get(cacheKey).(string) + + if ok && len(endpoint) > 0 && !CheckCacheIsExpire(cacheKey) { + support = true + return + } + + //get from remote + getEndpointRequest := requests.NewCommonRequest() + + getEndpointRequest.Product = "Location" + getEndpointRequest.Version = "2015-06-12" + getEndpointRequest.ApiName = "DescribeEndpoints" + getEndpointRequest.Domain = "location-readonly.aliyuncs.com" + getEndpointRequest.Method = "GET" + getEndpointRequest.Scheme = requests.HTTPS + + getEndpointRequest.QueryParams["Id"] = param.RegionId + getEndpointRequest.QueryParams["ServiceCode"] = param.LocationProduct + if len(param.LocationEndpointType) > 0 { + getEndpointRequest.QueryParams["Type"] = param.LocationEndpointType + } else { + getEndpointRequest.QueryParams["Type"] = "openAPI" + } + + response, err := param.CommonApi(getEndpointRequest) + if err != nil { + support = false + return + } + + if !response.IsSuccess() { + support = false + return + } + + var getEndpointResponse GetEndpointResponse + err = json.Unmarshal([]byte(response.GetHttpContentString()), &getEndpointResponse) + if err != nil { + support = false + return + } + + if !getEndpointResponse.Success || getEndpointResponse.Endpoints == nil { + support = false + return + } + if len(getEndpointResponse.Endpoints.Endpoint) <= 0 { + support = false + return + } + if len(getEndpointResponse.Endpoints.Endpoint[0].Endpoint) > 0 { + endpoint = getEndpointResponse.Endpoints.Endpoint[0].Endpoint + endpointCache.Set(cacheKey, endpoint) + lastClearTimePerProduct.Set(cacheKey, time.Now().Unix()) + support = true + return + } + + support = false + return +} + +// CheckCacheIsExpire ... +func CheckCacheIsExpire(cacheKey string) bool { + lastClearTime, ok := lastClearTimePerProduct.Get(cacheKey).(int64) + if !ok { + return true + } + + if lastClearTime <= 0 { + lastClearTime = time.Now().Unix() + lastClearTimePerProduct.Set(cacheKey, lastClearTime) + } + + now := time.Now().Unix() + elapsedTime := now - lastClearTime + if elapsedTime > EndpointCacheExpireTime { + return true + } + + return false +} + +// GetEndpointResponse ... +type GetEndpointResponse struct { + Endpoints *EndpointsObj + RequestId string + Success bool +} + +// EndpointsObj ... +type EndpointsObj struct { + Endpoint []EndpointObj +} + +// EndpointObj ... +type EndpointObj struct { + // Protocols map[string]string + Type string + Namespace string + Id string + SerivceCode string + Endpoint string +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/mapping_resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/mapping_resolver.go new file mode 100644 index 0000000000..a415a169a3 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/mapping_resolver.go @@ -0,0 +1,49 @@ +/* + * 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 endpoints + +import ( + "fmt" + "strings" + "sync" +) + +const keyFormatter = "%s::%s" + +type EndpointMapping struct { + sync.RWMutex + endpoint map[string]string +} + +var endpointMapping = EndpointMapping{endpoint: make(map[string]string)} + +// AddEndpointMapping use productId and regionId as key to store the endpoint into inner map +// when using the same productId and regionId as key, the endpoint will be covered. +func AddEndpointMapping(regionId, productId, endpoint string) (err error) { + key := fmt.Sprintf(keyFormatter, strings.ToLower(regionId), strings.ToLower(productId)) + endpointMapping.Lock() + endpointMapping.endpoint[key] = endpoint + endpointMapping.Unlock() + return nil +} + +// GetEndpointFromMap use Product and RegionId as key to find endpoint from inner map +func GetEndpointFromMap(regionId, productId string) string { + key := fmt.Sprintf(keyFormatter, strings.ToLower(regionId), strings.ToLower(productId)) + endpointMapping.RLock() + endpoint := endpointMapping.endpoint[key] + endpointMapping.RUnlock() + return endpoint +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/resolver.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/resolver.go new file mode 100644 index 0000000000..a73b8b137a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints/resolver.go @@ -0,0 +1,96 @@ +/* + * 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 endpoints + +import ( + "encoding/json" + "fmt" + "sync" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +var debug utils.Debug + +func init() { + debug = utils.Init("sdk") +} + +const ( + ResolveEndpointUserGuideLink = "" +) + +var once sync.Once +var resolvers []Resolver + +type Resolver interface { + TryResolve(param *ResolveParam) (endpoint string, support bool, err error) + GetName() (name string) +} + +// Resolve resolve endpoint with params +// It will resolve with each supported resolver until anyone resolved +func Resolve(param *ResolveParam) (endpoint string, err error) { + supportedResolvers := getAllResolvers() + var lastErr error + for _, resolver := range supportedResolvers { + endpoint, supported, resolveErr := resolver.TryResolve(param) + if resolveErr != nil { + lastErr = resolveErr + } + + if supported { + debug("resolve endpoint with %s\n", param) + debug("\t%s by resolver(%s)\n", endpoint, resolver.GetName()) + return endpoint, nil + } + } + + // not support + errorMsg := fmt.Sprintf(errors.CanNotResolveEndpointErrorMessage, param, ResolveEndpointUserGuideLink) + err = errors.NewClientError(errors.CanNotResolveEndpointErrorCode, errorMsg, lastErr) + return +} + +func getAllResolvers() []Resolver { + once.Do(func() { + resolvers = []Resolver{ + &LocationResolver{}, + &LocalRegionalResolver{}, + &LocalGlobalResolver{}, + } + }) + return resolvers +} + +type ResolveParam struct { + Domain string + Product string + RegionId string + LocationProduct string + LocationEndpointType string + CommonApi func(request *requests.CommonRequest) (response *responses.CommonResponse, err error) `json:"-"` +} + +func (param *ResolveParam) String() string { + jsonBytes, err := json.Marshal(param) + if err != nil { + return fmt.Sprint("ResolveParam.String() process error:", err) + } + return string(jsonBytes) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/client_error.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/client_error.go new file mode 100644 index 0000000000..1e2d9c0040 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/client_error.go @@ -0,0 +1,92 @@ +/* + * 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 errors + +import "fmt" + +const ( + DefaultClientErrorStatus = 400 + DefaultClientErrorCode = "SDK.ClientError" + + UnsupportedCredentialErrorCode = "SDK.UnsupportedCredential" + UnsupportedCredentialErrorMessage = "Specified credential (type = %s) is not supported, please check" + + CanNotResolveEndpointErrorCode = "SDK.CanNotResolveEndpoint" + CanNotResolveEndpointErrorMessage = "Can not resolve endpoint(param = %s), please check your accessKey with secret, and read the user guide\n %s" + + UnsupportedParamPositionErrorCode = "SDK.UnsupportedParamPosition" + UnsupportedParamPositionErrorMessage = "Specified param position (%s) is not supported, please upgrade sdk and retry" + + AsyncFunctionNotEnabledCode = "SDK.AsyncFunctionNotEnabled" + AsyncFunctionNotEnabledMessage = "Async function is not enabled in client, please invoke 'client.EnableAsync' function" + + UnknownRequestTypeErrorCode = "SDK.UnknownRequestType" + UnknownRequestTypeErrorMessage = "Unknown Request Type: %s" + + MissingParamErrorCode = "SDK.MissingParam" + InvalidParamErrorCode = "SDK.InvalidParam" + + JsonUnmarshalErrorCode = "SDK.JsonUnmarshalError" + JsonUnmarshalErrorMessage = "Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString()" + + TimeoutErrorCode = "SDK.TimeoutError" + TimeoutErrorMessage = "The request timed out %s times(%s for retry), perhaps we should have the threshold raised a little?" +) + +type ClientError struct { + errorCode string + message string + originError error +} + +func NewClientError(errorCode, message string, originErr error) Error { + return &ClientError{ + errorCode: errorCode, + message: message, + originError: originErr, + } +} + +func (err *ClientError) Error() string { + clientErrMsg := fmt.Sprintf("[%s] %s", err.ErrorCode(), err.message) + if err.originError != nil { + return clientErrMsg + "\ncaused by:\n" + err.originError.Error() + } + return clientErrMsg +} + +func (err *ClientError) OriginError() error { + return err.originError +} + +func (*ClientError) HttpStatus() int { + return DefaultClientErrorStatus +} + +func (err *ClientError) ErrorCode() string { + if err.errorCode == "" { + return DefaultClientErrorCode + } else { + return err.errorCode + } +} + +func (err *ClientError) Message() string { + return err.message +} + +func (err *ClientError) String() string { + return err.Error() +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/error.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/error.go new file mode 100644 index 0000000000..49962f3b5e --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/error.go @@ -0,0 +1,23 @@ +/* + * 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 errors + +type Error interface { + error + HttpStatus() int + ErrorCode() string + Message() string + OriginError() error +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/server_error.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/server_error.go new file mode 100644 index 0000000000..1b7810414a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/server_error.go @@ -0,0 +1,123 @@ +/* + * 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 errors + +import ( + "encoding/json" + "fmt" + + "github.com/jmespath/go-jmespath" +) + +var wrapperList = []ServerErrorWrapper{ + &SignatureDostNotMatchWrapper{}, +} + +type ServerError struct { + httpStatus int + requestId string + hostId string + errorCode string + recommend string + message string + comment string +} + +type ServerErrorWrapper interface { + tryWrap(error *ServerError, wrapInfo map[string]string) bool +} + +func (err *ServerError) Error() string { + return fmt.Sprintf("SDK.ServerError\nErrorCode: %s\nRecommend: %s\nRequestId: %s\nMessage: %s", + err.errorCode, err.comment+err.recommend, err.requestId, err.message) +} + +func NewServerError(httpStatus int, responseContent, comment string) Error { + result := &ServerError{ + httpStatus: httpStatus, + message: responseContent, + comment: comment, + } + + var data interface{} + err := json.Unmarshal([]byte(responseContent), &data) + if err == nil { + requestId, _ := jmespath.Search("RequestId", data) + hostId, _ := jmespath.Search("HostId", data) + errorCode, _ := jmespath.Search("Code", data) + recommend, _ := jmespath.Search("Recommend", data) + message, _ := jmespath.Search("Message", data) + + if requestId != nil { + result.requestId = requestId.(string) + } + if hostId != nil { + result.hostId = hostId.(string) + } + if errorCode != nil { + result.errorCode = errorCode.(string) + } + if recommend != nil { + result.recommend = recommend.(string) + } + if message != nil { + result.message = message.(string) + } + } + + return result +} + +func WrapServerError(originError *ServerError, wrapInfo map[string]string) *ServerError { + for _, wrapper := range wrapperList { + ok := wrapper.tryWrap(originError, wrapInfo) + if ok { + return originError + } + } + return originError +} + +func (err *ServerError) HttpStatus() int { + return err.httpStatus +} + +func (err *ServerError) ErrorCode() string { + return err.errorCode +} + +func (err *ServerError) Message() string { + return err.message +} + +func (err *ServerError) OriginError() error { + return nil +} + +func (err *ServerError) HostId() string { + return err.hostId +} + +func (err *ServerError) RequestId() string { + return err.requestId +} + +func (err *ServerError) Recommend() string { + return err.recommend +} + +func (err *ServerError) Comment() string { + return err.comment +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/signature_does_not_match_wrapper.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/signature_does_not_match_wrapper.go new file mode 100644 index 0000000000..4b09d7d71c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors/signature_does_not_match_wrapper.go @@ -0,0 +1,45 @@ +package errors + +import ( + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +const SignatureDostNotMatchErrorCode = "SignatureDoesNotMatch" +const IncompleteSignatureErrorCode = "IncompleteSignature" +const MessageContain = "server string to sign is:" + +var debug utils.Debug + +func init() { + debug = utils.Init("sdk") +} + +type SignatureDostNotMatchWrapper struct { +} + +func (*SignatureDostNotMatchWrapper) tryWrap(error *ServerError, wrapInfo map[string]string) (ok bool) { + clientStringToSign := wrapInfo["StringToSign"] + if (error.errorCode == SignatureDostNotMatchErrorCode || error.errorCode == IncompleteSignatureErrorCode) && clientStringToSign != "" { + message := error.message + if strings.Contains(message, MessageContain) { + str := strings.Split(message, MessageContain) + serverStringToSign := str[1] + + if clientStringToSign == serverStringToSign { + // user secret is error + error.recommend = "InvalidAccessKeySecret: Please check you AccessKeySecret" + } else { + debug("Client StringToSign: %s", clientStringToSign) + debug("Server StringToSign: %s", serverStringToSign) + error.recommend = "This may be a bug with the SDK and we hope you can submit this question in the " + + "github issue(https://github.com/aliyun/alibaba-cloud-sdk-go/issues), thanks very much" + } + } + ok = true + return + } + ok = false + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/logger.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/logger.go new file mode 100644 index 0000000000..49e49833d2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/logger.go @@ -0,0 +1,117 @@ +package sdk + +import ( + "encoding/json" + "io" + "log" + "os" + "strings" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +var logChannel string +var defaultChannel = "AlibabaCloud" + +type Logger struct { + *log.Logger + formatTemplate string + isOpen bool + lastLogMsg string +} + +var defaultLoggerTemplate = `{time} {channel}: "{method} {uri} HTTP/{version}" {code} {cost} {hostname}` +var loggerParam = []string{"{time}", "{start_time}", "{ts}", "{channel}", "{pid}", "{host}", "{method}", "{uri}", "{version}", "{target}", "{hostname}", "{code}", "{error}", "{req_headers}", "{res_body}", "{res_headers}", "{cost}"} + +func initLogMsg(fieldMap map[string]string) { + for _, value := range loggerParam { + fieldMap[value] = "" + } +} + +func (client *Client) GetLogger() *Logger { + return client.logger +} + +func (client *Client) GetLoggerMsg() string { + if client.logger == nil { + client.SetLogger("", "", os.Stdout, "") + } + return client.logger.lastLogMsg +} + +func (client *Client) SetLogger(level string, channel string, out io.Writer, template string) { + if level == "" { + level = "info" + } + + logChannel = "AlibabaCloud" + if channel != "" { + logChannel = channel + } + log := log.New(out, "["+strings.ToUpper(level)+"]", log.Lshortfile) + if template == "" { + template = defaultLoggerTemplate + } + + client.logger = &Logger{ + Logger: log, + formatTemplate: template, + isOpen: true, + } +} + +func (client *Client) OpenLogger() { + if client.logger == nil { + client.SetLogger("", "", os.Stdout, "") + } + client.logger.isOpen = true +} + +func (client *Client) CloseLogger() { + if client.logger != nil { + client.logger.isOpen = false + } +} + +func (client *Client) SetTemplate(template string) { + if client.logger == nil { + client.SetLogger("", "", os.Stdout, "") + } + client.logger.formatTemplate = template +} + +func (client *Client) GetTemplate() string { + if client.logger == nil { + client.SetLogger("", "", os.Stdout, "") + } + return client.logger.formatTemplate +} + +func TransToString(object interface{}) string { + byt, err := json.Marshal(object) + if err != nil { + return "" + } + return string(byt) +} + +func (client *Client) printLog(fieldMap map[string]string, err error) { + if err != nil { + fieldMap["{error}"] = err.Error() + } + fieldMap["{time}"] = time.Now().Format("2006-01-02 15:04:05") + fieldMap["{ts}"] = utils.GetTimeInFormatISO8601() + fieldMap["{channel}"] = logChannel + if client.logger != nil { + logMsg := client.logger.formatTemplate + for key, value := range fieldMap { + logMsg = strings.Replace(logMsg, key, value, -1) + } + client.logger.lastLogMsg = logMsg + if client.logger.isOpen == true { + client.logger.Output(2, logMsg) + } + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/acs_request.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/acs_request.go new file mode 100644 index 0000000000..d055c75428 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/acs_request.go @@ -0,0 +1,525 @@ +/* + * 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 requests + +import ( + "encoding/json" + "fmt" + "io" + "reflect" + "strconv" + "strings" + "time" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" +) + +const ( + RPC = "RPC" + ROA = "ROA" + + HTTP = "HTTP" + HTTPS = "HTTPS" + + DefaultHttpPort = "80" + + GET = "GET" + PUT = "PUT" + POST = "POST" + DELETE = "DELETE" + PATCH = "PATCH" + HEAD = "HEAD" + OPTIONS = "OPTIONS" + + Json = "application/json" + Xml = "application/xml" + Raw = "application/octet-stream" + Form = "application/x-www-form-urlencoded" + + Header = "Header" + Query = "Query" + Body = "Body" + Path = "Path" + + HeaderSeparator = "\n" +) + +// interface +type AcsRequest interface { + GetScheme() string + GetMethod() string + GetDomain() string + GetPort() string + GetRegionId() string + GetHeaders() map[string]string + GetQueryParams() map[string]string + GetFormParams() map[string]string + GetContent() []byte + GetBodyReader() io.Reader + GetStyle() string + GetProduct() string + GetVersion() string + SetVersion(version string) + GetActionName() string + GetAcceptFormat() string + GetLocationServiceCode() string + GetLocationEndpointType() string + GetReadTimeout() time.Duration + GetConnectTimeout() time.Duration + SetReadTimeout(readTimeout time.Duration) + SetConnectTimeout(connectTimeout time.Duration) + SetHTTPSInsecure(isInsecure bool) + GetHTTPSInsecure() *bool + + GetUserAgent() map[string]string + + SetStringToSign(stringToSign string) + GetStringToSign() string + + SetDomain(domain string) + SetContent(content []byte) + SetScheme(scheme string) + BuildUrl() string + BuildQueries() string + + addHeaderParam(key, value string) + addQueryParam(key, value string) + addFormParam(key, value string) + addPathParam(key, value string) +} + +// base class +type baseRequest struct { + Scheme string + Method string + Domain string + Port string + RegionId string + ReadTimeout time.Duration + ConnectTimeout time.Duration + isInsecure *bool + + userAgent map[string]string + product string + version string + + actionName string + + AcceptFormat string + + QueryParams map[string]string + Headers map[string]string + FormParams map[string]string + Content []byte + + locationServiceCode string + locationEndpointType string + + queries string + + stringToSign string +} + +func (request *baseRequest) GetQueryParams() map[string]string { + return request.QueryParams +} + +func (request *baseRequest) GetFormParams() map[string]string { + return request.FormParams +} + +func (request *baseRequest) GetReadTimeout() time.Duration { + return request.ReadTimeout +} + +func (request *baseRequest) GetConnectTimeout() time.Duration { + return request.ConnectTimeout +} + +func (request *baseRequest) SetReadTimeout(readTimeout time.Duration) { + request.ReadTimeout = readTimeout +} + +func (request *baseRequest) SetConnectTimeout(connectTimeout time.Duration) { + request.ConnectTimeout = connectTimeout +} + +func (request *baseRequest) GetHTTPSInsecure() *bool { + return request.isInsecure +} + +func (request *baseRequest) SetHTTPSInsecure(isInsecure bool) { + request.isInsecure = &isInsecure +} + +func (request *baseRequest) GetContent() []byte { + return request.Content +} + +func (request *baseRequest) SetVersion(version string) { + request.version = version +} + +func (request *baseRequest) GetVersion() string { + return request.version +} + +func (request *baseRequest) GetActionName() string { + return request.actionName +} + +func (request *baseRequest) SetContent(content []byte) { + request.Content = content +} + +func (request *baseRequest) GetUserAgent() map[string]string { + return request.userAgent +} + +func (request *baseRequest) AppendUserAgent(key, value string) { + newkey := true + if request.userAgent == nil { + request.userAgent = make(map[string]string) + } + if strings.ToLower(key) != "core" && strings.ToLower(key) != "go" { + for tag, _ := range request.userAgent { + if tag == key { + request.userAgent[tag] = value + newkey = false + } + } + if newkey { + request.userAgent[key] = value + } + } +} + +func (request *baseRequest) addHeaderParam(key, value string) { + request.Headers[key] = value +} + +func (request *baseRequest) addQueryParam(key, value string) { + request.QueryParams[key] = value +} + +func (request *baseRequest) addFormParam(key, value string) { + request.FormParams[key] = value +} + +func (request *baseRequest) GetAcceptFormat() string { + return request.AcceptFormat +} + +func (request *baseRequest) GetLocationServiceCode() string { + return request.locationServiceCode +} + +func (request *baseRequest) GetLocationEndpointType() string { + return request.locationEndpointType +} + +func (request *baseRequest) GetProduct() string { + return request.product +} + +func (request *baseRequest) GetScheme() string { + return request.Scheme +} + +func (request *baseRequest) SetScheme(scheme string) { + request.Scheme = scheme +} + +func (request *baseRequest) GetMethod() string { + return request.Method +} + +func (request *baseRequest) GetDomain() string { + return request.Domain +} + +func (request *baseRequest) SetDomain(host string) { + request.Domain = host +} + +func (request *baseRequest) GetPort() string { + return request.Port +} + +func (request *baseRequest) GetRegionId() string { + return request.RegionId +} + +func (request *baseRequest) GetHeaders() map[string]string { + return request.Headers +} + +func (request *baseRequest) SetContentType(contentType string) { + request.addHeaderParam("Content-Type", contentType) +} + +func (request *baseRequest) GetContentType() (contentType string, contains bool) { + contentType, contains = request.Headers["Content-Type"] + return +} + +func (request *baseRequest) SetStringToSign(stringToSign string) { + request.stringToSign = stringToSign +} + +func (request *baseRequest) GetStringToSign() string { + return request.stringToSign +} + +func defaultBaseRequest() (request *baseRequest) { + request = &baseRequest{ + Scheme: "", + AcceptFormat: "JSON", + Method: GET, + QueryParams: make(map[string]string), + Headers: map[string]string{ + "x-sdk-client": "golang/1.0.0", + "x-sdk-invoke-type": "normal", + "Accept-Encoding": "identity", + }, + FormParams: make(map[string]string), + } + return +} + +func InitParams(request AcsRequest) (err error) { + requestValue := reflect.ValueOf(request).Elem() + err = flatRepeatedList(requestValue, request, "", "") + return +} + +func flatRepeatedList(dataValue reflect.Value, request AcsRequest, position, prefix string) (err error) { + dataType := dataValue.Type() + for i := 0; i < dataType.NumField(); i++ { + field := dataType.Field(i) + name, containsNameTag := field.Tag.Lookup("name") + fieldPosition := position + if fieldPosition == "" { + fieldPosition, _ = field.Tag.Lookup("position") + } + typeTag, containsTypeTag := field.Tag.Lookup("type") + if containsNameTag { + if !containsTypeTag { + // simple param + key := prefix + name + value := dataValue.Field(i).String() + if dataValue.Field(i).Kind().String() == "map" { + byt, _ := json.Marshal(dataValue.Field(i).Interface()) + value = string(byt) + if value == "null" { + value = "" + } + } + err = addParam(request, fieldPosition, key, value) + if err != nil { + return + } + } else if typeTag == "Repeated" { + // repeated param + err = handleRepeatedParams(request, dataValue, prefix, name, fieldPosition, i) + if err != nil { + return + } + } else if typeTag == "Struct" { + err = handleStruct(request, dataValue, prefix, name, fieldPosition, i) + if err != nil { + return + } + } else if typeTag == "Map" { + err = handleMap(request, dataValue, prefix, name, fieldPosition, i) + if err != nil { + return err + } + } else if typeTag == "Json" { + byt, err := json.Marshal(dataValue.Field(i).Interface()) + if err != nil { + return err + } + key := prefix + name + err = addParam(request, fieldPosition, key, string(byt)) + if err != nil { + return err + } + } + } + } + return +} + +func handleRepeatedParams(request AcsRequest, dataValue reflect.Value, prefix, name, fieldPosition string, index int) (err error) { + repeatedFieldValue := dataValue.Field(index) + if repeatedFieldValue.Kind() != reflect.Slice { + // possible value: {"[]string", "*[]struct"}, we must call Elem() in the last condition + repeatedFieldValue = repeatedFieldValue.Elem() + } + if repeatedFieldValue.IsValid() && !repeatedFieldValue.IsNil() { + for m := 0; m < repeatedFieldValue.Len(); m++ { + elementValue := repeatedFieldValue.Index(m) + key := prefix + name + "." + strconv.Itoa(m+1) + if elementValue.Type().Kind().String() == "string" { + value := elementValue.String() + err = addParam(request, fieldPosition, key, value) + if err != nil { + return + } + } else { + err = flatRepeatedList(elementValue, request, fieldPosition, key+".") + if err != nil { + return + } + } + } + } + return nil +} + +func handleParam(request AcsRequest, dataValue reflect.Value, prefix, key, fieldPosition string) (err error) { + if dataValue.Type().String() == "[]string" { + if dataValue.IsNil() { + return + } + for j := 0; j < dataValue.Len(); j++ { + err = addParam(request, fieldPosition, key+"."+strconv.Itoa(j+1), dataValue.Index(j).String()) + if err != nil { + return + } + } + } else { + if dataValue.Type().Kind().String() == "string" { + value := dataValue.String() + err = addParam(request, fieldPosition, key, value) + if err != nil { + return + } + } else if dataValue.Type().Kind().String() == "struct" { + err = flatRepeatedList(dataValue, request, fieldPosition, key+".") + if err != nil { + return + } + } else if dataValue.Type().Kind().String() == "int" { + value := dataValue.Int() + err = addParam(request, fieldPosition, key, strconv.Itoa(int(value))) + if err != nil { + return err + } + } + } + return nil +} + +func handleMap(request AcsRequest, dataValue reflect.Value, prefix, name, fieldPosition string, index int) (err error) { + valueField := dataValue.Field(index) + if valueField.IsValid() && !valueField.IsNil() { + iter := valueField.MapRange() + for iter.Next() { + k := iter.Key() + v := iter.Value() + key := prefix + name + ".#" + strconv.Itoa(k.Len()) + "#" + k.String() + if v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface { + elementValue := v.Elem() + err = handleParam(request, elementValue, prefix, key, fieldPosition) + if err != nil { + return err + } + } else if v.IsValid() && v.IsNil() { + err = handleParam(request, v, prefix, key, fieldPosition) + if err != nil { + return err + } + } + } + } + return nil +} + +func handleStruct(request AcsRequest, dataValue reflect.Value, prefix, name, fieldPosition string, index int) (err error) { + valueField := dataValue.Field(index) + if valueField.IsValid() && valueField.String() != "" { + valueFieldType := valueField.Type() + for m := 0; m < valueFieldType.NumField(); m++ { + fieldName := valueFieldType.Field(m).Name + elementValue := valueField.FieldByName(fieldName) + key := prefix + name + "." + fieldName + if elementValue.Type().String() == "[]string" { + if elementValue.IsNil() { + continue + } + for j := 0; j < elementValue.Len(); j++ { + err = addParam(request, fieldPosition, key+"."+strconv.Itoa(j+1), elementValue.Index(j).String()) + if err != nil { + return + } + } + } else { + if elementValue.Type().Kind().String() == "string" { + value := elementValue.String() + err = addParam(request, fieldPosition, key, value) + if err != nil { + return + } + } else if elementValue.Type().Kind().String() == "struct" { + err = flatRepeatedList(elementValue, request, fieldPosition, key+".") + if err != nil { + return + } + } else if !elementValue.IsNil() { + repeatedFieldValue := elementValue.Elem() + if repeatedFieldValue.IsValid() && !repeatedFieldValue.IsNil() { + for m := 0; m < repeatedFieldValue.Len(); m++ { + elementValue := repeatedFieldValue.Index(m) + if elementValue.Type().Kind().String() == "string" { + value := elementValue.String() + err := addParam(request, fieldPosition, key+"."+strconv.Itoa(m+1), value) + if err != nil { + return err + } + } else { + err = flatRepeatedList(elementValue, request, fieldPosition, key+"."+strconv.Itoa(m+1)+".") + if err != nil { + return + } + } + } + } + } + } + } + } + return nil +} + +func addParam(request AcsRequest, position, name, value string) (err error) { + if len(value) > 0 { + switch position { + case Header: + request.addHeaderParam(name, value) + case Query: + request.addQueryParam(name, value) + case Path: + request.addPathParam(name, value) + case Body: + request.addFormParam(name, value) + default: + errMsg := fmt.Sprintf(errors.UnsupportedParamPositionErrorMessage, position) + err = errors.NewClientError(errors.UnsupportedParamPositionErrorCode, errMsg, nil) + } + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/common_request.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/common_request.go new file mode 100644 index 0000000000..a27f82c00a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/common_request.go @@ -0,0 +1,112 @@ +package requests + +import ( + "bytes" + "fmt" + "io" + "sort" + "strings" +) + +type CommonRequest struct { + *baseRequest + + Version string + ApiName string + Product string + ServiceCode string + EndpointType string + + // roa params + PathPattern string + PathParams map[string]string + + Ontology AcsRequest +} + +func NewCommonRequest() (request *CommonRequest) { + request = &CommonRequest{ + baseRequest: defaultBaseRequest(), + } + request.Headers["x-sdk-invoke-type"] = "common" + request.PathParams = make(map[string]string) + return +} + +func (request *CommonRequest) String() string { + request.TransToAcsRequest() + + resultBuilder := bytes.Buffer{} + + mapOutput := func(m map[string]string) { + if len(m) > 0 { + sortedKeys := make([]string, 0) + for k := range m { + sortedKeys = append(sortedKeys, k) + } + + // sort 'string' key in increasing order + sort.Strings(sortedKeys) + + for _, key := range sortedKeys { + resultBuilder.WriteString(key + ": " + m[key] + "\n") + } + } + } + + // Request Line + resultBuilder.WriteString(fmt.Sprintf("%s %s %s/1.1\n", request.Method, request.BuildQueries(), strings.ToUpper(request.Scheme))) + + // Headers + resultBuilder.WriteString("Host" + ": " + request.Domain + "\n") + mapOutput(request.Headers) + + resultBuilder.WriteString("\n") + // Body + if len(request.Content) > 0 { + resultBuilder.WriteString(string(request.Content) + "\n") + } else { + mapOutput(request.FormParams) + } + + return resultBuilder.String() +} + +func (request *CommonRequest) TransToAcsRequest() { + if len(request.PathPattern) > 0 { + roaRequest := &RoaRequest{} + roaRequest.initWithCommonRequest(request) + request.Ontology = roaRequest + } else { + rpcRequest := &RpcRequest{} + rpcRequest.baseRequest = request.baseRequest + rpcRequest.product = request.Product + rpcRequest.version = request.Version + rpcRequest.locationServiceCode = request.ServiceCode + rpcRequest.locationEndpointType = request.EndpointType + rpcRequest.actionName = request.ApiName + rpcRequest.Headers["x-acs-version"] = request.Version + rpcRequest.Headers["x-acs-action"] = request.ApiName + request.Ontology = rpcRequest + } +} + +func (request *CommonRequest) BuildUrl() string { + return request.Ontology.BuildUrl() +} + +func (request *CommonRequest) BuildQueries() string { + return request.Ontology.BuildQueries() +} + +func (request *CommonRequest) GetBodyReader() io.Reader { + return request.Ontology.GetBodyReader() +} + +func (request *CommonRequest) GetStyle() string { + return request.Ontology.GetStyle() +} + +func (request *CommonRequest) addPathParam(key, value string) { + request.PathParams[key] = value +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/roa_request.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/roa_request.go new file mode 100644 index 0000000000..4f52345b58 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/roa_request.go @@ -0,0 +1,148 @@ +/* + * 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 requests + +import ( + "bytes" + "fmt" + "io" + "net/url" + "sort" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +type RoaRequest struct { + *baseRequest + pathPattern string + PathParams map[string]string +} + +func (*RoaRequest) GetStyle() string { + return ROA +} + +func (request *RoaRequest) GetBodyReader() io.Reader { + if request.FormParams != nil && len(request.FormParams) > 0 { + formString := utils.GetUrlFormedMap(request.FormParams) + return strings.NewReader(formString) + } else if len(request.Content) > 0 { + return bytes.NewReader(request.Content) + } else { + return nil + } +} + +// for sign method, need not url encoded +func (request *RoaRequest) BuildQueries() string { + return request.buildQueries() +} + +func (request *RoaRequest) buildPath() string { + path := request.pathPattern + for key, value := range request.PathParams { + path = strings.Replace(path, "["+key+"]", value, 1) + } + return path +} + +func (request *RoaRequest) buildQueries() string { + // replace path params with value + path := request.buildPath() + queryParams := request.QueryParams + // sort QueryParams by key + var queryKeys []string + for key := range queryParams { + queryKeys = append(queryKeys, key) + } + sort.Strings(queryKeys) + + // append urlBuilder + urlBuilder := bytes.Buffer{} + urlBuilder.WriteString(path) + if len(queryKeys) > 0 { + urlBuilder.WriteString("?") + } + for i := 0; i < len(queryKeys); i++ { + queryKey := queryKeys[i] + urlBuilder.WriteString(queryKey) + if value := queryParams[queryKey]; len(value) > 0 { + urlBuilder.WriteString("=") + urlBuilder.WriteString(value) + } + if i < len(queryKeys)-1 { + urlBuilder.WriteString("&") + } + } + result := urlBuilder.String() + return result +} + +func (request *RoaRequest) buildQueryString() string { + queryParams := request.QueryParams + // sort QueryParams by key + q := url.Values{} + for key, value := range queryParams { + q.Add(key, value) + } + return q.Encode() +} + +func (request *RoaRequest) BuildUrl() string { + // for network trans, need url encoded + scheme := strings.ToLower(request.Scheme) + domain := request.Domain + port := request.Port + path := request.buildPath() + url := fmt.Sprintf("%s://%s:%s%s", scheme, domain, port, path) + querystring := request.buildQueryString() + if len(querystring) > 0 { + url = fmt.Sprintf("%s?%s", url, querystring) + } + return url +} + +func (request *RoaRequest) addPathParam(key, value string) { + request.PathParams[key] = value +} + +func (request *RoaRequest) InitWithApiInfo(product, version, action, uriPattern, serviceCode, endpointType string) { + request.baseRequest = defaultBaseRequest() + request.PathParams = make(map[string]string) + request.Headers["x-acs-version"] = version + request.Headers["x-acs-action"] = action + request.pathPattern = uriPattern + request.locationServiceCode = serviceCode + request.locationEndpointType = endpointType + request.product = product + //request.version = version + request.actionName = action +} + +func (request *RoaRequest) initWithCommonRequest(commonRequest *CommonRequest) { + request.baseRequest = commonRequest.baseRequest + request.PathParams = commonRequest.PathParams + request.product = commonRequest.Product + //request.version = commonRequest.Version + request.Headers["x-acs-version"] = commonRequest.Version + if commonRequest.ApiName != "" { + request.Headers["x-acs-action"] = commonRequest.ApiName + } + request.actionName = commonRequest.ApiName + request.pathPattern = commonRequest.PathPattern + request.locationServiceCode = commonRequest.ServiceCode + request.locationEndpointType = "" +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/rpc_request.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/rpc_request.go new file mode 100644 index 0000000000..a04765e94a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/rpc_request.go @@ -0,0 +1,81 @@ +/* + * 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 requests + +import ( + "fmt" + "io" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" +) + +type RpcRequest struct { + *baseRequest +} + +func (request *RpcRequest) init() { + request.baseRequest = defaultBaseRequest() + request.Method = POST +} + +func (*RpcRequest) GetStyle() string { + return RPC +} + +func (request *RpcRequest) GetBodyReader() io.Reader { + if request.FormParams != nil && len(request.FormParams) > 0 { + formString := utils.GetUrlFormedMap(request.FormParams) + return strings.NewReader(formString) + } else { + return strings.NewReader("") + } +} + +func (request *RpcRequest) BuildQueries() string { + request.queries = "/?" + utils.GetUrlFormedMap(request.QueryParams) + return request.queries +} + +func (request *RpcRequest) BuildUrl() string { + url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), request.Domain) + if len(request.Port) > 0 { + url = fmt.Sprintf("%s:%s", url, request.Port) + } + return url + request.BuildQueries() +} + +func (request *RpcRequest) GetVersion() string { + return request.version +} + +func (request *RpcRequest) GetActionName() string { + return request.actionName +} + +func (request *RpcRequest) addPathParam(key, value string) { + panic("not support") +} + +func (request *RpcRequest) InitWithApiInfo(product, version, action, serviceCode, endpointType string) { + request.init() + request.product = product + request.version = version + request.actionName = action + request.locationServiceCode = serviceCode + request.locationEndpointType = endpointType + request.Headers["x-acs-version"] = version + request.Headers["x-acs-action"] = action +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/types.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/types.go new file mode 100644 index 0000000000..28af63ea10 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests/types.go @@ -0,0 +1,53 @@ +package requests + +import "strconv" + +type Integer string + +func NewInteger(integer int) Integer { + return Integer(strconv.Itoa(integer)) +} + +func (integer Integer) HasValue() bool { + return integer != "" +} + +func (integer Integer) GetValue() (int, error) { + return strconv.Atoi(string(integer)) +} + +func NewInteger64(integer int64) Integer { + return Integer(strconv.FormatInt(integer, 10)) +} + +func (integer Integer) GetValue64() (int64, error) { + return strconv.ParseInt(string(integer), 10, 0) +} + +type Boolean string + +func NewBoolean(bool bool) Boolean { + return Boolean(strconv.FormatBool(bool)) +} + +func (boolean Boolean) HasValue() bool { + return boolean != "" +} + +func (boolean Boolean) GetValue() (bool, error) { + return strconv.ParseBool(string(boolean)) +} + +type Float string + +func NewFloat(f float64) Float { + return Float(strconv.FormatFloat(f, 'f', 6, 64)) +} + +func (float Float) HasValue() bool { + return float != "" +} + +func (float Float) GetValue() (float64, error) { + return strconv.ParseFloat(string(float), 64) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/json_parser.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/json_parser.go new file mode 100644 index 0000000000..cd66316d7f --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/json_parser.go @@ -0,0 +1,333 @@ +package responses + +import ( + "encoding/json" + "io" + "math" + "reflect" + "strconv" + "strings" + "unsafe" + + jsoniter "github.com/json-iterator/go" + "github.com/modern-go/reflect2" +) + +const maxUint = ^uint(0) +const maxInt = int(maxUint >> 1) +const minInt = -maxInt - 1 + +var jsonParser jsoniter.API + +func init() { + jsonParser = jsoniter.Config{ + EscapeHTML: true, + SortMapKeys: true, + ValidateJsonRawMessage: true, + CaseSensitive: true, + }.Froze() + + jsonParser.RegisterExtension(newBetterFuzzyExtension()) +} + +func newBetterFuzzyExtension() jsoniter.DecoderExtension { + return jsoniter.DecoderExtension{ + reflect2.DefaultTypeOfKind(reflect.String): &nullableFuzzyStringDecoder{}, + reflect2.DefaultTypeOfKind(reflect.Bool): &fuzzyBoolDecoder{}, + reflect2.DefaultTypeOfKind(reflect.Float32): &nullableFuzzyFloat32Decoder{}, + reflect2.DefaultTypeOfKind(reflect.Float64): &nullableFuzzyFloat64Decoder{}, + reflect2.DefaultTypeOfKind(reflect.Int): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(maxInt) || val < float64(minInt) { + iter.ReportError("fuzzy decode int", "exceed range") + return + } + *((*int)(ptr)) = int(val) + } else { + *((*int)(ptr)) = iter.ReadInt() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Uint): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(maxUint) || val < 0 { + iter.ReportError("fuzzy decode uint", "exceed range") + return + } + *((*uint)(ptr)) = uint(val) + } else { + *((*uint)(ptr)) = iter.ReadUint() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Int8): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxInt8) || val < float64(math.MinInt8) { + iter.ReportError("fuzzy decode int8", "exceed range") + return + } + *((*int8)(ptr)) = int8(val) + } else { + *((*int8)(ptr)) = iter.ReadInt8() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Uint8): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxUint8) || val < 0 { + iter.ReportError("fuzzy decode uint8", "exceed range") + return + } + *((*uint8)(ptr)) = uint8(val) + } else { + *((*uint8)(ptr)) = iter.ReadUint8() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Int16): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxInt16) || val < float64(math.MinInt16) { + iter.ReportError("fuzzy decode int16", "exceed range") + return + } + *((*int16)(ptr)) = int16(val) + } else { + *((*int16)(ptr)) = iter.ReadInt16() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Uint16): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxUint16) || val < 0 { + iter.ReportError("fuzzy decode uint16", "exceed range") + return + } + *((*uint16)(ptr)) = uint16(val) + } else { + *((*uint16)(ptr)) = iter.ReadUint16() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Int32): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxInt32) || val < float64(math.MinInt32) { + iter.ReportError("fuzzy decode int32", "exceed range") + return + } + *((*int32)(ptr)) = int32(val) + } else { + *((*int32)(ptr)) = iter.ReadInt32() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Uint32): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxUint32) || val < 0 { + iter.ReportError("fuzzy decode uint32", "exceed range") + return + } + *((*uint32)(ptr)) = uint32(val) + } else { + *((*uint32)(ptr)) = iter.ReadUint32() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Int64): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxInt64) || val < float64(math.MinInt64) { + iter.ReportError("fuzzy decode int64", "exceed range") + return + } + *((*int64)(ptr)) = int64(val) + } else { + *((*int64)(ptr)) = iter.ReadInt64() + } + }}, + reflect2.DefaultTypeOfKind(reflect.Uint64): &nullableFuzzyIntegerDecoder{func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) { + if isFloat { + val := iter.ReadFloat64() + if val > float64(math.MaxUint64) || val < 0 { + iter.ReportError("fuzzy decode uint64", "exceed range") + return + } + *((*uint64)(ptr)) = uint64(val) + } else { + *((*uint64)(ptr)) = iter.ReadUint64() + } + }}, + } +} + +type nullableFuzzyStringDecoder struct { +} + +func (decoder *nullableFuzzyStringDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { + valueType := iter.WhatIsNext() + switch valueType { + case jsoniter.NumberValue: + var number json.Number + iter.ReadVal(&number) + *((*string)(ptr)) = string(number) + case jsoniter.StringValue: + *((*string)(ptr)) = iter.ReadString() + case jsoniter.BoolValue: + *((*string)(ptr)) = strconv.FormatBool(iter.ReadBool()) + case jsoniter.NilValue: + iter.ReadNil() + *((*string)(ptr)) = "" + default: + iter.ReportError("fuzzyStringDecoder", "not number or string or bool") + } +} + +type fuzzyBoolDecoder struct { +} + +func (decoder *fuzzyBoolDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { + valueType := iter.WhatIsNext() + switch valueType { + case jsoniter.BoolValue: + *((*bool)(ptr)) = iter.ReadBool() + case jsoniter.NumberValue: + var number json.Number + iter.ReadVal(&number) + num, err := number.Int64() + if err != nil { + iter.ReportError("fuzzyBoolDecoder", "get value from json.number failed") + } + if num == 0 { + *((*bool)(ptr)) = false + } else { + *((*bool)(ptr)) = true + } + case jsoniter.StringValue: + strValue := strings.ToLower(iter.ReadString()) + if strValue == "true" { + *((*bool)(ptr)) = true + } else if strValue == "false" || strValue == "" { + *((*bool)(ptr)) = false + } else { + iter.ReportError("fuzzyBoolDecoder", "unsupported bool value: "+strValue) + } + case jsoniter.NilValue: + iter.ReadNil() + *((*bool)(ptr)) = false + default: + iter.ReportError("fuzzyBoolDecoder", "not number or string or nil") + } +} + +type nullableFuzzyIntegerDecoder struct { + fun func(isFloat bool, ptr unsafe.Pointer, iter *jsoniter.Iterator) +} + +func (decoder *nullableFuzzyIntegerDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { + valueType := iter.WhatIsNext() + var str string + switch valueType { + case jsoniter.NumberValue: + var number json.Number + iter.ReadVal(&number) + str = string(number) + case jsoniter.StringValue: + str = iter.ReadString() + // support empty string + if str == "" { + str = "0" + } + case jsoniter.BoolValue: + if iter.ReadBool() { + str = "1" + } else { + str = "0" + } + case jsoniter.NilValue: + iter.ReadNil() + str = "0" + default: + iter.ReportError("fuzzyIntegerDecoder", "not number or string") + } + newIter := iter.Pool().BorrowIterator([]byte(str)) + defer iter.Pool().ReturnIterator(newIter) + isFloat := strings.IndexByte(str, '.') != -1 + decoder.fun(isFloat, ptr, newIter) + if newIter.Error != nil && newIter.Error != io.EOF { + iter.Error = newIter.Error + } +} + +type nullableFuzzyFloat32Decoder struct { +} + +func (decoder *nullableFuzzyFloat32Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { + valueType := iter.WhatIsNext() + var str string + switch valueType { + case jsoniter.NumberValue: + *((*float32)(ptr)) = iter.ReadFloat32() + case jsoniter.StringValue: + str = iter.ReadString() + // support empty string + if str == "" { + *((*float32)(ptr)) = 0 + return + } + newIter := iter.Pool().BorrowIterator([]byte(str)) + defer iter.Pool().ReturnIterator(newIter) + *((*float32)(ptr)) = newIter.ReadFloat32() + if newIter.Error != nil && newIter.Error != io.EOF { + iter.Error = newIter.Error + } + case jsoniter.BoolValue: + // support bool to float32 + if iter.ReadBool() { + *((*float32)(ptr)) = 1 + } else { + *((*float32)(ptr)) = 0 + } + case jsoniter.NilValue: + iter.ReadNil() + *((*float32)(ptr)) = 0 + default: + iter.ReportError("nullableFuzzyFloat32Decoder", "not number or string") + } +} + +type nullableFuzzyFloat64Decoder struct { +} + +func (decoder *nullableFuzzyFloat64Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) { + valueType := iter.WhatIsNext() + var str string + switch valueType { + case jsoniter.NumberValue: + *((*float64)(ptr)) = iter.ReadFloat64() + case jsoniter.StringValue: + str = iter.ReadString() + // support empty string + if str == "" { + *((*float64)(ptr)) = 0 + return + } + newIter := iter.Pool().BorrowIterator([]byte(str)) + defer iter.Pool().ReturnIterator(newIter) + *((*float64)(ptr)) = newIter.ReadFloat64() + if newIter.Error != nil && newIter.Error != io.EOF { + iter.Error = newIter.Error + } + case jsoniter.BoolValue: + // support bool to float64 + if iter.ReadBool() { + *((*float64)(ptr)) = 1 + } else { + *((*float64)(ptr)) = 0 + } + case jsoniter.NilValue: + // support empty string + iter.ReadNil() + *((*float64)(ptr)) = 0 + default: + iter.ReportError("nullableFuzzyFloat64Decoder", "not number or string") + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/response.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/response.go new file mode 100644 index 0000000000..53a156b71a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses/response.go @@ -0,0 +1,144 @@ +/* + * 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 responses + +import ( + "bytes" + "encoding/xml" + "fmt" + "io/ioutil" + "net/http" + "strings" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" +) + +type AcsResponse interface { + IsSuccess() bool + GetHttpStatus() int + GetHttpHeaders() map[string][]string + GetHttpContentString() string + GetHttpContentBytes() []byte + GetOriginHttpResponse() *http.Response + parseFromHttpResponse(httpResponse *http.Response) error +} + +// Unmarshal object from http response body to target Response +func Unmarshal(response AcsResponse, httpResponse *http.Response, format string) (err error) { + err = response.parseFromHttpResponse(httpResponse) + if err != nil { + return + } + if !response.IsSuccess() { + err = errors.NewServerError(response.GetHttpStatus(), response.GetHttpContentString(), "") + return + } + + if _, isCommonResponse := response.(*CommonResponse); isCommonResponse { + // common response need not unmarshal + return + } + + if len(response.GetHttpContentBytes()) == 0 { + return + } + + if strings.ToUpper(format) == "JSON" { + err = jsonParser.Unmarshal(response.GetHttpContentBytes(), response) + if err != nil { + err = errors.NewClientError(errors.JsonUnmarshalErrorCode, errors.JsonUnmarshalErrorMessage, err) + } + } else if strings.ToUpper(format) == "XML" { + err = xml.Unmarshal(response.GetHttpContentBytes(), response) + } + return +} + +type BaseResponse struct { + httpStatus int + httpHeaders map[string][]string + httpContentString string + httpContentBytes []byte + originHttpResponse *http.Response +} + +func (baseResponse *BaseResponse) GetHttpStatus() int { + return baseResponse.httpStatus +} + +func (baseResponse *BaseResponse) GetHttpHeaders() map[string][]string { + return baseResponse.httpHeaders +} + +func (baseResponse *BaseResponse) GetHttpContentString() string { + return baseResponse.httpContentString +} + +func (baseResponse *BaseResponse) GetHttpContentBytes() []byte { + return baseResponse.httpContentBytes +} + +func (baseResponse *BaseResponse) GetOriginHttpResponse() *http.Response { + return baseResponse.originHttpResponse +} + +func (baseResponse *BaseResponse) IsSuccess() bool { + if baseResponse.GetHttpStatus() >= 200 && baseResponse.GetHttpStatus() < 300 { + return true + } + + return false +} + +func (baseResponse *BaseResponse) parseFromHttpResponse(httpResponse *http.Response) (err error) { + defer httpResponse.Body.Close() + body, err := ioutil.ReadAll(httpResponse.Body) + if err != nil { + return + } + baseResponse.httpStatus = httpResponse.StatusCode + baseResponse.httpHeaders = httpResponse.Header + baseResponse.httpContentBytes = body + baseResponse.httpContentString = string(body) + baseResponse.originHttpResponse = httpResponse + return +} + +func (baseResponse *BaseResponse) String() string { + resultBuilder := bytes.Buffer{} + // statusCode + // resultBuilder.WriteString("\n") + resultBuilder.WriteString(fmt.Sprintf("%s %s\n", baseResponse.originHttpResponse.Proto, baseResponse.originHttpResponse.Status)) + // httpHeaders + //resultBuilder.WriteString("Headers:\n") + for key, value := range baseResponse.httpHeaders { + resultBuilder.WriteString(key + ": " + strings.Join(value, ";") + "\n") + } + resultBuilder.WriteString("\n") + // content + //resultBuilder.WriteString("Content:\n") + resultBuilder.WriteString(baseResponse.httpContentString + "\n") + return resultBuilder.String() +} + +type CommonResponse struct { + *BaseResponse +} + +func NewCommonResponse() (response *CommonResponse) { + return &CommonResponse{ + BaseResponse: &BaseResponse{}, + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/debug.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/debug.go new file mode 100644 index 0000000000..09440d27be --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/debug.go @@ -0,0 +1,36 @@ +package utils + +import ( + "fmt" + "os" + "strings" +) + +type Debug func(format string, v ...interface{}) + +var hookGetEnv = func() string { + return os.Getenv("DEBUG") +} + +var hookPrint = func(input string) { + fmt.Println(input) +} + +func Init(flag string) Debug { + enable := false + + env := hookGetEnv() + parts := strings.Split(env, ",") + for _, part := range parts { + if part == flag { + enable = true + break + } + } + + return func(format string, v ...interface{}) { + if enable { + hookPrint(fmt.Sprintf(format, v...)) + } + } +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/utils.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/utils.go new file mode 100644 index 0000000000..f8a3ad3840 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils/utils.go @@ -0,0 +1,141 @@ +/* + * 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 utils + +import ( + "crypto/md5" + "crypto/rand" + "encoding/base64" + "encoding/hex" + "hash" + rand2 "math/rand" + "net/url" + "reflect" + "strconv" + "time" +) + +type UUID [16]byte + +const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +func GetUUID() (uuidHex string) { + uuid := NewUUID() + uuidHex = hex.EncodeToString(uuid[:]) + return +} + +func RandStringBytes(n int) string { + b := make([]byte, n) + for i := range b { + b[i] = letterBytes[rand2.Intn(len(letterBytes))] + } + return string(b) +} + +func GetMD5Base64(bytes []byte) (base64Value string) { + md5Ctx := md5.New() + md5Ctx.Write(bytes) + md5Value := md5Ctx.Sum(nil) + base64Value = base64.StdEncoding.EncodeToString(md5Value) + return +} + +func GetTimeInFormatISO8601() (timeStr string) { + gmt := time.FixedZone("GMT", 0) + + return time.Now().In(gmt).Format("2006-01-02T15:04:05Z") +} + +func GetTimeInFormatRFC2616() (timeStr string) { + gmt := time.FixedZone("GMT", 0) + + return time.Now().In(gmt).Format("Mon, 02 Jan 2006 15:04:05 GMT") +} + +func GetUrlFormedMap(source map[string]string) (urlEncoded string) { + urlEncoder := url.Values{} + for key, value := range source { + urlEncoder.Add(key, value) + } + urlEncoded = urlEncoder.Encode() + return +} + +func InitStructWithDefaultTag(bean interface{}) { + configType := reflect.TypeOf(bean) + for i := 0; i < configType.Elem().NumField(); i++ { + field := configType.Elem().Field(i) + defaultValue := field.Tag.Get("default") + if defaultValue == "" { + continue + } + setter := reflect.ValueOf(bean).Elem().Field(i) + switch field.Type.String() { + case "int": + intValue, _ := strconv.ParseInt(defaultValue, 10, 64) + setter.SetInt(intValue) + case "time.Duration": + intValue, _ := strconv.ParseInt(defaultValue, 10, 64) + setter.SetInt(intValue) + case "string": + setter.SetString(defaultValue) + case "bool": + boolValue, _ := strconv.ParseBool(defaultValue) + setter.SetBool(boolValue) + } + } +} + +func NewUUID() UUID { + ns := UUID{} + safeRandom(ns[:]) + u := newFromHash(md5.New(), ns, RandStringBytes(16)) + u[6] = (u[6] & 0x0f) | (byte(2) << 4) + u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) + + return u +} + +func newFromHash(h hash.Hash, ns UUID, name string) UUID { + u := UUID{} + h.Write(ns[:]) + h.Write([]byte(name)) + copy(u[:], h.Sum(nil)) + + return u +} + +func safeRandom(dest []byte) { + if _, err := rand.Read(dest); err != nil { + panic(err) + } +} + +func (u UUID) String() string { + buf := make([]byte, 36) + + hex.Encode(buf[0:8], u[0:4]) + buf[8] = '-' + hex.Encode(buf[9:13], u[4:6]) + buf[13] = '-' + hex.Encode(buf[14:18], u[6:8]) + buf[18] = '-' + hex.Encode(buf[19:23], u[8:10]) + buf[23] = '-' + hex.Encode(buf[24:], u[10:]) + + return string(buf) +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/add_user_to_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/add_user_to_group.go new file mode 100644 index 0000000000..1cde5e58c9 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/add_user_to_group.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// AddUserToGroup invokes the ram.AddUserToGroup API synchronously +// api document: https://help.aliyun.com/api/ram/addusertogroup.html +func (client *Client) AddUserToGroup(request *AddUserToGroupRequest) (response *AddUserToGroupResponse, err error) { + response = CreateAddUserToGroupResponse() + err = client.DoAction(request, response) + return +} + +// AddUserToGroupWithChan invokes the ram.AddUserToGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/addusertogroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AddUserToGroupWithChan(request *AddUserToGroupRequest) (<-chan *AddUserToGroupResponse, <-chan error) { + responseChan := make(chan *AddUserToGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.AddUserToGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// AddUserToGroupWithCallback invokes the ram.AddUserToGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/addusertogroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AddUserToGroupWithCallback(request *AddUserToGroupRequest, callback func(response *AddUserToGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *AddUserToGroupResponse + var err error + defer close(result) + response, err = client.AddUserToGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// AddUserToGroupRequest is the request struct for api AddUserToGroup +type AddUserToGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` + UserName string `position:"Query" name:"UserName"` +} + +// AddUserToGroupResponse is the response struct for api AddUserToGroup +type AddUserToGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateAddUserToGroupRequest creates a request to invoke AddUserToGroup API +func CreateAddUserToGroupRequest() (request *AddUserToGroupRequest) { + request = &AddUserToGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "AddUserToGroup", "Ram", "openAPI") + return +} + +// CreateAddUserToGroupResponse creates a response to parse from AddUserToGroup response +func CreateAddUserToGroupResponse() (response *AddUserToGroupResponse) { + response = &AddUserToGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_group.go new file mode 100644 index 0000000000..e8cb8b3f17 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_group.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// AttachPolicyToGroup invokes the ram.AttachPolicyToGroup API synchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytogroup.html +func (client *Client) AttachPolicyToGroup(request *AttachPolicyToGroupRequest) (response *AttachPolicyToGroupResponse, err error) { + response = CreateAttachPolicyToGroupResponse() + err = client.DoAction(request, response) + return +} + +// AttachPolicyToGroupWithChan invokes the ram.AttachPolicyToGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytogroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToGroupWithChan(request *AttachPolicyToGroupRequest) (<-chan *AttachPolicyToGroupResponse, <-chan error) { + responseChan := make(chan *AttachPolicyToGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.AttachPolicyToGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// AttachPolicyToGroupWithCallback invokes the ram.AttachPolicyToGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytogroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToGroupWithCallback(request *AttachPolicyToGroupRequest, callback func(response *AttachPolicyToGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *AttachPolicyToGroupResponse + var err error + defer close(result) + response, err = client.AttachPolicyToGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// AttachPolicyToGroupRequest is the request struct for api AttachPolicyToGroup +type AttachPolicyToGroupRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + GroupName string `position:"Query" name:"GroupName"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// AttachPolicyToGroupResponse is the response struct for api AttachPolicyToGroup +type AttachPolicyToGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateAttachPolicyToGroupRequest creates a request to invoke AttachPolicyToGroup API +func CreateAttachPolicyToGroupRequest() (request *AttachPolicyToGroupRequest) { + request = &AttachPolicyToGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "AttachPolicyToGroup", "Ram", "openAPI") + return +} + +// CreateAttachPolicyToGroupResponse creates a response to parse from AttachPolicyToGroup response +func CreateAttachPolicyToGroupResponse() (response *AttachPolicyToGroupResponse) { + response = &AttachPolicyToGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_role.go new file mode 100644 index 0000000000..a682b9f09c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_role.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// AttachPolicyToRole invokes the ram.AttachPolicyToRole API synchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytorole.html +func (client *Client) AttachPolicyToRole(request *AttachPolicyToRoleRequest) (response *AttachPolicyToRoleResponse, err error) { + response = CreateAttachPolicyToRoleResponse() + err = client.DoAction(request, response) + return +} + +// AttachPolicyToRoleWithChan invokes the ram.AttachPolicyToRole API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytorole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToRoleWithChan(request *AttachPolicyToRoleRequest) (<-chan *AttachPolicyToRoleResponse, <-chan error) { + responseChan := make(chan *AttachPolicyToRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.AttachPolicyToRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// AttachPolicyToRoleWithCallback invokes the ram.AttachPolicyToRole API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytorole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToRoleWithCallback(request *AttachPolicyToRoleRequest, callback func(response *AttachPolicyToRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *AttachPolicyToRoleResponse + var err error + defer close(result) + response, err = client.AttachPolicyToRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// AttachPolicyToRoleRequest is the request struct for api AttachPolicyToRole +type AttachPolicyToRoleRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + RoleName string `position:"Query" name:"RoleName"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// AttachPolicyToRoleResponse is the response struct for api AttachPolicyToRole +type AttachPolicyToRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateAttachPolicyToRoleRequest creates a request to invoke AttachPolicyToRole API +func CreateAttachPolicyToRoleRequest() (request *AttachPolicyToRoleRequest) { + request = &AttachPolicyToRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "AttachPolicyToRole", "Ram", "openAPI") + return +} + +// CreateAttachPolicyToRoleResponse creates a response to parse from AttachPolicyToRole response +func CreateAttachPolicyToRoleResponse() (response *AttachPolicyToRoleResponse) { + response = &AttachPolicyToRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_user.go new file mode 100644 index 0000000000..e0af9a48f6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/attach_policy_to_user.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// AttachPolicyToUser invokes the ram.AttachPolicyToUser API synchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytouser.html +func (client *Client) AttachPolicyToUser(request *AttachPolicyToUserRequest) (response *AttachPolicyToUserResponse, err error) { + response = CreateAttachPolicyToUserResponse() + err = client.DoAction(request, response) + return +} + +// AttachPolicyToUserWithChan invokes the ram.AttachPolicyToUser API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytouser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToUserWithChan(request *AttachPolicyToUserRequest) (<-chan *AttachPolicyToUserResponse, <-chan error) { + responseChan := make(chan *AttachPolicyToUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.AttachPolicyToUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// AttachPolicyToUserWithCallback invokes the ram.AttachPolicyToUser API asynchronously +// api document: https://help.aliyun.com/api/ram/attachpolicytouser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) AttachPolicyToUserWithCallback(request *AttachPolicyToUserRequest, callback func(response *AttachPolicyToUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *AttachPolicyToUserResponse + var err error + defer close(result) + response, err = client.AttachPolicyToUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// AttachPolicyToUserRequest is the request struct for api AttachPolicyToUser +type AttachPolicyToUserRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + PolicyName string `position:"Query" name:"PolicyName"` + UserName string `position:"Query" name:"UserName"` +} + +// AttachPolicyToUserResponse is the response struct for api AttachPolicyToUser +type AttachPolicyToUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateAttachPolicyToUserRequest creates a request to invoke AttachPolicyToUser API +func CreateAttachPolicyToUserRequest() (request *AttachPolicyToUserRequest) { + request = &AttachPolicyToUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "AttachPolicyToUser", "Ram", "openAPI") + return +} + +// CreateAttachPolicyToUserResponse creates a response to parse from AttachPolicyToUser response +func CreateAttachPolicyToUserResponse() (response *AttachPolicyToUserResponse) { + response = &AttachPolicyToUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/bind_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/bind_mfa_device.go new file mode 100644 index 0000000000..0ba2948698 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/bind_mfa_device.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// BindMFADevice invokes the ram.BindMFADevice API synchronously +// api document: https://help.aliyun.com/api/ram/bindmfadevice.html +func (client *Client) BindMFADevice(request *BindMFADeviceRequest) (response *BindMFADeviceResponse, err error) { + response = CreateBindMFADeviceResponse() + err = client.DoAction(request, response) + return +} + +// BindMFADeviceWithChan invokes the ram.BindMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/bindmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) BindMFADeviceWithChan(request *BindMFADeviceRequest) (<-chan *BindMFADeviceResponse, <-chan error) { + responseChan := make(chan *BindMFADeviceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.BindMFADevice(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// BindMFADeviceWithCallback invokes the ram.BindMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/bindmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) BindMFADeviceWithCallback(request *BindMFADeviceRequest, callback func(response *BindMFADeviceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *BindMFADeviceResponse + var err error + defer close(result) + response, err = client.BindMFADevice(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// BindMFADeviceRequest is the request struct for api BindMFADevice +type BindMFADeviceRequest struct { + *requests.RpcRequest + SerialNumber string `position:"Query" name:"SerialNumber"` + AuthenticationCode2 string `position:"Query" name:"AuthenticationCode2"` + AuthenticationCode1 string `position:"Query" name:"AuthenticationCode1"` + UserName string `position:"Query" name:"UserName"` +} + +// BindMFADeviceResponse is the response struct for api BindMFADevice +type BindMFADeviceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateBindMFADeviceRequest creates a request to invoke BindMFADevice API +func CreateBindMFADeviceRequest() (request *BindMFADeviceRequest) { + request = &BindMFADeviceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "BindMFADevice", "Ram", "openAPI") + return +} + +// CreateBindMFADeviceResponse creates a response to parse from BindMFADevice response +func CreateBindMFADeviceResponse() (response *BindMFADeviceResponse) { + response = &BindMFADeviceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/change_password.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/change_password.go new file mode 100644 index 0000000000..72b755fc4a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/change_password.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ChangePassword invokes the ram.ChangePassword API synchronously +// api document: https://help.aliyun.com/api/ram/changepassword.html +func (client *Client) ChangePassword(request *ChangePasswordRequest) (response *ChangePasswordResponse, err error) { + response = CreateChangePasswordResponse() + err = client.DoAction(request, response) + return +} + +// ChangePasswordWithChan invokes the ram.ChangePassword API asynchronously +// api document: https://help.aliyun.com/api/ram/changepassword.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ChangePasswordWithChan(request *ChangePasswordRequest) (<-chan *ChangePasswordResponse, <-chan error) { + responseChan := make(chan *ChangePasswordResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ChangePassword(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ChangePasswordWithCallback invokes the ram.ChangePassword API asynchronously +// api document: https://help.aliyun.com/api/ram/changepassword.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ChangePasswordWithCallback(request *ChangePasswordRequest, callback func(response *ChangePasswordResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ChangePasswordResponse + var err error + defer close(result) + response, err = client.ChangePassword(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ChangePasswordRequest is the request struct for api ChangePassword +type ChangePasswordRequest struct { + *requests.RpcRequest + OldPassword string `position:"Query" name:"OldPassword"` + NewPassword string `position:"Query" name:"NewPassword"` +} + +// ChangePasswordResponse is the response struct for api ChangePassword +type ChangePasswordResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateChangePasswordRequest creates a request to invoke ChangePassword API +func CreateChangePasswordRequest() (request *ChangePasswordRequest) { + request = &ChangePasswordRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ChangePassword", "Ram", "openAPI") + return +} + +// CreateChangePasswordResponse creates a response to parse from ChangePassword response +func CreateChangePasswordResponse() (response *ChangePasswordResponse) { + response = &ChangePasswordResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/clear_account_alias.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/clear_account_alias.go new file mode 100644 index 0000000000..44455ec51e --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/clear_account_alias.go @@ -0,0 +1,102 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ClearAccountAlias invokes the ram.ClearAccountAlias API synchronously +// api document: https://help.aliyun.com/api/ram/clearaccountalias.html +func (client *Client) ClearAccountAlias(request *ClearAccountAliasRequest) (response *ClearAccountAliasResponse, err error) { + response = CreateClearAccountAliasResponse() + err = client.DoAction(request, response) + return +} + +// ClearAccountAliasWithChan invokes the ram.ClearAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/clearaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ClearAccountAliasWithChan(request *ClearAccountAliasRequest) (<-chan *ClearAccountAliasResponse, <-chan error) { + responseChan := make(chan *ClearAccountAliasResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ClearAccountAlias(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ClearAccountAliasWithCallback invokes the ram.ClearAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/clearaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ClearAccountAliasWithCallback(request *ClearAccountAliasRequest, callback func(response *ClearAccountAliasResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ClearAccountAliasResponse + var err error + defer close(result) + response, err = client.ClearAccountAlias(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ClearAccountAliasRequest is the request struct for api ClearAccountAlias +type ClearAccountAliasRequest struct { + *requests.RpcRequest +} + +// ClearAccountAliasResponse is the response struct for api ClearAccountAlias +type ClearAccountAliasResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateClearAccountAliasRequest creates a request to invoke ClearAccountAlias API +func CreateClearAccountAliasRequest() (request *ClearAccountAliasRequest) { + request = &ClearAccountAliasRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ClearAccountAlias", "Ram", "openAPI") + return +} + +// CreateClearAccountAliasResponse creates a response to parse from ClearAccountAlias response +func CreateClearAccountAliasResponse() (response *ClearAccountAliasResponse) { + response = &ClearAccountAliasResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/client.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/client.go new file mode 100644 index 0000000000..4ae36a031c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/client.go @@ -0,0 +1,129 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "reflect" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider" +) + +// Client is the sdk client struct, each func corresponds to an OpenAPI +type Client struct { + sdk.Client +} + +// SetClientProperty Set Property by Reflect +func SetClientProperty(client *Client, propertyName string, propertyValue interface{}) { + v := reflect.ValueOf(client).Elem() + if v.FieldByName(propertyName).IsValid() && v.FieldByName(propertyName).CanSet() { + v.FieldByName(propertyName).Set(reflect.ValueOf(propertyValue)) + } +} + +// SetEndpointDataToClient Set EndpointMap and ENdpointType +func SetEndpointDataToClient(client *Client) { + SetClientProperty(client, "EndpointMap", GetEndpointMap()) + SetClientProperty(client, "EndpointType", GetEndpointType()) +} + +// NewClient creates a sdk client with environment variables +func NewClient() (client *Client, err error) { + client = &Client{} + err = client.Init() + SetEndpointDataToClient(client) + return +} + +// NewClientWithProvider creates a sdk client with providers +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) { + client = &Client{} + var pc provider.Provider + if len(providers) == 0 { + pc = provider.DefaultChain + } else { + pc = provider.NewProviderChain(providers) + } + err = client.InitWithProviderChain(regionId, pc) + SetEndpointDataToClient(client) + return +} + +// NewClientWithOptions creates a sdk client with regionId/sdkConfig/credential +// this is the common api to create a sdk client +func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) { + client = &Client{} + err = client.InitWithOptions(regionId, config, credential) + SetEndpointDataToClient(client) + return +} + +// NewClientWithAccessKey is a shortcut to create sdk client with accesskey +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) { + client = &Client{} + err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret) + SetEndpointDataToClient(client) + return +} + +// NewClientWithStsToken is a shortcut to create sdk client with sts token +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) { + client = &Client{} + err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken) + SetEndpointDataToClient(client) + return +} + +// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) { + client = &Client{} + err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName) + SetEndpointDataToClient(client) + return +} + +// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn and policy +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) { + client = &Client{} + err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy) + SetEndpointDataToClient(client) + return +} + +// NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) { + client = &Client{} + err = client.InitWithEcsRamRole(regionId, roleName) + SetEndpointDataToClient(client) + return +} + +// NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair +// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md +func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) { + client = &Client{} + err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration) + SetEndpointDataToClient(client) + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_access_key.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_access_key.go new file mode 100644 index 0000000000..10619e37f3 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_access_key.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateAccessKey invokes the ram.CreateAccessKey API synchronously +// api document: https://help.aliyun.com/api/ram/createaccesskey.html +func (client *Client) CreateAccessKey(request *CreateAccessKeyRequest) (response *CreateAccessKeyResponse, err error) { + response = CreateCreateAccessKeyResponse() + err = client.DoAction(request, response) + return +} + +// CreateAccessKeyWithChan invokes the ram.CreateAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/createaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateAccessKeyWithChan(request *CreateAccessKeyRequest) (<-chan *CreateAccessKeyResponse, <-chan error) { + responseChan := make(chan *CreateAccessKeyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateAccessKey(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateAccessKeyWithCallback invokes the ram.CreateAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/createaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateAccessKeyWithCallback(request *CreateAccessKeyRequest, callback func(response *CreateAccessKeyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateAccessKeyResponse + var err error + defer close(result) + response, err = client.CreateAccessKey(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateAccessKeyRequest is the request struct for api CreateAccessKey +type CreateAccessKeyRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// CreateAccessKeyResponse is the response struct for api CreateAccessKey +type CreateAccessKeyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + AccessKey AccessKeyInCreateAccessKey `json:"AccessKey" xml:"AccessKey"` +} + +// CreateCreateAccessKeyRequest creates a request to invoke CreateAccessKey API +func CreateCreateAccessKeyRequest() (request *CreateAccessKeyRequest) { + request = &CreateAccessKeyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateAccessKey", "Ram", "openAPI") + return +} + +// CreateCreateAccessKeyResponse creates a response to parse from CreateAccessKey response +func CreateCreateAccessKeyResponse() (response *CreateAccessKeyResponse) { + response = &CreateAccessKeyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_group.go new file mode 100644 index 0000000000..e7ad2eaa59 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_group.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateGroup invokes the ram.CreateGroup API synchronously +// api document: https://help.aliyun.com/api/ram/creategroup.html +func (client *Client) CreateGroup(request *CreateGroupRequest) (response *CreateGroupResponse, err error) { + response = CreateCreateGroupResponse() + err = client.DoAction(request, response) + return +} + +// CreateGroupWithChan invokes the ram.CreateGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/creategroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateGroupWithChan(request *CreateGroupRequest) (<-chan *CreateGroupResponse, <-chan error) { + responseChan := make(chan *CreateGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateGroupWithCallback invokes the ram.CreateGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/creategroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateGroupWithCallback(request *CreateGroupRequest, callback func(response *CreateGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateGroupResponse + var err error + defer close(result) + response, err = client.CreateGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateGroupRequest is the request struct for api CreateGroup +type CreateGroupRequest struct { + *requests.RpcRequest + Comments string `position:"Query" name:"Comments"` + GroupName string `position:"Query" name:"GroupName"` +} + +// CreateGroupResponse is the response struct for api CreateGroup +type CreateGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Group GroupInCreateGroup `json:"Group" xml:"Group"` +} + +// CreateCreateGroupRequest creates a request to invoke CreateGroup API +func CreateCreateGroupRequest() (request *CreateGroupRequest) { + request = &CreateGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateGroup", "Ram", "openAPI") + return +} + +// CreateCreateGroupResponse creates a response to parse from CreateGroup response +func CreateCreateGroupResponse() (response *CreateGroupResponse) { + response = &CreateGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_login_profile.go new file mode 100644 index 0000000000..baff7bbcef --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_login_profile.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateLoginProfile invokes the ram.CreateLoginProfile API synchronously +// api document: https://help.aliyun.com/api/ram/createloginprofile.html +func (client *Client) CreateLoginProfile(request *CreateLoginProfileRequest) (response *CreateLoginProfileResponse, err error) { + response = CreateCreateLoginProfileResponse() + err = client.DoAction(request, response) + return +} + +// CreateLoginProfileWithChan invokes the ram.CreateLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/createloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateLoginProfileWithChan(request *CreateLoginProfileRequest) (<-chan *CreateLoginProfileResponse, <-chan error) { + responseChan := make(chan *CreateLoginProfileResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateLoginProfile(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateLoginProfileWithCallback invokes the ram.CreateLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/createloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateLoginProfileWithCallback(request *CreateLoginProfileRequest, callback func(response *CreateLoginProfileResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateLoginProfileResponse + var err error + defer close(result) + response, err = client.CreateLoginProfile(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateLoginProfileRequest is the request struct for api CreateLoginProfile +type CreateLoginProfileRequest struct { + *requests.RpcRequest + PasswordResetRequired requests.Boolean `position:"Query" name:"PasswordResetRequired"` + Password string `position:"Query" name:"Password"` + MFABindRequired requests.Boolean `position:"Query" name:"MFABindRequired"` + UserName string `position:"Query" name:"UserName"` +} + +// CreateLoginProfileResponse is the response struct for api CreateLoginProfile +type CreateLoginProfileResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + LoginProfile LoginProfileInCreateLoginProfile `json:"LoginProfile" xml:"LoginProfile"` +} + +// CreateCreateLoginProfileRequest creates a request to invoke CreateLoginProfile API +func CreateCreateLoginProfileRequest() (request *CreateLoginProfileRequest) { + request = &CreateLoginProfileRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateLoginProfile", "Ram", "openAPI") + return +} + +// CreateCreateLoginProfileResponse creates a response to parse from CreateLoginProfile response +func CreateCreateLoginProfileResponse() (response *CreateLoginProfileResponse) { + response = &CreateLoginProfileResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy.go new file mode 100644 index 0000000000..cbd479c7a3 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreatePolicy invokes the ram.CreatePolicy API synchronously +// api document: https://help.aliyun.com/api/ram/createpolicy.html +func (client *Client) CreatePolicy(request *CreatePolicyRequest) (response *CreatePolicyResponse, err error) { + response = CreateCreatePolicyResponse() + err = client.DoAction(request, response) + return +} + +// CreatePolicyWithChan invokes the ram.CreatePolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/createpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreatePolicyWithChan(request *CreatePolicyRequest) (<-chan *CreatePolicyResponse, <-chan error) { + responseChan := make(chan *CreatePolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreatePolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreatePolicyWithCallback invokes the ram.CreatePolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/createpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreatePolicyWithCallback(request *CreatePolicyRequest, callback func(response *CreatePolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreatePolicyResponse + var err error + defer close(result) + response, err = client.CreatePolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreatePolicyRequest is the request struct for api CreatePolicy +type CreatePolicyRequest struct { + *requests.RpcRequest + Description string `position:"Query" name:"Description"` + PolicyName string `position:"Query" name:"PolicyName"` + PolicyDocument string `position:"Query" name:"PolicyDocument"` +} + +// CreatePolicyResponse is the response struct for api CreatePolicy +type CreatePolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Policy PolicyInCreatePolicy `json:"Policy" xml:"Policy"` +} + +// CreateCreatePolicyRequest creates a request to invoke CreatePolicy API +func CreateCreatePolicyRequest() (request *CreatePolicyRequest) { + request = &CreatePolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreatePolicy", "Ram", "openAPI") + return +} + +// CreateCreatePolicyResponse creates a response to parse from CreatePolicy response +func CreateCreatePolicyResponse() (response *CreatePolicyResponse) { + response = &CreatePolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy_version.go new file mode 100644 index 0000000000..1c630e2354 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_policy_version.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreatePolicyVersion invokes the ram.CreatePolicyVersion API synchronously +// api document: https://help.aliyun.com/api/ram/createpolicyversion.html +func (client *Client) CreatePolicyVersion(request *CreatePolicyVersionRequest) (response *CreatePolicyVersionResponse, err error) { + response = CreateCreatePolicyVersionResponse() + err = client.DoAction(request, response) + return +} + +// CreatePolicyVersionWithChan invokes the ram.CreatePolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/createpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreatePolicyVersionWithChan(request *CreatePolicyVersionRequest) (<-chan *CreatePolicyVersionResponse, <-chan error) { + responseChan := make(chan *CreatePolicyVersionResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreatePolicyVersion(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreatePolicyVersionWithCallback invokes the ram.CreatePolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/createpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreatePolicyVersionWithCallback(request *CreatePolicyVersionRequest, callback func(response *CreatePolicyVersionResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreatePolicyVersionResponse + var err error + defer close(result) + response, err = client.CreatePolicyVersion(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreatePolicyVersionRequest is the request struct for api CreatePolicyVersion +type CreatePolicyVersionRequest struct { + *requests.RpcRequest + SetAsDefault requests.Boolean `position:"Query" name:"SetAsDefault"` + PolicyName string `position:"Query" name:"PolicyName"` + PolicyDocument string `position:"Query" name:"PolicyDocument"` + RotateStrategy string `position:"Query" name:"RotateStrategy"` +} + +// CreatePolicyVersionResponse is the response struct for api CreatePolicyVersion +type CreatePolicyVersionResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + PolicyVersion PolicyVersionInCreatePolicyVersion `json:"PolicyVersion" xml:"PolicyVersion"` +} + +// CreateCreatePolicyVersionRequest creates a request to invoke CreatePolicyVersion API +func CreateCreatePolicyVersionRequest() (request *CreatePolicyVersionRequest) { + request = &CreatePolicyVersionRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreatePolicyVersion", "Ram", "openAPI") + return +} + +// CreateCreatePolicyVersionResponse creates a response to parse from CreatePolicyVersion response +func CreateCreatePolicyVersionResponse() (response *CreatePolicyVersionResponse) { + response = &CreatePolicyVersionResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_role.go new file mode 100644 index 0000000000..d77b8f605b --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_role.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateRole invokes the ram.CreateRole API synchronously +// api document: https://help.aliyun.com/api/ram/createrole.html +func (client *Client) CreateRole(request *CreateRoleRequest) (response *CreateRoleResponse, err error) { + response = CreateCreateRoleResponse() + err = client.DoAction(request, response) + return +} + +// CreateRoleWithChan invokes the ram.CreateRole API asynchronously +// api document: https://help.aliyun.com/api/ram/createrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateRoleWithChan(request *CreateRoleRequest) (<-chan *CreateRoleResponse, <-chan error) { + responseChan := make(chan *CreateRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateRoleWithCallback invokes the ram.CreateRole API asynchronously +// api document: https://help.aliyun.com/api/ram/createrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateRoleWithCallback(request *CreateRoleRequest, callback func(response *CreateRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateRoleResponse + var err error + defer close(result) + response, err = client.CreateRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateRoleRequest is the request struct for api CreateRole +type CreateRoleRequest struct { + *requests.RpcRequest + MaxSessionDuration requests.Integer `position:"Query" name:"MaxSessionDuration"` + RoleName string `position:"Query" name:"RoleName"` + Description string `position:"Query" name:"Description"` + AssumeRolePolicyDocument string `position:"Query" name:"AssumeRolePolicyDocument"` +} + +// CreateRoleResponse is the response struct for api CreateRole +type CreateRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Role RoleInCreateRole `json:"Role" xml:"Role"` +} + +// CreateCreateRoleRequest creates a request to invoke CreateRole API +func CreateCreateRoleRequest() (request *CreateRoleRequest) { + request = &CreateRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateRole", "Ram", "openAPI") + return +} + +// CreateCreateRoleResponse creates a response to parse from CreateRole response +func CreateCreateRoleResponse() (response *CreateRoleResponse) { + response = &CreateRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_user.go new file mode 100644 index 0000000000..508e2a3150 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_user.go @@ -0,0 +1,108 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateUser invokes the ram.CreateUser API synchronously +// api document: https://help.aliyun.com/api/ram/createuser.html +func (client *Client) CreateUser(request *CreateUserRequest) (response *CreateUserResponse, err error) { + response = CreateCreateUserResponse() + err = client.DoAction(request, response) + return +} + +// CreateUserWithChan invokes the ram.CreateUser API asynchronously +// api document: https://help.aliyun.com/api/ram/createuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateUserWithChan(request *CreateUserRequest) (<-chan *CreateUserResponse, <-chan error) { + responseChan := make(chan *CreateUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateUserWithCallback invokes the ram.CreateUser API asynchronously +// api document: https://help.aliyun.com/api/ram/createuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateUserWithCallback(request *CreateUserRequest, callback func(response *CreateUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateUserResponse + var err error + defer close(result) + response, err = client.CreateUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateUserRequest is the request struct for api CreateUser +type CreateUserRequest struct { + *requests.RpcRequest + MobilePhone string `position:"Query" name:"MobilePhone"` + Email string `position:"Query" name:"Email"` + Comments string `position:"Query" name:"Comments"` + DisplayName string `position:"Query" name:"DisplayName"` + UserName string `position:"Query" name:"UserName"` +} + +// CreateUserResponse is the response struct for api CreateUser +type CreateUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + User UserInCreateUser `json:"User" xml:"User"` +} + +// CreateCreateUserRequest creates a request to invoke CreateUser API +func CreateCreateUserRequest() (request *CreateUserRequest) { + request = &CreateUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateUser", "Ram", "openAPI") + return +} + +// CreateCreateUserResponse creates a response to parse from CreateUser response +func CreateCreateUserResponse() (response *CreateUserResponse) { + response = &CreateUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_virtual_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_virtual_mfa_device.go new file mode 100644 index 0000000000..d57257d487 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/create_virtual_mfa_device.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// CreateVirtualMFADevice invokes the ram.CreateVirtualMFADevice API synchronously +// api document: https://help.aliyun.com/api/ram/createvirtualmfadevice.html +func (client *Client) CreateVirtualMFADevice(request *CreateVirtualMFADeviceRequest) (response *CreateVirtualMFADeviceResponse, err error) { + response = CreateCreateVirtualMFADeviceResponse() + err = client.DoAction(request, response) + return +} + +// CreateVirtualMFADeviceWithChan invokes the ram.CreateVirtualMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/createvirtualmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateVirtualMFADeviceWithChan(request *CreateVirtualMFADeviceRequest) (<-chan *CreateVirtualMFADeviceResponse, <-chan error) { + responseChan := make(chan *CreateVirtualMFADeviceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.CreateVirtualMFADevice(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// CreateVirtualMFADeviceWithCallback invokes the ram.CreateVirtualMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/createvirtualmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) CreateVirtualMFADeviceWithCallback(request *CreateVirtualMFADeviceRequest, callback func(response *CreateVirtualMFADeviceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *CreateVirtualMFADeviceResponse + var err error + defer close(result) + response, err = client.CreateVirtualMFADevice(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// CreateVirtualMFADeviceRequest is the request struct for api CreateVirtualMFADevice +type CreateVirtualMFADeviceRequest struct { + *requests.RpcRequest + VirtualMFADeviceName string `position:"Query" name:"VirtualMFADeviceName"` +} + +// CreateVirtualMFADeviceResponse is the response struct for api CreateVirtualMFADevice +type CreateVirtualMFADeviceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + VirtualMFADevice VirtualMFADeviceInCreateVirtualMFADevice `json:"VirtualMFADevice" xml:"VirtualMFADevice"` +} + +// CreateCreateVirtualMFADeviceRequest creates a request to invoke CreateVirtualMFADevice API +func CreateCreateVirtualMFADeviceRequest() (request *CreateVirtualMFADeviceRequest) { + request = &CreateVirtualMFADeviceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "CreateVirtualMFADevice", "Ram", "openAPI") + return +} + +// CreateCreateVirtualMFADeviceResponse creates a response to parse from CreateVirtualMFADevice response +func CreateCreateVirtualMFADeviceResponse() (response *CreateVirtualMFADeviceResponse) { + response = &CreateVirtualMFADeviceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_access_key.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_access_key.go new file mode 100644 index 0000000000..ec8039c27f --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_access_key.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteAccessKey invokes the ram.DeleteAccessKey API synchronously +// api document: https://help.aliyun.com/api/ram/deleteaccesskey.html +func (client *Client) DeleteAccessKey(request *DeleteAccessKeyRequest) (response *DeleteAccessKeyResponse, err error) { + response = CreateDeleteAccessKeyResponse() + err = client.DoAction(request, response) + return +} + +// DeleteAccessKeyWithChan invokes the ram.DeleteAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteAccessKeyWithChan(request *DeleteAccessKeyRequest) (<-chan *DeleteAccessKeyResponse, <-chan error) { + responseChan := make(chan *DeleteAccessKeyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteAccessKey(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteAccessKeyWithCallback invokes the ram.DeleteAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteAccessKeyWithCallback(request *DeleteAccessKeyRequest, callback func(response *DeleteAccessKeyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteAccessKeyResponse + var err error + defer close(result) + response, err = client.DeleteAccessKey(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteAccessKeyRequest is the request struct for api DeleteAccessKey +type DeleteAccessKeyRequest struct { + *requests.RpcRequest + UserAccessKeyId string `position:"Query" name:"UserAccessKeyId"` + UserName string `position:"Query" name:"UserName"` +} + +// DeleteAccessKeyResponse is the response struct for api DeleteAccessKey +type DeleteAccessKeyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteAccessKeyRequest creates a request to invoke DeleteAccessKey API +func CreateDeleteAccessKeyRequest() (request *DeleteAccessKeyRequest) { + request = &DeleteAccessKeyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteAccessKey", "Ram", "openAPI") + return +} + +// CreateDeleteAccessKeyResponse creates a response to parse from DeleteAccessKey response +func CreateDeleteAccessKeyResponse() (response *DeleteAccessKeyResponse) { + response = &DeleteAccessKeyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_group.go new file mode 100644 index 0000000000..2b56c870d5 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_group.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteGroup invokes the ram.DeleteGroup API synchronously +// api document: https://help.aliyun.com/api/ram/deletegroup.html +func (client *Client) DeleteGroup(request *DeleteGroupRequest) (response *DeleteGroupResponse, err error) { + response = CreateDeleteGroupResponse() + err = client.DoAction(request, response) + return +} + +// DeleteGroupWithChan invokes the ram.DeleteGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/deletegroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteGroupWithChan(request *DeleteGroupRequest) (<-chan *DeleteGroupResponse, <-chan error) { + responseChan := make(chan *DeleteGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteGroupWithCallback invokes the ram.DeleteGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/deletegroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteGroupWithCallback(request *DeleteGroupRequest, callback func(response *DeleteGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteGroupResponse + var err error + defer close(result) + response, err = client.DeleteGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteGroupRequest is the request struct for api DeleteGroup +type DeleteGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` +} + +// DeleteGroupResponse is the response struct for api DeleteGroup +type DeleteGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteGroupRequest creates a request to invoke DeleteGroup API +func CreateDeleteGroupRequest() (request *DeleteGroupRequest) { + request = &DeleteGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteGroup", "Ram", "openAPI") + return +} + +// CreateDeleteGroupResponse creates a response to parse from DeleteGroup response +func CreateDeleteGroupResponse() (response *DeleteGroupResponse) { + response = &DeleteGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_login_profile.go new file mode 100644 index 0000000000..347858239d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_login_profile.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteLoginProfile invokes the ram.DeleteLoginProfile API synchronously +// api document: https://help.aliyun.com/api/ram/deleteloginprofile.html +func (client *Client) DeleteLoginProfile(request *DeleteLoginProfileRequest) (response *DeleteLoginProfileResponse, err error) { + response = CreateDeleteLoginProfileResponse() + err = client.DoAction(request, response) + return +} + +// DeleteLoginProfileWithChan invokes the ram.DeleteLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteLoginProfileWithChan(request *DeleteLoginProfileRequest) (<-chan *DeleteLoginProfileResponse, <-chan error) { + responseChan := make(chan *DeleteLoginProfileResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteLoginProfile(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteLoginProfileWithCallback invokes the ram.DeleteLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteLoginProfileWithCallback(request *DeleteLoginProfileRequest, callback func(response *DeleteLoginProfileResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteLoginProfileResponse + var err error + defer close(result) + response, err = client.DeleteLoginProfile(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteLoginProfileRequest is the request struct for api DeleteLoginProfile +type DeleteLoginProfileRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// DeleteLoginProfileResponse is the response struct for api DeleteLoginProfile +type DeleteLoginProfileResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteLoginProfileRequest creates a request to invoke DeleteLoginProfile API +func CreateDeleteLoginProfileRequest() (request *DeleteLoginProfileRequest) { + request = &DeleteLoginProfileRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteLoginProfile", "Ram", "openAPI") + return +} + +// CreateDeleteLoginProfileResponse creates a response to parse from DeleteLoginProfile response +func CreateDeleteLoginProfileResponse() (response *DeleteLoginProfileResponse) { + response = &DeleteLoginProfileResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy.go new file mode 100644 index 0000000000..508bc411cb --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeletePolicy invokes the ram.DeletePolicy API synchronously +// api document: https://help.aliyun.com/api/ram/deletepolicy.html +func (client *Client) DeletePolicy(request *DeletePolicyRequest) (response *DeletePolicyResponse, err error) { + response = CreateDeletePolicyResponse() + err = client.DoAction(request, response) + return +} + +// DeletePolicyWithChan invokes the ram.DeletePolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/deletepolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeletePolicyWithChan(request *DeletePolicyRequest) (<-chan *DeletePolicyResponse, <-chan error) { + responseChan := make(chan *DeletePolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeletePolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeletePolicyWithCallback invokes the ram.DeletePolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/deletepolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeletePolicyWithCallback(request *DeletePolicyRequest, callback func(response *DeletePolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeletePolicyResponse + var err error + defer close(result) + response, err = client.DeletePolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeletePolicyRequest is the request struct for api DeletePolicy +type DeletePolicyRequest struct { + *requests.RpcRequest + PolicyName string `position:"Query" name:"PolicyName"` +} + +// DeletePolicyResponse is the response struct for api DeletePolicy +type DeletePolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeletePolicyRequest creates a request to invoke DeletePolicy API +func CreateDeletePolicyRequest() (request *DeletePolicyRequest) { + request = &DeletePolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeletePolicy", "Ram", "openAPI") + return +} + +// CreateDeletePolicyResponse creates a response to parse from DeletePolicy response +func CreateDeletePolicyResponse() (response *DeletePolicyResponse) { + response = &DeletePolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy_version.go new file mode 100644 index 0000000000..7c41a781fe --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_policy_version.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeletePolicyVersion invokes the ram.DeletePolicyVersion API synchronously +// api document: https://help.aliyun.com/api/ram/deletepolicyversion.html +func (client *Client) DeletePolicyVersion(request *DeletePolicyVersionRequest) (response *DeletePolicyVersionResponse, err error) { + response = CreateDeletePolicyVersionResponse() + err = client.DoAction(request, response) + return +} + +// DeletePolicyVersionWithChan invokes the ram.DeletePolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/deletepolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeletePolicyVersionWithChan(request *DeletePolicyVersionRequest) (<-chan *DeletePolicyVersionResponse, <-chan error) { + responseChan := make(chan *DeletePolicyVersionResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeletePolicyVersion(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeletePolicyVersionWithCallback invokes the ram.DeletePolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/deletepolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeletePolicyVersionWithCallback(request *DeletePolicyVersionRequest, callback func(response *DeletePolicyVersionResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeletePolicyVersionResponse + var err error + defer close(result) + response, err = client.DeletePolicyVersion(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeletePolicyVersionRequest is the request struct for api DeletePolicyVersion +type DeletePolicyVersionRequest struct { + *requests.RpcRequest + VersionId string `position:"Query" name:"VersionId"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// DeletePolicyVersionResponse is the response struct for api DeletePolicyVersion +type DeletePolicyVersionResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeletePolicyVersionRequest creates a request to invoke DeletePolicyVersion API +func CreateDeletePolicyVersionRequest() (request *DeletePolicyVersionRequest) { + request = &DeletePolicyVersionRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeletePolicyVersion", "Ram", "openAPI") + return +} + +// CreateDeletePolicyVersionResponse creates a response to parse from DeletePolicyVersion response +func CreateDeletePolicyVersionResponse() (response *DeletePolicyVersionResponse) { + response = &DeletePolicyVersionResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_role.go new file mode 100644 index 0000000000..8882268ab2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_role.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteRole invokes the ram.DeleteRole API synchronously +// api document: https://help.aliyun.com/api/ram/deleterole.html +func (client *Client) DeleteRole(request *DeleteRoleRequest) (response *DeleteRoleResponse, err error) { + response = CreateDeleteRoleResponse() + err = client.DoAction(request, response) + return +} + +// DeleteRoleWithChan invokes the ram.DeleteRole API asynchronously +// api document: https://help.aliyun.com/api/ram/deleterole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteRoleWithChan(request *DeleteRoleRequest) (<-chan *DeleteRoleResponse, <-chan error) { + responseChan := make(chan *DeleteRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteRoleWithCallback invokes the ram.DeleteRole API asynchronously +// api document: https://help.aliyun.com/api/ram/deleterole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteRoleWithCallback(request *DeleteRoleRequest, callback func(response *DeleteRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteRoleResponse + var err error + defer close(result) + response, err = client.DeleteRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteRoleRequest is the request struct for api DeleteRole +type DeleteRoleRequest struct { + *requests.RpcRequest + RoleName string `position:"Query" name:"RoleName"` +} + +// DeleteRoleResponse is the response struct for api DeleteRole +type DeleteRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteRoleRequest creates a request to invoke DeleteRole API +func CreateDeleteRoleRequest() (request *DeleteRoleRequest) { + request = &DeleteRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteRole", "Ram", "openAPI") + return +} + +// CreateDeleteRoleResponse creates a response to parse from DeleteRole response +func CreateDeleteRoleResponse() (response *DeleteRoleResponse) { + response = &DeleteRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_user.go new file mode 100644 index 0000000000..57ea786f97 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_user.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteUser invokes the ram.DeleteUser API synchronously +// api document: https://help.aliyun.com/api/ram/deleteuser.html +func (client *Client) DeleteUser(request *DeleteUserRequest) (response *DeleteUserResponse, err error) { + response = CreateDeleteUserResponse() + err = client.DoAction(request, response) + return +} + +// DeleteUserWithChan invokes the ram.DeleteUser API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteUserWithChan(request *DeleteUserRequest) (<-chan *DeleteUserResponse, <-chan error) { + responseChan := make(chan *DeleteUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteUserWithCallback invokes the ram.DeleteUser API asynchronously +// api document: https://help.aliyun.com/api/ram/deleteuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteUserWithCallback(request *DeleteUserRequest, callback func(response *DeleteUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteUserResponse + var err error + defer close(result) + response, err = client.DeleteUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteUserRequest is the request struct for api DeleteUser +type DeleteUserRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// DeleteUserResponse is the response struct for api DeleteUser +type DeleteUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteUserRequest creates a request to invoke DeleteUser API +func CreateDeleteUserRequest() (request *DeleteUserRequest) { + request = &DeleteUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteUser", "Ram", "openAPI") + return +} + +// CreateDeleteUserResponse creates a response to parse from DeleteUser response +func CreateDeleteUserResponse() (response *DeleteUserResponse) { + response = &DeleteUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_virtual_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_virtual_mfa_device.go new file mode 100644 index 0000000000..16fdd22bae --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/delete_virtual_mfa_device.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DeleteVirtualMFADevice invokes the ram.DeleteVirtualMFADevice API synchronously +// api document: https://help.aliyun.com/api/ram/deletevirtualmfadevice.html +func (client *Client) DeleteVirtualMFADevice(request *DeleteVirtualMFADeviceRequest) (response *DeleteVirtualMFADeviceResponse, err error) { + response = CreateDeleteVirtualMFADeviceResponse() + err = client.DoAction(request, response) + return +} + +// DeleteVirtualMFADeviceWithChan invokes the ram.DeleteVirtualMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/deletevirtualmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteVirtualMFADeviceWithChan(request *DeleteVirtualMFADeviceRequest) (<-chan *DeleteVirtualMFADeviceResponse, <-chan error) { + responseChan := make(chan *DeleteVirtualMFADeviceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DeleteVirtualMFADevice(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DeleteVirtualMFADeviceWithCallback invokes the ram.DeleteVirtualMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/deletevirtualmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DeleteVirtualMFADeviceWithCallback(request *DeleteVirtualMFADeviceRequest, callback func(response *DeleteVirtualMFADeviceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DeleteVirtualMFADeviceResponse + var err error + defer close(result) + response, err = client.DeleteVirtualMFADevice(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DeleteVirtualMFADeviceRequest is the request struct for api DeleteVirtualMFADevice +type DeleteVirtualMFADeviceRequest struct { + *requests.RpcRequest + SerialNumber string `position:"Query" name:"SerialNumber"` +} + +// DeleteVirtualMFADeviceResponse is the response struct for api DeleteVirtualMFADevice +type DeleteVirtualMFADeviceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDeleteVirtualMFADeviceRequest creates a request to invoke DeleteVirtualMFADevice API +func CreateDeleteVirtualMFADeviceRequest() (request *DeleteVirtualMFADeviceRequest) { + request = &DeleteVirtualMFADeviceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DeleteVirtualMFADevice", "Ram", "openAPI") + return +} + +// CreateDeleteVirtualMFADeviceResponse creates a response to parse from DeleteVirtualMFADevice response +func CreateDeleteVirtualMFADeviceResponse() (response *DeleteVirtualMFADeviceResponse) { + response = &DeleteVirtualMFADeviceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_group.go new file mode 100644 index 0000000000..56ec09c1ad --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_group.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DetachPolicyFromGroup invokes the ram.DetachPolicyFromGroup API synchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromgroup.html +func (client *Client) DetachPolicyFromGroup(request *DetachPolicyFromGroupRequest) (response *DetachPolicyFromGroupResponse, err error) { + response = CreateDetachPolicyFromGroupResponse() + err = client.DoAction(request, response) + return +} + +// DetachPolicyFromGroupWithChan invokes the ram.DetachPolicyFromGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromGroupWithChan(request *DetachPolicyFromGroupRequest) (<-chan *DetachPolicyFromGroupResponse, <-chan error) { + responseChan := make(chan *DetachPolicyFromGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DetachPolicyFromGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DetachPolicyFromGroupWithCallback invokes the ram.DetachPolicyFromGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromGroupWithCallback(request *DetachPolicyFromGroupRequest, callback func(response *DetachPolicyFromGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DetachPolicyFromGroupResponse + var err error + defer close(result) + response, err = client.DetachPolicyFromGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DetachPolicyFromGroupRequest is the request struct for api DetachPolicyFromGroup +type DetachPolicyFromGroupRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + GroupName string `position:"Query" name:"GroupName"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// DetachPolicyFromGroupResponse is the response struct for api DetachPolicyFromGroup +type DetachPolicyFromGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDetachPolicyFromGroupRequest creates a request to invoke DetachPolicyFromGroup API +func CreateDetachPolicyFromGroupRequest() (request *DetachPolicyFromGroupRequest) { + request = &DetachPolicyFromGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DetachPolicyFromGroup", "Ram", "openAPI") + return +} + +// CreateDetachPolicyFromGroupResponse creates a response to parse from DetachPolicyFromGroup response +func CreateDetachPolicyFromGroupResponse() (response *DetachPolicyFromGroupResponse) { + response = &DetachPolicyFromGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_role.go new file mode 100644 index 0000000000..798a5a69e9 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_role.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DetachPolicyFromRole invokes the ram.DetachPolicyFromRole API synchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromrole.html +func (client *Client) DetachPolicyFromRole(request *DetachPolicyFromRoleRequest) (response *DetachPolicyFromRoleResponse, err error) { + response = CreateDetachPolicyFromRoleResponse() + err = client.DoAction(request, response) + return +} + +// DetachPolicyFromRoleWithChan invokes the ram.DetachPolicyFromRole API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromRoleWithChan(request *DetachPolicyFromRoleRequest) (<-chan *DetachPolicyFromRoleResponse, <-chan error) { + responseChan := make(chan *DetachPolicyFromRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DetachPolicyFromRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DetachPolicyFromRoleWithCallback invokes the ram.DetachPolicyFromRole API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromRoleWithCallback(request *DetachPolicyFromRoleRequest, callback func(response *DetachPolicyFromRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DetachPolicyFromRoleResponse + var err error + defer close(result) + response, err = client.DetachPolicyFromRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DetachPolicyFromRoleRequest is the request struct for api DetachPolicyFromRole +type DetachPolicyFromRoleRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + RoleName string `position:"Query" name:"RoleName"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// DetachPolicyFromRoleResponse is the response struct for api DetachPolicyFromRole +type DetachPolicyFromRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDetachPolicyFromRoleRequest creates a request to invoke DetachPolicyFromRole API +func CreateDetachPolicyFromRoleRequest() (request *DetachPolicyFromRoleRequest) { + request = &DetachPolicyFromRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DetachPolicyFromRole", "Ram", "openAPI") + return +} + +// CreateDetachPolicyFromRoleResponse creates a response to parse from DetachPolicyFromRole response +func CreateDetachPolicyFromRoleResponse() (response *DetachPolicyFromRoleResponse) { + response = &DetachPolicyFromRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_user.go new file mode 100644 index 0000000000..3b3fd75828 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/detach_policy_from_user.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// DetachPolicyFromUser invokes the ram.DetachPolicyFromUser API synchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromuser.html +func (client *Client) DetachPolicyFromUser(request *DetachPolicyFromUserRequest) (response *DetachPolicyFromUserResponse, err error) { + response = CreateDetachPolicyFromUserResponse() + err = client.DoAction(request, response) + return +} + +// DetachPolicyFromUserWithChan invokes the ram.DetachPolicyFromUser API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromUserWithChan(request *DetachPolicyFromUserRequest) (<-chan *DetachPolicyFromUserResponse, <-chan error) { + responseChan := make(chan *DetachPolicyFromUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.DetachPolicyFromUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// DetachPolicyFromUserWithCallback invokes the ram.DetachPolicyFromUser API asynchronously +// api document: https://help.aliyun.com/api/ram/detachpolicyfromuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) DetachPolicyFromUserWithCallback(request *DetachPolicyFromUserRequest, callback func(response *DetachPolicyFromUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *DetachPolicyFromUserResponse + var err error + defer close(result) + response, err = client.DetachPolicyFromUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// DetachPolicyFromUserRequest is the request struct for api DetachPolicyFromUser +type DetachPolicyFromUserRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + PolicyName string `position:"Query" name:"PolicyName"` + UserName string `position:"Query" name:"UserName"` +} + +// DetachPolicyFromUserResponse is the response struct for api DetachPolicyFromUser +type DetachPolicyFromUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateDetachPolicyFromUserRequest creates a request to invoke DetachPolicyFromUser API +func CreateDetachPolicyFromUserRequest() (request *DetachPolicyFromUserRequest) { + request = &DetachPolicyFromUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "DetachPolicyFromUser", "Ram", "openAPI") + return +} + +// CreateDetachPolicyFromUserResponse creates a response to parse from DetachPolicyFromUser response +func CreateDetachPolicyFromUserResponse() (response *DetachPolicyFromUserResponse) { + response = &DetachPolicyFromUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/endpoint.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/endpoint.go new file mode 100644 index 0000000000..1cdf483eff --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/endpoint.go @@ -0,0 +1,20 @@ +package ram + +// EndpointMap Endpoint Data +var EndpointMap map[string]string + +// EndpointType regional or central +var EndpointType = "central" + +// GetEndpointMap Get Endpoint Data Map +func GetEndpointMap() map[string]string { + if EndpointMap == nil { + EndpointMap = map[string]string{} + } + return EndpointMap +} + +// GetEndpointType Get Endpoint Type Value +func GetEndpointType() string { + return EndpointType +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_access_key_last_used.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_access_key_last_used.go new file mode 100644 index 0000000000..54dc78a9b9 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_access_key_last_used.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetAccessKeyLastUsed invokes the ram.GetAccessKeyLastUsed API synchronously +// api document: https://help.aliyun.com/api/ram/getaccesskeylastused.html +func (client *Client) GetAccessKeyLastUsed(request *GetAccessKeyLastUsedRequest) (response *GetAccessKeyLastUsedResponse, err error) { + response = CreateGetAccessKeyLastUsedResponse() + err = client.DoAction(request, response) + return +} + +// GetAccessKeyLastUsedWithChan invokes the ram.GetAccessKeyLastUsed API asynchronously +// api document: https://help.aliyun.com/api/ram/getaccesskeylastused.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetAccessKeyLastUsedWithChan(request *GetAccessKeyLastUsedRequest) (<-chan *GetAccessKeyLastUsedResponse, <-chan error) { + responseChan := make(chan *GetAccessKeyLastUsedResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetAccessKeyLastUsed(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetAccessKeyLastUsedWithCallback invokes the ram.GetAccessKeyLastUsed API asynchronously +// api document: https://help.aliyun.com/api/ram/getaccesskeylastused.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetAccessKeyLastUsedWithCallback(request *GetAccessKeyLastUsedRequest, callback func(response *GetAccessKeyLastUsedResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetAccessKeyLastUsedResponse + var err error + defer close(result) + response, err = client.GetAccessKeyLastUsed(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetAccessKeyLastUsedRequest is the request struct for api GetAccessKeyLastUsed +type GetAccessKeyLastUsedRequest struct { + *requests.RpcRequest + UserAccessKeyId string `position:"Query" name:"UserAccessKeyId"` + UserName string `position:"Query" name:"UserName"` +} + +// GetAccessKeyLastUsedResponse is the response struct for api GetAccessKeyLastUsed +type GetAccessKeyLastUsedResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + AccessKeyLastUsed AccessKeyLastUsed `json:"AccessKeyLastUsed" xml:"AccessKeyLastUsed"` +} + +// CreateGetAccessKeyLastUsedRequest creates a request to invoke GetAccessKeyLastUsed API +func CreateGetAccessKeyLastUsedRequest() (request *GetAccessKeyLastUsedRequest) { + request = &GetAccessKeyLastUsedRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetAccessKeyLastUsed", "Ram", "openAPI") + return +} + +// CreateGetAccessKeyLastUsedResponse creates a response to parse from GetAccessKeyLastUsed response +func CreateGetAccessKeyLastUsedResponse() (response *GetAccessKeyLastUsedResponse) { + response = &GetAccessKeyLastUsedResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_account_alias.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_account_alias.go new file mode 100644 index 0000000000..5f2ebeb132 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_account_alias.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetAccountAlias invokes the ram.GetAccountAlias API synchronously +// api document: https://help.aliyun.com/api/ram/getaccountalias.html +func (client *Client) GetAccountAlias(request *GetAccountAliasRequest) (response *GetAccountAliasResponse, err error) { + response = CreateGetAccountAliasResponse() + err = client.DoAction(request, response) + return +} + +// GetAccountAliasWithChan invokes the ram.GetAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/getaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetAccountAliasWithChan(request *GetAccountAliasRequest) (<-chan *GetAccountAliasResponse, <-chan error) { + responseChan := make(chan *GetAccountAliasResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetAccountAlias(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetAccountAliasWithCallback invokes the ram.GetAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/getaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetAccountAliasWithCallback(request *GetAccountAliasRequest, callback func(response *GetAccountAliasResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetAccountAliasResponse + var err error + defer close(result) + response, err = client.GetAccountAlias(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetAccountAliasRequest is the request struct for api GetAccountAlias +type GetAccountAliasRequest struct { + *requests.RpcRequest +} + +// GetAccountAliasResponse is the response struct for api GetAccountAlias +type GetAccountAliasResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + AccountAlias string `json:"AccountAlias" xml:"AccountAlias"` +} + +// CreateGetAccountAliasRequest creates a request to invoke GetAccountAlias API +func CreateGetAccountAliasRequest() (request *GetAccountAliasRequest) { + request = &GetAccountAliasRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetAccountAlias", "Ram", "openAPI") + return +} + +// CreateGetAccountAliasResponse creates a response to parse from GetAccountAlias response +func CreateGetAccountAliasResponse() (response *GetAccountAliasResponse) { + response = &GetAccountAliasResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_group.go new file mode 100644 index 0000000000..b473a352be --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_group.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetGroup invokes the ram.GetGroup API synchronously +// api document: https://help.aliyun.com/api/ram/getgroup.html +func (client *Client) GetGroup(request *GetGroupRequest) (response *GetGroupResponse, err error) { + response = CreateGetGroupResponse() + err = client.DoAction(request, response) + return +} + +// GetGroupWithChan invokes the ram.GetGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/getgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetGroupWithChan(request *GetGroupRequest) (<-chan *GetGroupResponse, <-chan error) { + responseChan := make(chan *GetGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetGroupWithCallback invokes the ram.GetGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/getgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetGroupWithCallback(request *GetGroupRequest, callback func(response *GetGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetGroupResponse + var err error + defer close(result) + response, err = client.GetGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetGroupRequest is the request struct for api GetGroup +type GetGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` +} + +// GetGroupResponse is the response struct for api GetGroup +type GetGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Group GroupInGetGroup `json:"Group" xml:"Group"` +} + +// CreateGetGroupRequest creates a request to invoke GetGroup API +func CreateGetGroupRequest() (request *GetGroupRequest) { + request = &GetGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetGroup", "Ram", "openAPI") + return +} + +// CreateGetGroupResponse creates a response to parse from GetGroup response +func CreateGetGroupResponse() (response *GetGroupResponse) { + response = &GetGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_login_profile.go new file mode 100644 index 0000000000..223f667a42 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_login_profile.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetLoginProfile invokes the ram.GetLoginProfile API synchronously +// api document: https://help.aliyun.com/api/ram/getloginprofile.html +func (client *Client) GetLoginProfile(request *GetLoginProfileRequest) (response *GetLoginProfileResponse, err error) { + response = CreateGetLoginProfileResponse() + err = client.DoAction(request, response) + return +} + +// GetLoginProfileWithChan invokes the ram.GetLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/getloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetLoginProfileWithChan(request *GetLoginProfileRequest) (<-chan *GetLoginProfileResponse, <-chan error) { + responseChan := make(chan *GetLoginProfileResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetLoginProfile(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetLoginProfileWithCallback invokes the ram.GetLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/getloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetLoginProfileWithCallback(request *GetLoginProfileRequest, callback func(response *GetLoginProfileResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetLoginProfileResponse + var err error + defer close(result) + response, err = client.GetLoginProfile(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetLoginProfileRequest is the request struct for api GetLoginProfile +type GetLoginProfileRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// GetLoginProfileResponse is the response struct for api GetLoginProfile +type GetLoginProfileResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + LoginProfile LoginProfileInGetLoginProfile `json:"LoginProfile" xml:"LoginProfile"` +} + +// CreateGetLoginProfileRequest creates a request to invoke GetLoginProfile API +func CreateGetLoginProfileRequest() (request *GetLoginProfileRequest) { + request = &GetLoginProfileRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetLoginProfile", "Ram", "openAPI") + return +} + +// CreateGetLoginProfileResponse creates a response to parse from GetLoginProfile response +func CreateGetLoginProfileResponse() (response *GetLoginProfileResponse) { + response = &GetLoginProfileResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_password_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_password_policy.go new file mode 100644 index 0000000000..4574a32934 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_password_policy.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetPasswordPolicy invokes the ram.GetPasswordPolicy API synchronously +// api document: https://help.aliyun.com/api/ram/getpasswordpolicy.html +func (client *Client) GetPasswordPolicy(request *GetPasswordPolicyRequest) (response *GetPasswordPolicyResponse, err error) { + response = CreateGetPasswordPolicyResponse() + err = client.DoAction(request, response) + return +} + +// GetPasswordPolicyWithChan invokes the ram.GetPasswordPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/getpasswordpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPasswordPolicyWithChan(request *GetPasswordPolicyRequest) (<-chan *GetPasswordPolicyResponse, <-chan error) { + responseChan := make(chan *GetPasswordPolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetPasswordPolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetPasswordPolicyWithCallback invokes the ram.GetPasswordPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/getpasswordpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPasswordPolicyWithCallback(request *GetPasswordPolicyRequest, callback func(response *GetPasswordPolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetPasswordPolicyResponse + var err error + defer close(result) + response, err = client.GetPasswordPolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetPasswordPolicyRequest is the request struct for api GetPasswordPolicy +type GetPasswordPolicyRequest struct { + *requests.RpcRequest +} + +// GetPasswordPolicyResponse is the response struct for api GetPasswordPolicy +type GetPasswordPolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + PasswordPolicy PasswordPolicyInGetPasswordPolicy `json:"PasswordPolicy" xml:"PasswordPolicy"` +} + +// CreateGetPasswordPolicyRequest creates a request to invoke GetPasswordPolicy API +func CreateGetPasswordPolicyRequest() (request *GetPasswordPolicyRequest) { + request = &GetPasswordPolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetPasswordPolicy", "Ram", "openAPI") + return +} + +// CreateGetPasswordPolicyResponse creates a response to parse from GetPasswordPolicy response +func CreateGetPasswordPolicyResponse() (response *GetPasswordPolicyResponse) { + response = &GetPasswordPolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy.go new file mode 100644 index 0000000000..fe343f9e1c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetPolicy invokes the ram.GetPolicy API synchronously +// api document: https://help.aliyun.com/api/ram/getpolicy.html +func (client *Client) GetPolicy(request *GetPolicyRequest) (response *GetPolicyResponse, err error) { + response = CreateGetPolicyResponse() + err = client.DoAction(request, response) + return +} + +// GetPolicyWithChan invokes the ram.GetPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/getpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPolicyWithChan(request *GetPolicyRequest) (<-chan *GetPolicyResponse, <-chan error) { + responseChan := make(chan *GetPolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetPolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetPolicyWithCallback invokes the ram.GetPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/getpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPolicyWithCallback(request *GetPolicyRequest, callback func(response *GetPolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetPolicyResponse + var err error + defer close(result) + response, err = client.GetPolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetPolicyRequest is the request struct for api GetPolicy +type GetPolicyRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// GetPolicyResponse is the response struct for api GetPolicy +type GetPolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Policy PolicyInGetPolicy `json:"Policy" xml:"Policy"` + DefaultPolicyVersion DefaultPolicyVersion `json:"DefaultPolicyVersion" xml:"DefaultPolicyVersion"` +} + +// CreateGetPolicyRequest creates a request to invoke GetPolicy API +func CreateGetPolicyRequest() (request *GetPolicyRequest) { + request = &GetPolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetPolicy", "Ram", "openAPI") + return +} + +// CreateGetPolicyResponse creates a response to parse from GetPolicy response +func CreateGetPolicyResponse() (response *GetPolicyResponse) { + response = &GetPolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy_version.go new file mode 100644 index 0000000000..cd3a9033e3 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_policy_version.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetPolicyVersion invokes the ram.GetPolicyVersion API synchronously +// api document: https://help.aliyun.com/api/ram/getpolicyversion.html +func (client *Client) GetPolicyVersion(request *GetPolicyVersionRequest) (response *GetPolicyVersionResponse, err error) { + response = CreateGetPolicyVersionResponse() + err = client.DoAction(request, response) + return +} + +// GetPolicyVersionWithChan invokes the ram.GetPolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/getpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPolicyVersionWithChan(request *GetPolicyVersionRequest) (<-chan *GetPolicyVersionResponse, <-chan error) { + responseChan := make(chan *GetPolicyVersionResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetPolicyVersion(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetPolicyVersionWithCallback invokes the ram.GetPolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/getpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetPolicyVersionWithCallback(request *GetPolicyVersionRequest, callback func(response *GetPolicyVersionResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetPolicyVersionResponse + var err error + defer close(result) + response, err = client.GetPolicyVersion(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetPolicyVersionRequest is the request struct for api GetPolicyVersion +type GetPolicyVersionRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + VersionId string `position:"Query" name:"VersionId"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// GetPolicyVersionResponse is the response struct for api GetPolicyVersion +type GetPolicyVersionResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + PolicyVersion PolicyVersionInGetPolicyVersion `json:"PolicyVersion" xml:"PolicyVersion"` +} + +// CreateGetPolicyVersionRequest creates a request to invoke GetPolicyVersion API +func CreateGetPolicyVersionRequest() (request *GetPolicyVersionRequest) { + request = &GetPolicyVersionRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetPolicyVersion", "Ram", "openAPI") + return +} + +// CreateGetPolicyVersionResponse creates a response to parse from GetPolicyVersion response +func CreateGetPolicyVersionResponse() (response *GetPolicyVersionResponse) { + response = &GetPolicyVersionResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_role.go new file mode 100644 index 0000000000..5014f6f181 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_role.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetRole invokes the ram.GetRole API synchronously +// api document: https://help.aliyun.com/api/ram/getrole.html +func (client *Client) GetRole(request *GetRoleRequest) (response *GetRoleResponse, err error) { + response = CreateGetRoleResponse() + err = client.DoAction(request, response) + return +} + +// GetRoleWithChan invokes the ram.GetRole API asynchronously +// api document: https://help.aliyun.com/api/ram/getrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetRoleWithChan(request *GetRoleRequest) (<-chan *GetRoleResponse, <-chan error) { + responseChan := make(chan *GetRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetRoleWithCallback invokes the ram.GetRole API asynchronously +// api document: https://help.aliyun.com/api/ram/getrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetRoleWithCallback(request *GetRoleRequest, callback func(response *GetRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetRoleResponse + var err error + defer close(result) + response, err = client.GetRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetRoleRequest is the request struct for api GetRole +type GetRoleRequest struct { + *requests.RpcRequest + RoleName string `position:"Query" name:"RoleName"` +} + +// GetRoleResponse is the response struct for api GetRole +type GetRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Role RoleInGetRole `json:"Role" xml:"Role"` +} + +// CreateGetRoleRequest creates a request to invoke GetRole API +func CreateGetRoleRequest() (request *GetRoleRequest) { + request = &GetRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetRole", "Ram", "openAPI") + return +} + +// CreateGetRoleResponse creates a response to parse from GetRole response +func CreateGetRoleResponse() (response *GetRoleResponse) { + response = &GetRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_security_preference.go new file mode 100644 index 0000000000..48f5917836 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_security_preference.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetSecurityPreference invokes the ram.GetSecurityPreference API synchronously +// api document: https://help.aliyun.com/api/ram/getsecuritypreference.html +func (client *Client) GetSecurityPreference(request *GetSecurityPreferenceRequest) (response *GetSecurityPreferenceResponse, err error) { + response = CreateGetSecurityPreferenceResponse() + err = client.DoAction(request, response) + return +} + +// GetSecurityPreferenceWithChan invokes the ram.GetSecurityPreference API asynchronously +// api document: https://help.aliyun.com/api/ram/getsecuritypreference.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetSecurityPreferenceWithChan(request *GetSecurityPreferenceRequest) (<-chan *GetSecurityPreferenceResponse, <-chan error) { + responseChan := make(chan *GetSecurityPreferenceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetSecurityPreference(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetSecurityPreferenceWithCallback invokes the ram.GetSecurityPreference API asynchronously +// api document: https://help.aliyun.com/api/ram/getsecuritypreference.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetSecurityPreferenceWithCallback(request *GetSecurityPreferenceRequest, callback func(response *GetSecurityPreferenceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetSecurityPreferenceResponse + var err error + defer close(result) + response, err = client.GetSecurityPreference(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetSecurityPreferenceRequest is the request struct for api GetSecurityPreference +type GetSecurityPreferenceRequest struct { + *requests.RpcRequest +} + +// GetSecurityPreferenceResponse is the response struct for api GetSecurityPreference +type GetSecurityPreferenceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + SecurityPreference SecurityPreferenceInGetSecurityPreference `json:"SecurityPreference" xml:"SecurityPreference"` +} + +// CreateGetSecurityPreferenceRequest creates a request to invoke GetSecurityPreference API +func CreateGetSecurityPreferenceRequest() (request *GetSecurityPreferenceRequest) { + request = &GetSecurityPreferenceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetSecurityPreference", "Ram", "openAPI") + return +} + +// CreateGetSecurityPreferenceResponse creates a response to parse from GetSecurityPreference response +func CreateGetSecurityPreferenceResponse() (response *GetSecurityPreferenceResponse) { + response = &GetSecurityPreferenceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user.go new file mode 100644 index 0000000000..0bc34ae4d6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetUser invokes the ram.GetUser API synchronously +// api document: https://help.aliyun.com/api/ram/getuser.html +func (client *Client) GetUser(request *GetUserRequest) (response *GetUserResponse, err error) { + response = CreateGetUserResponse() + err = client.DoAction(request, response) + return +} + +// GetUserWithChan invokes the ram.GetUser API asynchronously +// api document: https://help.aliyun.com/api/ram/getuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetUserWithChan(request *GetUserRequest) (<-chan *GetUserResponse, <-chan error) { + responseChan := make(chan *GetUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetUserWithCallback invokes the ram.GetUser API asynchronously +// api document: https://help.aliyun.com/api/ram/getuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetUserWithCallback(request *GetUserRequest, callback func(response *GetUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetUserResponse + var err error + defer close(result) + response, err = client.GetUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetUserRequest is the request struct for api GetUser +type GetUserRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// GetUserResponse is the response struct for api GetUser +type GetUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + User UserInGetUser `json:"User" xml:"User"` +} + +// CreateGetUserRequest creates a request to invoke GetUser API +func CreateGetUserRequest() (request *GetUserRequest) { + request = &GetUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetUser", "Ram", "openAPI") + return +} + +// CreateGetUserResponse creates a response to parse from GetUser response +func CreateGetUserResponse() (response *GetUserResponse) { + response = &GetUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user_mfa_info.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user_mfa_info.go new file mode 100644 index 0000000000..5fb5b7e6d0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/get_user_mfa_info.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// GetUserMFAInfo invokes the ram.GetUserMFAInfo API synchronously +// api document: https://help.aliyun.com/api/ram/getusermfainfo.html +func (client *Client) GetUserMFAInfo(request *GetUserMFAInfoRequest) (response *GetUserMFAInfoResponse, err error) { + response = CreateGetUserMFAInfoResponse() + err = client.DoAction(request, response) + return +} + +// GetUserMFAInfoWithChan invokes the ram.GetUserMFAInfo API asynchronously +// api document: https://help.aliyun.com/api/ram/getusermfainfo.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetUserMFAInfoWithChan(request *GetUserMFAInfoRequest) (<-chan *GetUserMFAInfoResponse, <-chan error) { + responseChan := make(chan *GetUserMFAInfoResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.GetUserMFAInfo(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// GetUserMFAInfoWithCallback invokes the ram.GetUserMFAInfo API asynchronously +// api document: https://help.aliyun.com/api/ram/getusermfainfo.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) GetUserMFAInfoWithCallback(request *GetUserMFAInfoRequest, callback func(response *GetUserMFAInfoResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *GetUserMFAInfoResponse + var err error + defer close(result) + response, err = client.GetUserMFAInfo(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// GetUserMFAInfoRequest is the request struct for api GetUserMFAInfo +type GetUserMFAInfoRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// GetUserMFAInfoResponse is the response struct for api GetUserMFAInfo +type GetUserMFAInfoResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + MFADevice MFADeviceInGetUserMFAInfo `json:"MFADevice" xml:"MFADevice"` +} + +// CreateGetUserMFAInfoRequest creates a request to invoke GetUserMFAInfo API +func CreateGetUserMFAInfoRequest() (request *GetUserMFAInfoRequest) { + request = &GetUserMFAInfoRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "GetUserMFAInfo", "Ram", "openAPI") + return +} + +// CreateGetUserMFAInfoResponse creates a response to parse from GetUserMFAInfo response +func CreateGetUserMFAInfoResponse() (response *GetUserMFAInfoResponse) { + response = &GetUserMFAInfoResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_access_keys.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_access_keys.go new file mode 100644 index 0000000000..3bc971d7e1 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_access_keys.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListAccessKeys invokes the ram.ListAccessKeys API synchronously +// api document: https://help.aliyun.com/api/ram/listaccesskeys.html +func (client *Client) ListAccessKeys(request *ListAccessKeysRequest) (response *ListAccessKeysResponse, err error) { + response = CreateListAccessKeysResponse() + err = client.DoAction(request, response) + return +} + +// ListAccessKeysWithChan invokes the ram.ListAccessKeys API asynchronously +// api document: https://help.aliyun.com/api/ram/listaccesskeys.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListAccessKeysWithChan(request *ListAccessKeysRequest) (<-chan *ListAccessKeysResponse, <-chan error) { + responseChan := make(chan *ListAccessKeysResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListAccessKeys(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListAccessKeysWithCallback invokes the ram.ListAccessKeys API asynchronously +// api document: https://help.aliyun.com/api/ram/listaccesskeys.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListAccessKeysWithCallback(request *ListAccessKeysRequest, callback func(response *ListAccessKeysResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListAccessKeysResponse + var err error + defer close(result) + response, err = client.ListAccessKeys(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListAccessKeysRequest is the request struct for api ListAccessKeys +type ListAccessKeysRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// ListAccessKeysResponse is the response struct for api ListAccessKeys +type ListAccessKeysResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + AccessKeys AccessKeys `json:"AccessKeys" xml:"AccessKeys"` +} + +// CreateListAccessKeysRequest creates a request to invoke ListAccessKeys API +func CreateListAccessKeysRequest() (request *ListAccessKeysRequest) { + request = &ListAccessKeysRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListAccessKeys", "Ram", "openAPI") + return +} + +// CreateListAccessKeysResponse creates a response to parse from ListAccessKeys response +func CreateListAccessKeysResponse() (response *ListAccessKeysResponse) { + response = &ListAccessKeysResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_entities_for_policy.go new file mode 100644 index 0000000000..6abf4cd9b5 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_entities_for_policy.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListEntitiesForPolicy invokes the ram.ListEntitiesForPolicy API synchronously +// api document: https://help.aliyun.com/api/ram/listentitiesforpolicy.html +func (client *Client) ListEntitiesForPolicy(request *ListEntitiesForPolicyRequest) (response *ListEntitiesForPolicyResponse, err error) { + response = CreateListEntitiesForPolicyResponse() + err = client.DoAction(request, response) + return +} + +// ListEntitiesForPolicyWithChan invokes the ram.ListEntitiesForPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/listentitiesforpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListEntitiesForPolicyWithChan(request *ListEntitiesForPolicyRequest) (<-chan *ListEntitiesForPolicyResponse, <-chan error) { + responseChan := make(chan *ListEntitiesForPolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListEntitiesForPolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListEntitiesForPolicyWithCallback invokes the ram.ListEntitiesForPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/listentitiesforpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListEntitiesForPolicyWithCallback(request *ListEntitiesForPolicyRequest, callback func(response *ListEntitiesForPolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListEntitiesForPolicyResponse + var err error + defer close(result) + response, err = client.ListEntitiesForPolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListEntitiesForPolicyRequest is the request struct for api ListEntitiesForPolicy +type ListEntitiesForPolicyRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// ListEntitiesForPolicyResponse is the response struct for api ListEntitiesForPolicy +type ListEntitiesForPolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Groups GroupsInListEntitiesForPolicy `json:"Groups" xml:"Groups"` + Users UsersInListEntitiesForPolicy `json:"Users" xml:"Users"` + Roles RolesInListEntitiesForPolicy `json:"Roles" xml:"Roles"` +} + +// CreateListEntitiesForPolicyRequest creates a request to invoke ListEntitiesForPolicy API +func CreateListEntitiesForPolicyRequest() (request *ListEntitiesForPolicyRequest) { + request = &ListEntitiesForPolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListEntitiesForPolicy", "Ram", "openAPI") + return +} + +// CreateListEntitiesForPolicyResponse creates a response to parse from ListEntitiesForPolicy response +func CreateListEntitiesForPolicyResponse() (response *ListEntitiesForPolicyResponse) { + response = &ListEntitiesForPolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups.go new file mode 100644 index 0000000000..5b5a5f63f6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListGroups invokes the ram.ListGroups API synchronously +// api document: https://help.aliyun.com/api/ram/listgroups.html +func (client *Client) ListGroups(request *ListGroupsRequest) (response *ListGroupsResponse, err error) { + response = CreateListGroupsResponse() + err = client.DoAction(request, response) + return +} + +// ListGroupsWithChan invokes the ram.ListGroups API asynchronously +// api document: https://help.aliyun.com/api/ram/listgroups.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListGroupsWithChan(request *ListGroupsRequest) (<-chan *ListGroupsResponse, <-chan error) { + responseChan := make(chan *ListGroupsResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListGroups(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListGroupsWithCallback invokes the ram.ListGroups API asynchronously +// api document: https://help.aliyun.com/api/ram/listgroups.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListGroupsWithCallback(request *ListGroupsRequest, callback func(response *ListGroupsResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListGroupsResponse + var err error + defer close(result) + response, err = client.ListGroups(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListGroupsRequest is the request struct for api ListGroups +type ListGroupsRequest struct { + *requests.RpcRequest + Marker string `position:"Query" name:"Marker"` + MaxItems requests.Integer `position:"Query" name:"MaxItems"` +} + +// ListGroupsResponse is the response struct for api ListGroups +type ListGroupsResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + IsTruncated bool `json:"IsTruncated" xml:"IsTruncated"` + Marker string `json:"Marker" xml:"Marker"` + Groups GroupsInListGroups `json:"Groups" xml:"Groups"` +} + +// CreateListGroupsRequest creates a request to invoke ListGroups API +func CreateListGroupsRequest() (request *ListGroupsRequest) { + request = &ListGroupsRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListGroups", "Ram", "openAPI") + return +} + +// CreateListGroupsResponse creates a response to parse from ListGroups response +func CreateListGroupsResponse() (response *ListGroupsResponse) { + response = &ListGroupsResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups_for_user.go new file mode 100644 index 0000000000..50e6408871 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_groups_for_user.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListGroupsForUser invokes the ram.ListGroupsForUser API synchronously +// api document: https://help.aliyun.com/api/ram/listgroupsforuser.html +func (client *Client) ListGroupsForUser(request *ListGroupsForUserRequest) (response *ListGroupsForUserResponse, err error) { + response = CreateListGroupsForUserResponse() + err = client.DoAction(request, response) + return +} + +// ListGroupsForUserWithChan invokes the ram.ListGroupsForUser API asynchronously +// api document: https://help.aliyun.com/api/ram/listgroupsforuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListGroupsForUserWithChan(request *ListGroupsForUserRequest) (<-chan *ListGroupsForUserResponse, <-chan error) { + responseChan := make(chan *ListGroupsForUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListGroupsForUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListGroupsForUserWithCallback invokes the ram.ListGroupsForUser API asynchronously +// api document: https://help.aliyun.com/api/ram/listgroupsforuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListGroupsForUserWithCallback(request *ListGroupsForUserRequest, callback func(response *ListGroupsForUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListGroupsForUserResponse + var err error + defer close(result) + response, err = client.ListGroupsForUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListGroupsForUserRequest is the request struct for api ListGroupsForUser +type ListGroupsForUserRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// ListGroupsForUserResponse is the response struct for api ListGroupsForUser +type ListGroupsForUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Groups GroupsInListGroupsForUser `json:"Groups" xml:"Groups"` +} + +// CreateListGroupsForUserRequest creates a request to invoke ListGroupsForUser API +func CreateListGroupsForUserRequest() (request *ListGroupsForUserRequest) { + request = &ListGroupsForUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListGroupsForUser", "Ram", "openAPI") + return +} + +// CreateListGroupsForUserResponse creates a response to parse from ListGroupsForUser response +func CreateListGroupsForUserResponse() (response *ListGroupsForUserResponse) { + response = &ListGroupsForUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies.go new file mode 100644 index 0000000000..cc4e12bd35 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies.go @@ -0,0 +1,108 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListPolicies invokes the ram.ListPolicies API synchronously +// api document: https://help.aliyun.com/api/ram/listpolicies.html +func (client *Client) ListPolicies(request *ListPoliciesRequest) (response *ListPoliciesResponse, err error) { + response = CreateListPoliciesResponse() + err = client.DoAction(request, response) + return +} + +// ListPoliciesWithChan invokes the ram.ListPolicies API asynchronously +// api document: https://help.aliyun.com/api/ram/listpolicies.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesWithChan(request *ListPoliciesRequest) (<-chan *ListPoliciesResponse, <-chan error) { + responseChan := make(chan *ListPoliciesResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListPolicies(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListPoliciesWithCallback invokes the ram.ListPolicies API asynchronously +// api document: https://help.aliyun.com/api/ram/listpolicies.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesWithCallback(request *ListPoliciesRequest, callback func(response *ListPoliciesResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListPoliciesResponse + var err error + defer close(result) + response, err = client.ListPolicies(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListPoliciesRequest is the request struct for api ListPolicies +type ListPoliciesRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + Marker string `position:"Query" name:"Marker"` + MaxItems requests.Integer `position:"Query" name:"MaxItems"` +} + +// ListPoliciesResponse is the response struct for api ListPolicies +type ListPoliciesResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + IsTruncated bool `json:"IsTruncated" xml:"IsTruncated"` + Marker string `json:"Marker" xml:"Marker"` + Policies PoliciesInListPolicies `json:"Policies" xml:"Policies"` +} + +// CreateListPoliciesRequest creates a request to invoke ListPolicies API +func CreateListPoliciesRequest() (request *ListPoliciesRequest) { + request = &ListPoliciesRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListPolicies", "Ram", "openAPI") + return +} + +// CreateListPoliciesResponse creates a response to parse from ListPolicies response +func CreateListPoliciesResponse() (response *ListPoliciesResponse) { + response = &ListPoliciesResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_group.go new file mode 100644 index 0000000000..0ea6cf69d6 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_group.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListPoliciesForGroup invokes the ram.ListPoliciesForGroup API synchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforgroup.html +func (client *Client) ListPoliciesForGroup(request *ListPoliciesForGroupRequest) (response *ListPoliciesForGroupResponse, err error) { + response = CreateListPoliciesForGroupResponse() + err = client.DoAction(request, response) + return +} + +// ListPoliciesForGroupWithChan invokes the ram.ListPoliciesForGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForGroupWithChan(request *ListPoliciesForGroupRequest) (<-chan *ListPoliciesForGroupResponse, <-chan error) { + responseChan := make(chan *ListPoliciesForGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListPoliciesForGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListPoliciesForGroupWithCallback invokes the ram.ListPoliciesForGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForGroupWithCallback(request *ListPoliciesForGroupRequest, callback func(response *ListPoliciesForGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListPoliciesForGroupResponse + var err error + defer close(result) + response, err = client.ListPoliciesForGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListPoliciesForGroupRequest is the request struct for api ListPoliciesForGroup +type ListPoliciesForGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` +} + +// ListPoliciesForGroupResponse is the response struct for api ListPoliciesForGroup +type ListPoliciesForGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Policies PoliciesInListPoliciesForGroup `json:"Policies" xml:"Policies"` +} + +// CreateListPoliciesForGroupRequest creates a request to invoke ListPoliciesForGroup API +func CreateListPoliciesForGroupRequest() (request *ListPoliciesForGroupRequest) { + request = &ListPoliciesForGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListPoliciesForGroup", "Ram", "openAPI") + return +} + +// CreateListPoliciesForGroupResponse creates a response to parse from ListPoliciesForGroup response +func CreateListPoliciesForGroupResponse() (response *ListPoliciesForGroupResponse) { + response = &ListPoliciesForGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_role.go new file mode 100644 index 0000000000..7888bc74f0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_role.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListPoliciesForRole invokes the ram.ListPoliciesForRole API synchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforrole.html +func (client *Client) ListPoliciesForRole(request *ListPoliciesForRoleRequest) (response *ListPoliciesForRoleResponse, err error) { + response = CreateListPoliciesForRoleResponse() + err = client.DoAction(request, response) + return +} + +// ListPoliciesForRoleWithChan invokes the ram.ListPoliciesForRole API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForRoleWithChan(request *ListPoliciesForRoleRequest) (<-chan *ListPoliciesForRoleResponse, <-chan error) { + responseChan := make(chan *ListPoliciesForRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListPoliciesForRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListPoliciesForRoleWithCallback invokes the ram.ListPoliciesForRole API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforrole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForRoleWithCallback(request *ListPoliciesForRoleRequest, callback func(response *ListPoliciesForRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListPoliciesForRoleResponse + var err error + defer close(result) + response, err = client.ListPoliciesForRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListPoliciesForRoleRequest is the request struct for api ListPoliciesForRole +type ListPoliciesForRoleRequest struct { + *requests.RpcRequest + RoleName string `position:"Query" name:"RoleName"` +} + +// ListPoliciesForRoleResponse is the response struct for api ListPoliciesForRole +type ListPoliciesForRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Policies PoliciesInListPoliciesForRole `json:"Policies" xml:"Policies"` +} + +// CreateListPoliciesForRoleRequest creates a request to invoke ListPoliciesForRole API +func CreateListPoliciesForRoleRequest() (request *ListPoliciesForRoleRequest) { + request = &ListPoliciesForRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListPoliciesForRole", "Ram", "openAPI") + return +} + +// CreateListPoliciesForRoleResponse creates a response to parse from ListPoliciesForRole response +func CreateListPoliciesForRoleResponse() (response *ListPoliciesForRoleResponse) { + response = &ListPoliciesForRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_user.go new file mode 100644 index 0000000000..74ba7b244e --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policies_for_user.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListPoliciesForUser invokes the ram.ListPoliciesForUser API synchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforuser.html +func (client *Client) ListPoliciesForUser(request *ListPoliciesForUserRequest) (response *ListPoliciesForUserResponse, err error) { + response = CreateListPoliciesForUserResponse() + err = client.DoAction(request, response) + return +} + +// ListPoliciesForUserWithChan invokes the ram.ListPoliciesForUser API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForUserWithChan(request *ListPoliciesForUserRequest) (<-chan *ListPoliciesForUserResponse, <-chan error) { + responseChan := make(chan *ListPoliciesForUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListPoliciesForUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListPoliciesForUserWithCallback invokes the ram.ListPoliciesForUser API asynchronously +// api document: https://help.aliyun.com/api/ram/listpoliciesforuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPoliciesForUserWithCallback(request *ListPoliciesForUserRequest, callback func(response *ListPoliciesForUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListPoliciesForUserResponse + var err error + defer close(result) + response, err = client.ListPoliciesForUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListPoliciesForUserRequest is the request struct for api ListPoliciesForUser +type ListPoliciesForUserRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// ListPoliciesForUserResponse is the response struct for api ListPoliciesForUser +type ListPoliciesForUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Policies PoliciesInListPoliciesForUser `json:"Policies" xml:"Policies"` +} + +// CreateListPoliciesForUserRequest creates a request to invoke ListPoliciesForUser API +func CreateListPoliciesForUserRequest() (request *ListPoliciesForUserRequest) { + request = &ListPoliciesForUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListPoliciesForUser", "Ram", "openAPI") + return +} + +// CreateListPoliciesForUserResponse creates a response to parse from ListPoliciesForUser response +func CreateListPoliciesForUserResponse() (response *ListPoliciesForUserResponse) { + response = &ListPoliciesForUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policy_versions.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policy_versions.go new file mode 100644 index 0000000000..626bf18d12 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_policy_versions.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListPolicyVersions invokes the ram.ListPolicyVersions API synchronously +// api document: https://help.aliyun.com/api/ram/listpolicyversions.html +func (client *Client) ListPolicyVersions(request *ListPolicyVersionsRequest) (response *ListPolicyVersionsResponse, err error) { + response = CreateListPolicyVersionsResponse() + err = client.DoAction(request, response) + return +} + +// ListPolicyVersionsWithChan invokes the ram.ListPolicyVersions API asynchronously +// api document: https://help.aliyun.com/api/ram/listpolicyversions.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPolicyVersionsWithChan(request *ListPolicyVersionsRequest) (<-chan *ListPolicyVersionsResponse, <-chan error) { + responseChan := make(chan *ListPolicyVersionsResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListPolicyVersions(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListPolicyVersionsWithCallback invokes the ram.ListPolicyVersions API asynchronously +// api document: https://help.aliyun.com/api/ram/listpolicyversions.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListPolicyVersionsWithCallback(request *ListPolicyVersionsRequest, callback func(response *ListPolicyVersionsResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListPolicyVersionsResponse + var err error + defer close(result) + response, err = client.ListPolicyVersions(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListPolicyVersionsRequest is the request struct for api ListPolicyVersions +type ListPolicyVersionsRequest struct { + *requests.RpcRequest + PolicyType string `position:"Query" name:"PolicyType"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// ListPolicyVersionsResponse is the response struct for api ListPolicyVersions +type ListPolicyVersionsResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + PolicyVersions PolicyVersions `json:"PolicyVersions" xml:"PolicyVersions"` +} + +// CreateListPolicyVersionsRequest creates a request to invoke ListPolicyVersions API +func CreateListPolicyVersionsRequest() (request *ListPolicyVersionsRequest) { + request = &ListPolicyVersionsRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListPolicyVersions", "Ram", "openAPI") + return +} + +// CreateListPolicyVersionsResponse creates a response to parse from ListPolicyVersions response +func CreateListPolicyVersionsResponse() (response *ListPolicyVersionsResponse) { + response = &ListPolicyVersionsResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_roles.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_roles.go new file mode 100644 index 0000000000..01f9652c07 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_roles.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListRoles invokes the ram.ListRoles API synchronously +// api document: https://help.aliyun.com/api/ram/listroles.html +func (client *Client) ListRoles(request *ListRolesRequest) (response *ListRolesResponse, err error) { + response = CreateListRolesResponse() + err = client.DoAction(request, response) + return +} + +// ListRolesWithChan invokes the ram.ListRoles API asynchronously +// api document: https://help.aliyun.com/api/ram/listroles.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListRolesWithChan(request *ListRolesRequest) (<-chan *ListRolesResponse, <-chan error) { + responseChan := make(chan *ListRolesResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListRoles(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListRolesWithCallback invokes the ram.ListRoles API asynchronously +// api document: https://help.aliyun.com/api/ram/listroles.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListRolesWithCallback(request *ListRolesRequest, callback func(response *ListRolesResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListRolesResponse + var err error + defer close(result) + response, err = client.ListRoles(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListRolesRequest is the request struct for api ListRoles +type ListRolesRequest struct { + *requests.RpcRequest + Marker string `position:"Query" name:"Marker"` + MaxItems requests.Integer `position:"Query" name:"MaxItems"` +} + +// ListRolesResponse is the response struct for api ListRoles +type ListRolesResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + IsTruncated bool `json:"IsTruncated" xml:"IsTruncated"` + Marker string `json:"Marker" xml:"Marker"` + Roles RolesInListRoles `json:"Roles" xml:"Roles"` +} + +// CreateListRolesRequest creates a request to invoke ListRoles API +func CreateListRolesRequest() (request *ListRolesRequest) { + request = &ListRolesRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListRoles", "Ram", "openAPI") + return +} + +// CreateListRolesResponse creates a response to parse from ListRoles response +func CreateListRolesResponse() (response *ListRolesResponse) { + response = &ListRolesResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users.go new file mode 100644 index 0000000000..6ad3c67b41 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users.go @@ -0,0 +1,107 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListUsers invokes the ram.ListUsers API synchronously +// api document: https://help.aliyun.com/api/ram/listusers.html +func (client *Client) ListUsers(request *ListUsersRequest) (response *ListUsersResponse, err error) { + response = CreateListUsersResponse() + err = client.DoAction(request, response) + return +} + +// ListUsersWithChan invokes the ram.ListUsers API asynchronously +// api document: https://help.aliyun.com/api/ram/listusers.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListUsersWithChan(request *ListUsersRequest) (<-chan *ListUsersResponse, <-chan error) { + responseChan := make(chan *ListUsersResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListUsers(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListUsersWithCallback invokes the ram.ListUsers API asynchronously +// api document: https://help.aliyun.com/api/ram/listusers.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListUsersWithCallback(request *ListUsersRequest, callback func(response *ListUsersResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListUsersResponse + var err error + defer close(result) + response, err = client.ListUsers(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListUsersRequest is the request struct for api ListUsers +type ListUsersRequest struct { + *requests.RpcRequest + Marker string `position:"Query" name:"Marker"` + MaxItems requests.Integer `position:"Query" name:"MaxItems"` +} + +// ListUsersResponse is the response struct for api ListUsers +type ListUsersResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + IsTruncated bool `json:"IsTruncated" xml:"IsTruncated"` + Marker string `json:"Marker" xml:"Marker"` + Users UsersInListUsers `json:"Users" xml:"Users"` +} + +// CreateListUsersRequest creates a request to invoke ListUsers API +func CreateListUsersRequest() (request *ListUsersRequest) { + request = &ListUsersRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListUsers", "Ram", "openAPI") + return +} + +// CreateListUsersResponse creates a response to parse from ListUsers response +func CreateListUsersResponse() (response *ListUsersResponse) { + response = &ListUsersResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users_for_group.go new file mode 100644 index 0000000000..a3c2969a96 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_users_for_group.go @@ -0,0 +1,108 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListUsersForGroup invokes the ram.ListUsersForGroup API synchronously +// api document: https://help.aliyun.com/api/ram/listusersforgroup.html +func (client *Client) ListUsersForGroup(request *ListUsersForGroupRequest) (response *ListUsersForGroupResponse, err error) { + response = CreateListUsersForGroupResponse() + err = client.DoAction(request, response) + return +} + +// ListUsersForGroupWithChan invokes the ram.ListUsersForGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/listusersforgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListUsersForGroupWithChan(request *ListUsersForGroupRequest) (<-chan *ListUsersForGroupResponse, <-chan error) { + responseChan := make(chan *ListUsersForGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListUsersForGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListUsersForGroupWithCallback invokes the ram.ListUsersForGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/listusersforgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListUsersForGroupWithCallback(request *ListUsersForGroupRequest, callback func(response *ListUsersForGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListUsersForGroupResponse + var err error + defer close(result) + response, err = client.ListUsersForGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListUsersForGroupRequest is the request struct for api ListUsersForGroup +type ListUsersForGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` + Marker string `position:"Query" name:"Marker"` + MaxItems requests.Integer `position:"Query" name:"MaxItems"` +} + +// ListUsersForGroupResponse is the response struct for api ListUsersForGroup +type ListUsersForGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + IsTruncated bool `json:"IsTruncated" xml:"IsTruncated"` + Marker string `json:"Marker" xml:"Marker"` + Users UsersInListUsersForGroup `json:"Users" xml:"Users"` +} + +// CreateListUsersForGroupRequest creates a request to invoke ListUsersForGroup API +func CreateListUsersForGroupRequest() (request *ListUsersForGroupRequest) { + request = &ListUsersForGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListUsersForGroup", "Ram", "openAPI") + return +} + +// CreateListUsersForGroupResponse creates a response to parse from ListUsersForGroup response +func CreateListUsersForGroupResponse() (response *ListUsersForGroupResponse) { + response = &ListUsersForGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_virtual_mfa_devices.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_virtual_mfa_devices.go new file mode 100644 index 0000000000..aa9f746528 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/list_virtual_mfa_devices.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// ListVirtualMFADevices invokes the ram.ListVirtualMFADevices API synchronously +// api document: https://help.aliyun.com/api/ram/listvirtualmfadevices.html +func (client *Client) ListVirtualMFADevices(request *ListVirtualMFADevicesRequest) (response *ListVirtualMFADevicesResponse, err error) { + response = CreateListVirtualMFADevicesResponse() + err = client.DoAction(request, response) + return +} + +// ListVirtualMFADevicesWithChan invokes the ram.ListVirtualMFADevices API asynchronously +// api document: https://help.aliyun.com/api/ram/listvirtualmfadevices.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListVirtualMFADevicesWithChan(request *ListVirtualMFADevicesRequest) (<-chan *ListVirtualMFADevicesResponse, <-chan error) { + responseChan := make(chan *ListVirtualMFADevicesResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.ListVirtualMFADevices(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// ListVirtualMFADevicesWithCallback invokes the ram.ListVirtualMFADevices API asynchronously +// api document: https://help.aliyun.com/api/ram/listvirtualmfadevices.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) ListVirtualMFADevicesWithCallback(request *ListVirtualMFADevicesRequest, callback func(response *ListVirtualMFADevicesResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *ListVirtualMFADevicesResponse + var err error + defer close(result) + response, err = client.ListVirtualMFADevices(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// ListVirtualMFADevicesRequest is the request struct for api ListVirtualMFADevices +type ListVirtualMFADevicesRequest struct { + *requests.RpcRequest +} + +// ListVirtualMFADevicesResponse is the response struct for api ListVirtualMFADevices +type ListVirtualMFADevicesResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + VirtualMFADevices VirtualMFADevices `json:"VirtualMFADevices" xml:"VirtualMFADevices"` +} + +// CreateListVirtualMFADevicesRequest creates a request to invoke ListVirtualMFADevices API +func CreateListVirtualMFADevicesRequest() (request *ListVirtualMFADevicesRequest) { + request = &ListVirtualMFADevicesRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "ListVirtualMFADevices", "Ram", "openAPI") + return +} + +// CreateListVirtualMFADevicesResponse creates a response to parse from ListVirtualMFADevices response +func CreateListVirtualMFADevicesResponse() (response *ListVirtualMFADevicesResponse) { + response = &ListVirtualMFADevicesResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/remove_user_from_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/remove_user_from_group.go new file mode 100644 index 0000000000..945dfaf200 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/remove_user_from_group.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// RemoveUserFromGroup invokes the ram.RemoveUserFromGroup API synchronously +// api document: https://help.aliyun.com/api/ram/removeuserfromgroup.html +func (client *Client) RemoveUserFromGroup(request *RemoveUserFromGroupRequest) (response *RemoveUserFromGroupResponse, err error) { + response = CreateRemoveUserFromGroupResponse() + err = client.DoAction(request, response) + return +} + +// RemoveUserFromGroupWithChan invokes the ram.RemoveUserFromGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/removeuserfromgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) RemoveUserFromGroupWithChan(request *RemoveUserFromGroupRequest) (<-chan *RemoveUserFromGroupResponse, <-chan error) { + responseChan := make(chan *RemoveUserFromGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.RemoveUserFromGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// RemoveUserFromGroupWithCallback invokes the ram.RemoveUserFromGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/removeuserfromgroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) RemoveUserFromGroupWithCallback(request *RemoveUserFromGroupRequest, callback func(response *RemoveUserFromGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *RemoveUserFromGroupResponse + var err error + defer close(result) + response, err = client.RemoveUserFromGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// RemoveUserFromGroupRequest is the request struct for api RemoveUserFromGroup +type RemoveUserFromGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` + UserName string `position:"Query" name:"UserName"` +} + +// RemoveUserFromGroupResponse is the response struct for api RemoveUserFromGroup +type RemoveUserFromGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateRemoveUserFromGroupRequest creates a request to invoke RemoveUserFromGroup API +func CreateRemoveUserFromGroupRequest() (request *RemoveUserFromGroupRequest) { + request = &RemoveUserFromGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "RemoveUserFromGroup", "Ram", "openAPI") + return +} + +// CreateRemoveUserFromGroupResponse creates a response to parse from RemoveUserFromGroup response +func CreateRemoveUserFromGroupResponse() (response *RemoveUserFromGroupResponse) { + response = &RemoveUserFromGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_account_alias.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_account_alias.go new file mode 100644 index 0000000000..537805d044 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_account_alias.go @@ -0,0 +1,103 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// SetAccountAlias invokes the ram.SetAccountAlias API synchronously +// api document: https://help.aliyun.com/api/ram/setaccountalias.html +func (client *Client) SetAccountAlias(request *SetAccountAliasRequest) (response *SetAccountAliasResponse, err error) { + response = CreateSetAccountAliasResponse() + err = client.DoAction(request, response) + return +} + +// SetAccountAliasWithChan invokes the ram.SetAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/setaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetAccountAliasWithChan(request *SetAccountAliasRequest) (<-chan *SetAccountAliasResponse, <-chan error) { + responseChan := make(chan *SetAccountAliasResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.SetAccountAlias(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// SetAccountAliasWithCallback invokes the ram.SetAccountAlias API asynchronously +// api document: https://help.aliyun.com/api/ram/setaccountalias.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetAccountAliasWithCallback(request *SetAccountAliasRequest, callback func(response *SetAccountAliasResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *SetAccountAliasResponse + var err error + defer close(result) + response, err = client.SetAccountAlias(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// SetAccountAliasRequest is the request struct for api SetAccountAlias +type SetAccountAliasRequest struct { + *requests.RpcRequest + AccountAlias string `position:"Query" name:"AccountAlias"` +} + +// SetAccountAliasResponse is the response struct for api SetAccountAlias +type SetAccountAliasResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateSetAccountAliasRequest creates a request to invoke SetAccountAlias API +func CreateSetAccountAliasRequest() (request *SetAccountAliasRequest) { + request = &SetAccountAliasRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "SetAccountAlias", "Ram", "openAPI") + return +} + +// CreateSetAccountAliasResponse creates a response to parse from SetAccountAlias response +func CreateSetAccountAliasResponse() (response *SetAccountAliasResponse) { + response = &SetAccountAliasResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_default_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_default_policy_version.go new file mode 100644 index 0000000000..f1f8b07358 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_default_policy_version.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// SetDefaultPolicyVersion invokes the ram.SetDefaultPolicyVersion API synchronously +// api document: https://help.aliyun.com/api/ram/setdefaultpolicyversion.html +func (client *Client) SetDefaultPolicyVersion(request *SetDefaultPolicyVersionRequest) (response *SetDefaultPolicyVersionResponse, err error) { + response = CreateSetDefaultPolicyVersionResponse() + err = client.DoAction(request, response) + return +} + +// SetDefaultPolicyVersionWithChan invokes the ram.SetDefaultPolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/setdefaultpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetDefaultPolicyVersionWithChan(request *SetDefaultPolicyVersionRequest) (<-chan *SetDefaultPolicyVersionResponse, <-chan error) { + responseChan := make(chan *SetDefaultPolicyVersionResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.SetDefaultPolicyVersion(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// SetDefaultPolicyVersionWithCallback invokes the ram.SetDefaultPolicyVersion API asynchronously +// api document: https://help.aliyun.com/api/ram/setdefaultpolicyversion.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetDefaultPolicyVersionWithCallback(request *SetDefaultPolicyVersionRequest, callback func(response *SetDefaultPolicyVersionResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *SetDefaultPolicyVersionResponse + var err error + defer close(result) + response, err = client.SetDefaultPolicyVersion(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// SetDefaultPolicyVersionRequest is the request struct for api SetDefaultPolicyVersion +type SetDefaultPolicyVersionRequest struct { + *requests.RpcRequest + VersionId string `position:"Query" name:"VersionId"` + PolicyName string `position:"Query" name:"PolicyName"` +} + +// SetDefaultPolicyVersionResponse is the response struct for api SetDefaultPolicyVersion +type SetDefaultPolicyVersionResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateSetDefaultPolicyVersionRequest creates a request to invoke SetDefaultPolicyVersion API +func CreateSetDefaultPolicyVersionRequest() (request *SetDefaultPolicyVersionRequest) { + request = &SetDefaultPolicyVersionRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "SetDefaultPolicyVersion", "Ram", "openAPI") + return +} + +// CreateSetDefaultPolicyVersionResponse creates a response to parse from SetDefaultPolicyVersion response +func CreateSetDefaultPolicyVersionResponse() (response *SetDefaultPolicyVersionResponse) { + response = &SetDefaultPolicyVersionResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_password_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_password_policy.go new file mode 100644 index 0000000000..de68898458 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_password_policy.go @@ -0,0 +1,112 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// SetPasswordPolicy invokes the ram.SetPasswordPolicy API synchronously +// api document: https://help.aliyun.com/api/ram/setpasswordpolicy.html +func (client *Client) SetPasswordPolicy(request *SetPasswordPolicyRequest) (response *SetPasswordPolicyResponse, err error) { + response = CreateSetPasswordPolicyResponse() + err = client.DoAction(request, response) + return +} + +// SetPasswordPolicyWithChan invokes the ram.SetPasswordPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/setpasswordpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetPasswordPolicyWithChan(request *SetPasswordPolicyRequest) (<-chan *SetPasswordPolicyResponse, <-chan error) { + responseChan := make(chan *SetPasswordPolicyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.SetPasswordPolicy(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// SetPasswordPolicyWithCallback invokes the ram.SetPasswordPolicy API asynchronously +// api document: https://help.aliyun.com/api/ram/setpasswordpolicy.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetPasswordPolicyWithCallback(request *SetPasswordPolicyRequest, callback func(response *SetPasswordPolicyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *SetPasswordPolicyResponse + var err error + defer close(result) + response, err = client.SetPasswordPolicy(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// SetPasswordPolicyRequest is the request struct for api SetPasswordPolicy +type SetPasswordPolicyRequest struct { + *requests.RpcRequest + PasswordReusePrevention requests.Integer `position:"Query" name:"PasswordReusePrevention"` + RequireUppercaseCharacters requests.Boolean `position:"Query" name:"RequireUppercaseCharacters"` + MinimumPasswordLength requests.Integer `position:"Query" name:"MinimumPasswordLength"` + RequireNumbers requests.Boolean `position:"Query" name:"RequireNumbers"` + RequireLowercaseCharacters requests.Boolean `position:"Query" name:"RequireLowercaseCharacters"` + MaxPasswordAge requests.Integer `position:"Query" name:"MaxPasswordAge"` + MaxLoginAttemps requests.Integer `position:"Query" name:"MaxLoginAttemps"` + HardExpiry requests.Boolean `position:"Query" name:"HardExpiry"` + RequireSymbols requests.Boolean `position:"Query" name:"RequireSymbols"` +} + +// SetPasswordPolicyResponse is the response struct for api SetPasswordPolicy +type SetPasswordPolicyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + PasswordPolicy PasswordPolicyInSetPasswordPolicy `json:"PasswordPolicy" xml:"PasswordPolicy"` +} + +// CreateSetPasswordPolicyRequest creates a request to invoke SetPasswordPolicy API +func CreateSetPasswordPolicyRequest() (request *SetPasswordPolicyRequest) { + request = &SetPasswordPolicyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "SetPasswordPolicy", "Ram", "openAPI") + return +} + +// CreateSetPasswordPolicyResponse creates a response to parse from SetPasswordPolicy response +func CreateSetPasswordPolicyResponse() (response *SetPasswordPolicyResponse) { + response = &SetPasswordPolicyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_security_preference.go new file mode 100644 index 0000000000..6675544627 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/set_security_preference.go @@ -0,0 +1,110 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// SetSecurityPreference invokes the ram.SetSecurityPreference API synchronously +// api document: https://help.aliyun.com/api/ram/setsecuritypreference.html +func (client *Client) SetSecurityPreference(request *SetSecurityPreferenceRequest) (response *SetSecurityPreferenceResponse, err error) { + response = CreateSetSecurityPreferenceResponse() + err = client.DoAction(request, response) + return +} + +// SetSecurityPreferenceWithChan invokes the ram.SetSecurityPreference API asynchronously +// api document: https://help.aliyun.com/api/ram/setsecuritypreference.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetSecurityPreferenceWithChan(request *SetSecurityPreferenceRequest) (<-chan *SetSecurityPreferenceResponse, <-chan error) { + responseChan := make(chan *SetSecurityPreferenceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.SetSecurityPreference(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// SetSecurityPreferenceWithCallback invokes the ram.SetSecurityPreference API asynchronously +// api document: https://help.aliyun.com/api/ram/setsecuritypreference.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) SetSecurityPreferenceWithCallback(request *SetSecurityPreferenceRequest, callback func(response *SetSecurityPreferenceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *SetSecurityPreferenceResponse + var err error + defer close(result) + response, err = client.SetSecurityPreference(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// SetSecurityPreferenceRequest is the request struct for api SetSecurityPreference +type SetSecurityPreferenceRequest struct { + *requests.RpcRequest + EnableSaveMFATicket requests.Boolean `position:"Query" name:"EnableSaveMFATicket"` + LoginNetworkMasks string `position:"Query" name:"LoginNetworkMasks"` + AllowUserToChangePassword requests.Boolean `position:"Query" name:"AllowUserToChangePassword"` + AllowUserToManagePublicKeys requests.Boolean `position:"Query" name:"AllowUserToManagePublicKeys"` + LoginSessionDuration requests.Integer `position:"Query" name:"LoginSessionDuration"` + AllowUserToManageAccessKeys requests.Boolean `position:"Query" name:"AllowUserToManageAccessKeys"` + AllowUserToManageMFADevices requests.Boolean `position:"Query" name:"AllowUserToManageMFADevices"` +} + +// SetSecurityPreferenceResponse is the response struct for api SetSecurityPreference +type SetSecurityPreferenceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + SecurityPreference SecurityPreferenceInSetSecurityPreference `json:"SecurityPreference" xml:"SecurityPreference"` +} + +// CreateSetSecurityPreferenceRequest creates a request to invoke SetSecurityPreference API +func CreateSetSecurityPreferenceRequest() (request *SetSecurityPreferenceRequest) { + request = &SetSecurityPreferenceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "SetSecurityPreference", "Ram", "openAPI") + return +} + +// CreateSetSecurityPreferenceResponse creates a response to parse from SetSecurityPreference response +func CreateSetSecurityPreferenceResponse() (response *SetSecurityPreferenceResponse) { + response = &SetSecurityPreferenceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_create_access_key.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_create_access_key.go new file mode 100644 index 0000000000..da027dc30f --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_create_access_key.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyInCreateAccessKey is a nested struct in ram response +type AccessKeyInCreateAccessKey struct { + AccessKeyId string `json:"AccessKeyId" xml:"AccessKeyId"` + AccessKeySecret string `json:"AccessKeySecret" xml:"AccessKeySecret"` + Status string `json:"Status" xml:"Status"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_list_access_keys.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_list_access_keys.go new file mode 100644 index 0000000000..64e52b98d1 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_in_list_access_keys.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyInListAccessKeys is a nested struct in ram response +type AccessKeyInListAccessKeys struct { + AccessKeyId string `json:"AccessKeyId" xml:"AccessKeyId"` + Status string `json:"Status" xml:"Status"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_last_used.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_last_used.go new file mode 100644 index 0000000000..7d9c94e393 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_last_used.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyLastUsed is a nested struct in ram response +type AccessKeyLastUsed struct { + LastUsedDate string `json:"LastUsedDate" xml:"LastUsedDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_get_security_preference.go new file mode 100644 index 0000000000..66eaf3597d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_get_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyPreferenceInGetSecurityPreference is a nested struct in ram response +type AccessKeyPreferenceInGetSecurityPreference struct { + AllowUserToManageAccessKeys bool `json:"AllowUserToManageAccessKeys" xml:"AllowUserToManageAccessKeys"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_set_security_preference.go new file mode 100644 index 0000000000..aff470b468 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_key_preference_in_set_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyPreferenceInSetSecurityPreference is a nested struct in ram response +type AccessKeyPreferenceInSetSecurityPreference struct { + AllowUserToManageAccessKeys bool `json:"AllowUserToManageAccessKeys" xml:"AllowUserToManageAccessKeys"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_keys.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_keys.go new file mode 100644 index 0000000000..416b076325 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_access_keys.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeys is a nested struct in ram response +type AccessKeys struct { + AccessKey []AccessKeyInListAccessKeys `json:"AccessKey" xml:"AccessKey"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_default_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_default_policy_version.go new file mode 100644 index 0000000000..a38dddac0d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_default_policy_version.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// DefaultPolicyVersion is a nested struct in ram response +type DefaultPolicyVersion struct { + VersionId string `json:"VersionId" xml:"VersionId"` + IsDefaultVersion bool `json:"IsDefaultVersion" xml:"IsDefaultVersion"` + PolicyDocument string `json:"PolicyDocument" xml:"PolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_create_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_create_group.go new file mode 100644 index 0000000000..a1e3a99ce2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_create_group.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInCreateGroup is a nested struct in ram response +type GroupInCreateGroup struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_get_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_get_group.go new file mode 100644 index 0000000000..7214a077d8 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_get_group.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInGetGroup is a nested struct in ram response +type GroupInGetGroup struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_entities_for_policy.go new file mode 100644 index 0000000000..73c25e380a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_entities_for_policy.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInListEntitiesForPolicy is a nested struct in ram response +type GroupInListEntitiesForPolicy struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups.go new file mode 100644 index 0000000000..995d7bf91c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInListGroups is a nested struct in ram response +type GroupInListGroups struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups_for_user.go new file mode 100644 index 0000000000..1aa93f71cd --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_list_groups_for_user.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInListGroupsForUser is a nested struct in ram response +type GroupInListGroupsForUser struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + JoinDate string `json:"JoinDate" xml:"JoinDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_update_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_update_group.go new file mode 100644 index 0000000000..5a6364a2aa --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_group_in_update_group.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupInUpdateGroup is a nested struct in ram response +type GroupInUpdateGroup struct { + GroupName string `json:"GroupName" xml:"GroupName"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_entities_for_policy.go new file mode 100644 index 0000000000..fa341edefa --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_entities_for_policy.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupsInListEntitiesForPolicy is a nested struct in ram response +type GroupsInListEntitiesForPolicy struct { + Group []GroupInListEntitiesForPolicy `json:"Group" xml:"Group"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups.go new file mode 100644 index 0000000000..a5175f2a24 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupsInListGroups is a nested struct in ram response +type GroupsInListGroups struct { + Group []GroupInListGroups `json:"Group" xml:"Group"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups_for_user.go new file mode 100644 index 0000000000..0404a97b02 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_groups_in_list_groups_for_user.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// GroupsInListGroupsForUser is a nested struct in ram response +type GroupsInListGroupsForUser struct { + Group []GroupInListGroupsForUser `json:"Group" xml:"Group"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_create_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_create_login_profile.go new file mode 100644 index 0000000000..f5c5e85c23 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_create_login_profile.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// LoginProfileInCreateLoginProfile is a nested struct in ram response +type LoginProfileInCreateLoginProfile struct { + UserName string `json:"UserName" xml:"UserName"` + PasswordResetRequired bool `json:"PasswordResetRequired" xml:"PasswordResetRequired"` + MFABindRequired bool `json:"MFABindRequired" xml:"MFABindRequired"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_get_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_get_login_profile.go new file mode 100644 index 0000000000..c938d4f5e5 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_in_get_login_profile.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// LoginProfileInGetLoginProfile is a nested struct in ram response +type LoginProfileInGetLoginProfile struct { + UserName string `json:"UserName" xml:"UserName"` + PasswordResetRequired bool `json:"PasswordResetRequired" xml:"PasswordResetRequired"` + MFABindRequired bool `json:"MFABindRequired" xml:"MFABindRequired"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_get_security_preference.go new file mode 100644 index 0000000000..306f93c975 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_get_security_preference.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// LoginProfilePreferenceInGetSecurityPreference is a nested struct in ram response +type LoginProfilePreferenceInGetSecurityPreference struct { + EnableSaveMFATicket bool `json:"EnableSaveMFATicket" xml:"EnableSaveMFATicket"` + AllowUserToChangePassword bool `json:"AllowUserToChangePassword" xml:"AllowUserToChangePassword"` + LoginSessionDuration int `json:"LoginSessionDuration" xml:"LoginSessionDuration"` + LoginNetworkMasks string `json:"LoginNetworkMasks" xml:"LoginNetworkMasks"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_set_security_preference.go new file mode 100644 index 0000000000..44c1e1cb0d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_login_profile_preference_in_set_security_preference.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// LoginProfilePreferenceInSetSecurityPreference is a nested struct in ram response +type LoginProfilePreferenceInSetSecurityPreference struct { + EnableSaveMFATicket bool `json:"EnableSaveMFATicket" xml:"EnableSaveMFATicket"` + AllowUserToChangePassword bool `json:"AllowUserToChangePassword" xml:"AllowUserToChangePassword"` + LoginSessionDuration int `json:"LoginSessionDuration" xml:"LoginSessionDuration"` + LoginNetworkMasks string `json:"LoginNetworkMasks" xml:"LoginNetworkMasks"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_get_user_mfa_info.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_get_user_mfa_info.go new file mode 100644 index 0000000000..95f373857d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_get_user_mfa_info.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// MFADeviceInGetUserMFAInfo is a nested struct in ram response +type MFADeviceInGetUserMFAInfo struct { + SerialNumber string `json:"SerialNumber" xml:"SerialNumber"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_unbind_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_unbind_mfa_device.go new file mode 100644 index 0000000000..5bcfc02ba0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_device_in_unbind_mfa_device.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// MFADeviceInUnbindMFADevice is a nested struct in ram response +type MFADeviceInUnbindMFADevice struct { + SerialNumber string `json:"SerialNumber" xml:"SerialNumber"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_get_security_preference.go new file mode 100644 index 0000000000..fd08111d23 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_get_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// MFAPreferenceInGetSecurityPreference is a nested struct in ram response +type MFAPreferenceInGetSecurityPreference struct { + AllowUserToManageMFADevices bool `json:"AllowUserToManageMFADevices" xml:"AllowUserToManageMFADevices"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_set_security_preference.go new file mode 100644 index 0000000000..80f7e35666 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_mfa_preference_in_set_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// MFAPreferenceInSetSecurityPreference is a nested struct in ram response +type MFAPreferenceInSetSecurityPreference struct { + AllowUserToManageMFADevices bool `json:"AllowUserToManageMFADevices" xml:"AllowUserToManageMFADevices"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_get_password_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_get_password_policy.go new file mode 100644 index 0000000000..8f1d825ea0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_get_password_policy.go @@ -0,0 +1,29 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PasswordPolicyInGetPasswordPolicy is a nested struct in ram response +type PasswordPolicyInGetPasswordPolicy struct { + MinimumPasswordLength int `json:"MinimumPasswordLength" xml:"MinimumPasswordLength"` + RequireLowercaseCharacters bool `json:"RequireLowercaseCharacters" xml:"RequireLowercaseCharacters"` + RequireUppercaseCharacters bool `json:"RequireUppercaseCharacters" xml:"RequireUppercaseCharacters"` + RequireNumbers bool `json:"RequireNumbers" xml:"RequireNumbers"` + RequireSymbols bool `json:"RequireSymbols" xml:"RequireSymbols"` + HardExpiry bool `json:"HardExpiry" xml:"HardExpiry"` + MaxPasswordAge int `json:"MaxPasswordAge" xml:"MaxPasswordAge"` + PasswordReusePrevention int `json:"PasswordReusePrevention" xml:"PasswordReusePrevention"` + MaxLoginAttemps int `json:"MaxLoginAttemps" xml:"MaxLoginAttemps"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_set_password_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_set_password_policy.go new file mode 100644 index 0000000000..42ea19e5fa --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_password_policy_in_set_password_policy.go @@ -0,0 +1,29 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PasswordPolicyInSetPasswordPolicy is a nested struct in ram response +type PasswordPolicyInSetPasswordPolicy struct { + MinimumPasswordLength int `json:"MinimumPasswordLength" xml:"MinimumPasswordLength"` + RequireLowercaseCharacters bool `json:"RequireLowercaseCharacters" xml:"RequireLowercaseCharacters"` + RequireUppercaseCharacters bool `json:"RequireUppercaseCharacters" xml:"RequireUppercaseCharacters"` + RequireNumbers bool `json:"RequireNumbers" xml:"RequireNumbers"` + RequireSymbols bool `json:"RequireSymbols" xml:"RequireSymbols"` + HardExpiry bool `json:"HardExpiry" xml:"HardExpiry"` + MaxPasswordAge int `json:"MaxPasswordAge" xml:"MaxPasswordAge"` + PasswordReusePrevention int `json:"PasswordReusePrevention" xml:"PasswordReusePrevention"` + MaxLoginAttemps int `json:"MaxLoginAttemps" xml:"MaxLoginAttemps"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies.go new file mode 100644 index 0000000000..a4e3e9cf37 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PoliciesInListPolicies is a nested struct in ram response +type PoliciesInListPolicies struct { + Policy []PolicyInListPolicies `json:"Policy" xml:"Policy"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_group.go new file mode 100644 index 0000000000..cd1d6e9d73 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_group.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PoliciesInListPoliciesForGroup is a nested struct in ram response +type PoliciesInListPoliciesForGroup struct { + Policy []PolicyInListPoliciesForGroup `json:"Policy" xml:"Policy"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_role.go new file mode 100644 index 0000000000..6673f081df --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_role.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PoliciesInListPoliciesForRole is a nested struct in ram response +type PoliciesInListPoliciesForRole struct { + Policy []PolicyInListPoliciesForRole `json:"Policy" xml:"Policy"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_user.go new file mode 100644 index 0000000000..fedaf99127 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policies_in_list_policies_for_user.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PoliciesInListPoliciesForUser is a nested struct in ram response +type PoliciesInListPoliciesForUser struct { + Policy []PolicyInListPoliciesForUser `json:"Policy" xml:"Policy"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_create_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_create_policy.go new file mode 100644 index 0000000000..76789e1efb --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_create_policy.go @@ -0,0 +1,25 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInCreatePolicy is a nested struct in ram response +type PolicyInCreatePolicy struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_get_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_get_policy.go new file mode 100644 index 0000000000..a074550dc1 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_get_policy.go @@ -0,0 +1,28 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInGetPolicy is a nested struct in ram response +type PolicyInGetPolicy struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + PolicyDocument string `json:"PolicyDocument" xml:"PolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + AttachmentCount int `json:"AttachmentCount" xml:"AttachmentCount"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies.go new file mode 100644 index 0000000000..2d522bea08 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies.go @@ -0,0 +1,27 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInListPolicies is a nested struct in ram response +type PolicyInListPolicies struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + AttachmentCount int `json:"AttachmentCount" xml:"AttachmentCount"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_group.go new file mode 100644 index 0000000000..420d684609 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_group.go @@ -0,0 +1,25 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInListPoliciesForGroup is a nested struct in ram response +type PolicyInListPoliciesForGroup struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_role.go new file mode 100644 index 0000000000..e739a004bb --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_role.go @@ -0,0 +1,25 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInListPoliciesForRole is a nested struct in ram response +type PolicyInListPoliciesForRole struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_user.go new file mode 100644 index 0000000000..fb9a2ea9ef --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_in_list_policies_for_user.go @@ -0,0 +1,25 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyInListPoliciesForUser is a nested struct in ram response +type PolicyInListPoliciesForUser struct { + PolicyName string `json:"PolicyName" xml:"PolicyName"` + PolicyType string `json:"PolicyType" xml:"PolicyType"` + Description string `json:"Description" xml:"Description"` + DefaultVersion string `json:"DefaultVersion" xml:"DefaultVersion"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_create_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_create_policy_version.go new file mode 100644 index 0000000000..c9ed51d709 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_create_policy_version.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyVersionInCreatePolicyVersion is a nested struct in ram response +type PolicyVersionInCreatePolicyVersion struct { + VersionId string `json:"VersionId" xml:"VersionId"` + IsDefaultVersion bool `json:"IsDefaultVersion" xml:"IsDefaultVersion"` + PolicyDocument string `json:"PolicyDocument" xml:"PolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_get_policy_version.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_get_policy_version.go new file mode 100644 index 0000000000..c28ecff5c7 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_get_policy_version.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyVersionInGetPolicyVersion is a nested struct in ram response +type PolicyVersionInGetPolicyVersion struct { + VersionId string `json:"VersionId" xml:"VersionId"` + IsDefaultVersion bool `json:"IsDefaultVersion" xml:"IsDefaultVersion"` + PolicyDocument string `json:"PolicyDocument" xml:"PolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_list_policy_versions.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_list_policy_versions.go new file mode 100644 index 0000000000..31d01ac42e --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_version_in_list_policy_versions.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyVersionInListPolicyVersions is a nested struct in ram response +type PolicyVersionInListPolicyVersions struct { + VersionId string `json:"VersionId" xml:"VersionId"` + IsDefaultVersion bool `json:"IsDefaultVersion" xml:"IsDefaultVersion"` + PolicyDocument string `json:"PolicyDocument" xml:"PolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_versions.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_versions.go new file mode 100644 index 0000000000..6575192d63 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_policy_versions.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PolicyVersions is a nested struct in ram response +type PolicyVersions struct { + PolicyVersion []PolicyVersionInListPolicyVersions `json:"PolicyVersion" xml:"PolicyVersion"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_get_security_preference.go new file mode 100644 index 0000000000..e43e84779d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_get_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PublicKeyPreferenceInGetSecurityPreference is a nested struct in ram response +type PublicKeyPreferenceInGetSecurityPreference struct { + AllowUserToManagePublicKeys bool `json:"AllowUserToManagePublicKeys" xml:"AllowUserToManagePublicKeys"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_set_security_preference.go new file mode 100644 index 0000000000..6877f174a5 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_public_key_preference_in_set_security_preference.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// PublicKeyPreferenceInSetSecurityPreference is a nested struct in ram response +type PublicKeyPreferenceInSetSecurityPreference struct { + AllowUserToManagePublicKeys bool `json:"AllowUserToManagePublicKeys" xml:"AllowUserToManagePublicKeys"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_create_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_create_role.go new file mode 100644 index 0000000000..13bb313006 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_create_role.go @@ -0,0 +1,27 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RoleInCreateRole is a nested struct in ram response +type RoleInCreateRole struct { + RoleId string `json:"RoleId" xml:"RoleId"` + RoleName string `json:"RoleName" xml:"RoleName"` + Arn string `json:"Arn" xml:"Arn"` + Description string `json:"Description" xml:"Description"` + AssumeRolePolicyDocument string `json:"AssumeRolePolicyDocument" xml:"AssumeRolePolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + MaxSessionDuration int64 `json:"MaxSessionDuration" xml:"MaxSessionDuration"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_get_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_get_role.go new file mode 100644 index 0000000000..526aaa5a88 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_get_role.go @@ -0,0 +1,28 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RoleInGetRole is a nested struct in ram response +type RoleInGetRole struct { + RoleId string `json:"RoleId" xml:"RoleId"` + RoleName string `json:"RoleName" xml:"RoleName"` + Arn string `json:"Arn" xml:"Arn"` + Description string `json:"Description" xml:"Description"` + AssumeRolePolicyDocument string `json:"AssumeRolePolicyDocument" xml:"AssumeRolePolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + MaxSessionDuration int64 `json:"MaxSessionDuration" xml:"MaxSessionDuration"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_entities_for_policy.go new file mode 100644 index 0000000000..d28f0a59ec --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_entities_for_policy.go @@ -0,0 +1,25 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RoleInListEntitiesForPolicy is a nested struct in ram response +type RoleInListEntitiesForPolicy struct { + RoleId string `json:"RoleId" xml:"RoleId"` + RoleName string `json:"RoleName" xml:"RoleName"` + Arn string `json:"Arn" xml:"Arn"` + Description string `json:"Description" xml:"Description"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_roles.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_roles.go new file mode 100644 index 0000000000..d805be6540 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_list_roles.go @@ -0,0 +1,27 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RoleInListRoles is a nested struct in ram response +type RoleInListRoles struct { + RoleId string `json:"RoleId" xml:"RoleId"` + RoleName string `json:"RoleName" xml:"RoleName"` + Arn string `json:"Arn" xml:"Arn"` + Description string `json:"Description" xml:"Description"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + MaxSessionDuration int64 `json:"MaxSessionDuration" xml:"MaxSessionDuration"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_update_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_update_role.go new file mode 100644 index 0000000000..ed5aaae94a --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_role_in_update_role.go @@ -0,0 +1,28 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RoleInUpdateRole is a nested struct in ram response +type RoleInUpdateRole struct { + RoleId string `json:"RoleId" xml:"RoleId"` + RoleName string `json:"RoleName" xml:"RoleName"` + Arn string `json:"Arn" xml:"Arn"` + Description string `json:"Description" xml:"Description"` + AssumeRolePolicyDocument string `json:"AssumeRolePolicyDocument" xml:"AssumeRolePolicyDocument"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + MaxSessionDuration int64 `json:"MaxSessionDuration" xml:"MaxSessionDuration"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_entities_for_policy.go new file mode 100644 index 0000000000..9363c55e40 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_entities_for_policy.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RolesInListEntitiesForPolicy is a nested struct in ram response +type RolesInListEntitiesForPolicy struct { + Role []RoleInListEntitiesForPolicy `json:"Role" xml:"Role"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_roles.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_roles.go new file mode 100644 index 0000000000..45f882b7a0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_roles_in_list_roles.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// RolesInListRoles is a nested struct in ram response +type RolesInListRoles struct { + Role []RoleInListRoles `json:"Role" xml:"Role"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_get_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_get_security_preference.go new file mode 100644 index 0000000000..f941a8e510 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_get_security_preference.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// SecurityPreferenceInGetSecurityPreference is a nested struct in ram response +type SecurityPreferenceInGetSecurityPreference struct { + LoginProfilePreference LoginProfilePreferenceInGetSecurityPreference `json:"LoginProfilePreference" xml:"LoginProfilePreference"` + AccessKeyPreference AccessKeyPreferenceInGetSecurityPreference `json:"AccessKeyPreference" xml:"AccessKeyPreference"` + PublicKeyPreference PublicKeyPreferenceInGetSecurityPreference `json:"PublicKeyPreference" xml:"PublicKeyPreference"` + MFAPreference MFAPreferenceInGetSecurityPreference `json:"MFAPreference" xml:"MFAPreference"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_set_security_preference.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_set_security_preference.go new file mode 100644 index 0000000000..d60fb13633 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_security_preference_in_set_security_preference.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// SecurityPreferenceInSetSecurityPreference is a nested struct in ram response +type SecurityPreferenceInSetSecurityPreference struct { + LoginProfilePreference LoginProfilePreferenceInSetSecurityPreference `json:"LoginProfilePreference" xml:"LoginProfilePreference"` + AccessKeyPreference AccessKeyPreferenceInSetSecurityPreference `json:"AccessKeyPreference" xml:"AccessKeyPreference"` + PublicKeyPreference PublicKeyPreferenceInSetSecurityPreference `json:"PublicKeyPreference" xml:"PublicKeyPreference"` + MFAPreference MFAPreferenceInSetSecurityPreference `json:"MFAPreference" xml:"MFAPreference"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_create_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_create_user.go new file mode 100644 index 0000000000..f37de285ed --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_create_user.go @@ -0,0 +1,27 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInCreateUser is a nested struct in ram response +type UserInCreateUser struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + MobilePhone string `json:"MobilePhone" xml:"MobilePhone"` + Email string `json:"Email" xml:"Email"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_get_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_get_user.go new file mode 100644 index 0000000000..c6c874ff21 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_get_user.go @@ -0,0 +1,29 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInGetUser is a nested struct in ram response +type UserInGetUser struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + MobilePhone string `json:"MobilePhone" xml:"MobilePhone"` + Email string `json:"Email" xml:"Email"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` + LastLoginDate string `json:"LastLoginDate" xml:"LastLoginDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_entities_for_policy.go new file mode 100644 index 0000000000..c8b9b41a0d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_entities_for_policy.go @@ -0,0 +1,24 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInListEntitiesForPolicy is a nested struct in ram response +type UserInListEntitiesForPolicy struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + AttachDate string `json:"AttachDate" xml:"AttachDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users.go new file mode 100644 index 0000000000..4938b512d2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users.go @@ -0,0 +1,28 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInListUsers is a nested struct in ram response +type UserInListUsers struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + MobilePhone string `json:"MobilePhone" xml:"MobilePhone"` + Email string `json:"Email" xml:"Email"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users_for_group.go new file mode 100644 index 0000000000..be94bbc811 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_users_for_group.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInListUsersForGroup is a nested struct in ram response +type UserInListUsersForGroup struct { + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + JoinDate string `json:"JoinDate" xml:"JoinDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_virtual_mfa_devices.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_virtual_mfa_devices.go new file mode 100644 index 0000000000..858bd03c9e --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_list_virtual_mfa_devices.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInListVirtualMFADevices is a nested struct in ram response +type UserInListVirtualMFADevices struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_update_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_update_user.go new file mode 100644 index 0000000000..b31c62c6de --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_user_in_update_user.go @@ -0,0 +1,28 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserInUpdateUser is a nested struct in ram response +type UserInUpdateUser struct { + UserId string `json:"UserId" xml:"UserId"` + UserName string `json:"UserName" xml:"UserName"` + DisplayName string `json:"DisplayName" xml:"DisplayName"` + MobilePhone string `json:"MobilePhone" xml:"MobilePhone"` + Email string `json:"Email" xml:"Email"` + Comments string `json:"Comments" xml:"Comments"` + CreateDate string `json:"CreateDate" xml:"CreateDate"` + UpdateDate string `json:"UpdateDate" xml:"UpdateDate"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_entities_for_policy.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_entities_for_policy.go new file mode 100644 index 0000000000..c33e279a6c --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_entities_for_policy.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UsersInListEntitiesForPolicy is a nested struct in ram response +type UsersInListEntitiesForPolicy struct { + User []UserInListEntitiesForPolicy `json:"User" xml:"User"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users.go new file mode 100644 index 0000000000..9d2d7f7eaf --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UsersInListUsers is a nested struct in ram response +type UsersInListUsers struct { + User []UserInListUsers `json:"User" xml:"User"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users_for_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users_for_group.go new file mode 100644 index 0000000000..5df9149749 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_users_in_list_users_for_group.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UsersInListUsersForGroup is a nested struct in ram response +type UsersInListUsersForGroup struct { + User []UserInListUsersForGroup `json:"User" xml:"User"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_create_virtual_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_create_virtual_mfa_device.go new file mode 100644 index 0000000000..20b4ec2b8d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_create_virtual_mfa_device.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// VirtualMFADeviceInCreateVirtualMFADevice is a nested struct in ram response +type VirtualMFADeviceInCreateVirtualMFADevice struct { + SerialNumber string `json:"SerialNumber" xml:"SerialNumber"` + Base32StringSeed string `json:"Base32StringSeed" xml:"Base32StringSeed"` + QRCodePNG string `json:"QRCodePNG" xml:"QRCodePNG"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_list_virtual_mfa_devices.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_list_virtual_mfa_devices.go new file mode 100644 index 0000000000..427830b071 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_device_in_list_virtual_mfa_devices.go @@ -0,0 +1,23 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// VirtualMFADeviceInListVirtualMFADevices is a nested struct in ram response +type VirtualMFADeviceInListVirtualMFADevices struct { + SerialNumber string `json:"SerialNumber" xml:"SerialNumber"` + ActivateDate string `json:"ActivateDate" xml:"ActivateDate"` + User UserInListVirtualMFADevices `json:"User" xml:"User"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_devices.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_devices.go new file mode 100644 index 0000000000..71b374ff32 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/struct_virtual_mfa_devices.go @@ -0,0 +1,21 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// VirtualMFADevices is a nested struct in ram response +type VirtualMFADevices struct { + VirtualMFADevice []VirtualMFADeviceInListVirtualMFADevices `json:"VirtualMFADevice" xml:"VirtualMFADevice"` +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/unbind_mfa_device.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/unbind_mfa_device.go new file mode 100644 index 0000000000..ef66f5adb0 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/unbind_mfa_device.go @@ -0,0 +1,104 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UnbindMFADevice invokes the ram.UnbindMFADevice API synchronously +// api document: https://help.aliyun.com/api/ram/unbindmfadevice.html +func (client *Client) UnbindMFADevice(request *UnbindMFADeviceRequest) (response *UnbindMFADeviceResponse, err error) { + response = CreateUnbindMFADeviceResponse() + err = client.DoAction(request, response) + return +} + +// UnbindMFADeviceWithChan invokes the ram.UnbindMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/unbindmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UnbindMFADeviceWithChan(request *UnbindMFADeviceRequest) (<-chan *UnbindMFADeviceResponse, <-chan error) { + responseChan := make(chan *UnbindMFADeviceResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UnbindMFADevice(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UnbindMFADeviceWithCallback invokes the ram.UnbindMFADevice API asynchronously +// api document: https://help.aliyun.com/api/ram/unbindmfadevice.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UnbindMFADeviceWithCallback(request *UnbindMFADeviceRequest, callback func(response *UnbindMFADeviceResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UnbindMFADeviceResponse + var err error + defer close(result) + response, err = client.UnbindMFADevice(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UnbindMFADeviceRequest is the request struct for api UnbindMFADevice +type UnbindMFADeviceRequest struct { + *requests.RpcRequest + UserName string `position:"Query" name:"UserName"` +} + +// UnbindMFADeviceResponse is the response struct for api UnbindMFADevice +type UnbindMFADeviceResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + MFADevice MFADeviceInUnbindMFADevice `json:"MFADevice" xml:"MFADevice"` +} + +// CreateUnbindMFADeviceRequest creates a request to invoke UnbindMFADevice API +func CreateUnbindMFADeviceRequest() (request *UnbindMFADeviceRequest) { + request = &UnbindMFADeviceRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UnbindMFADevice", "Ram", "openAPI") + return +} + +// CreateUnbindMFADeviceResponse creates a response to parse from UnbindMFADevice response +func CreateUnbindMFADeviceResponse() (response *UnbindMFADeviceResponse) { + response = &UnbindMFADeviceResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_access_key.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_access_key.go new file mode 100644 index 0000000000..df72f78a5f --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_access_key.go @@ -0,0 +1,105 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UpdateAccessKey invokes the ram.UpdateAccessKey API synchronously +// api document: https://help.aliyun.com/api/ram/updateaccesskey.html +func (client *Client) UpdateAccessKey(request *UpdateAccessKeyRequest) (response *UpdateAccessKeyResponse, err error) { + response = CreateUpdateAccessKeyResponse() + err = client.DoAction(request, response) + return +} + +// UpdateAccessKeyWithChan invokes the ram.UpdateAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/updateaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateAccessKeyWithChan(request *UpdateAccessKeyRequest) (<-chan *UpdateAccessKeyResponse, <-chan error) { + responseChan := make(chan *UpdateAccessKeyResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UpdateAccessKey(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UpdateAccessKeyWithCallback invokes the ram.UpdateAccessKey API asynchronously +// api document: https://help.aliyun.com/api/ram/updateaccesskey.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateAccessKeyWithCallback(request *UpdateAccessKeyRequest, callback func(response *UpdateAccessKeyResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UpdateAccessKeyResponse + var err error + defer close(result) + response, err = client.UpdateAccessKey(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UpdateAccessKeyRequest is the request struct for api UpdateAccessKey +type UpdateAccessKeyRequest struct { + *requests.RpcRequest + UserAccessKeyId string `position:"Query" name:"UserAccessKeyId"` + UserName string `position:"Query" name:"UserName"` + Status string `position:"Query" name:"Status"` +} + +// UpdateAccessKeyResponse is the response struct for api UpdateAccessKey +type UpdateAccessKeyResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateUpdateAccessKeyRequest creates a request to invoke UpdateAccessKey API +func CreateUpdateAccessKeyRequest() (request *UpdateAccessKeyRequest) { + request = &UpdateAccessKeyRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UpdateAccessKey", "Ram", "openAPI") + return +} + +// CreateUpdateAccessKeyResponse creates a response to parse from UpdateAccessKey response +func CreateUpdateAccessKeyResponse() (response *UpdateAccessKeyResponse) { + response = &UpdateAccessKeyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_group.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_group.go new file mode 100644 index 0000000000..565defae4d --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_group.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UpdateGroup invokes the ram.UpdateGroup API synchronously +// api document: https://help.aliyun.com/api/ram/updategroup.html +func (client *Client) UpdateGroup(request *UpdateGroupRequest) (response *UpdateGroupResponse, err error) { + response = CreateUpdateGroupResponse() + err = client.DoAction(request, response) + return +} + +// UpdateGroupWithChan invokes the ram.UpdateGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/updategroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateGroupWithChan(request *UpdateGroupRequest) (<-chan *UpdateGroupResponse, <-chan error) { + responseChan := make(chan *UpdateGroupResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UpdateGroup(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UpdateGroupWithCallback invokes the ram.UpdateGroup API asynchronously +// api document: https://help.aliyun.com/api/ram/updategroup.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateGroupWithCallback(request *UpdateGroupRequest, callback func(response *UpdateGroupResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UpdateGroupResponse + var err error + defer close(result) + response, err = client.UpdateGroup(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UpdateGroupRequest is the request struct for api UpdateGroup +type UpdateGroupRequest struct { + *requests.RpcRequest + GroupName string `position:"Query" name:"GroupName"` + NewGroupName string `position:"Query" name:"NewGroupName"` + NewComments string `position:"Query" name:"NewComments"` +} + +// UpdateGroupResponse is the response struct for api UpdateGroup +type UpdateGroupResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Group GroupInUpdateGroup `json:"Group" xml:"Group"` +} + +// CreateUpdateGroupRequest creates a request to invoke UpdateGroup API +func CreateUpdateGroupRequest() (request *UpdateGroupRequest) { + request = &UpdateGroupRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UpdateGroup", "Ram", "openAPI") + return +} + +// CreateUpdateGroupResponse creates a response to parse from UpdateGroup response +func CreateUpdateGroupResponse() (response *UpdateGroupResponse) { + response = &UpdateGroupResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_login_profile.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_login_profile.go new file mode 100644 index 0000000000..54fea436c2 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_login_profile.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UpdateLoginProfile invokes the ram.UpdateLoginProfile API synchronously +// api document: https://help.aliyun.com/api/ram/updateloginprofile.html +func (client *Client) UpdateLoginProfile(request *UpdateLoginProfileRequest) (response *UpdateLoginProfileResponse, err error) { + response = CreateUpdateLoginProfileResponse() + err = client.DoAction(request, response) + return +} + +// UpdateLoginProfileWithChan invokes the ram.UpdateLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/updateloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateLoginProfileWithChan(request *UpdateLoginProfileRequest) (<-chan *UpdateLoginProfileResponse, <-chan error) { + responseChan := make(chan *UpdateLoginProfileResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UpdateLoginProfile(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UpdateLoginProfileWithCallback invokes the ram.UpdateLoginProfile API asynchronously +// api document: https://help.aliyun.com/api/ram/updateloginprofile.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateLoginProfileWithCallback(request *UpdateLoginProfileRequest, callback func(response *UpdateLoginProfileResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UpdateLoginProfileResponse + var err error + defer close(result) + response, err = client.UpdateLoginProfile(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UpdateLoginProfileRequest is the request struct for api UpdateLoginProfile +type UpdateLoginProfileRequest struct { + *requests.RpcRequest + PasswordResetRequired requests.Boolean `position:"Query" name:"PasswordResetRequired"` + Password string `position:"Query" name:"Password"` + MFABindRequired requests.Boolean `position:"Query" name:"MFABindRequired"` + UserName string `position:"Query" name:"UserName"` +} + +// UpdateLoginProfileResponse is the response struct for api UpdateLoginProfile +type UpdateLoginProfileResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` +} + +// CreateUpdateLoginProfileRequest creates a request to invoke UpdateLoginProfile API +func CreateUpdateLoginProfileRequest() (request *UpdateLoginProfileRequest) { + request = &UpdateLoginProfileRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UpdateLoginProfile", "Ram", "openAPI") + return +} + +// CreateUpdateLoginProfileResponse creates a response to parse from UpdateLoginProfile response +func CreateUpdateLoginProfileResponse() (response *UpdateLoginProfileResponse) { + response = &UpdateLoginProfileResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_role.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_role.go new file mode 100644 index 0000000000..583e3cc615 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_role.go @@ -0,0 +1,106 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UpdateRole invokes the ram.UpdateRole API synchronously +// api document: https://help.aliyun.com/api/ram/updaterole.html +func (client *Client) UpdateRole(request *UpdateRoleRequest) (response *UpdateRoleResponse, err error) { + response = CreateUpdateRoleResponse() + err = client.DoAction(request, response) + return +} + +// UpdateRoleWithChan invokes the ram.UpdateRole API asynchronously +// api document: https://help.aliyun.com/api/ram/updaterole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateRoleWithChan(request *UpdateRoleRequest) (<-chan *UpdateRoleResponse, <-chan error) { + responseChan := make(chan *UpdateRoleResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UpdateRole(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UpdateRoleWithCallback invokes the ram.UpdateRole API asynchronously +// api document: https://help.aliyun.com/api/ram/updaterole.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateRoleWithCallback(request *UpdateRoleRequest, callback func(response *UpdateRoleResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UpdateRoleResponse + var err error + defer close(result) + response, err = client.UpdateRole(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UpdateRoleRequest is the request struct for api UpdateRole +type UpdateRoleRequest struct { + *requests.RpcRequest + NewAssumeRolePolicyDocument string `position:"Query" name:"NewAssumeRolePolicyDocument"` + RoleName string `position:"Query" name:"RoleName"` + NewMaxSessionDuration requests.Integer `position:"Query" name:"NewMaxSessionDuration"` +} + +// UpdateRoleResponse is the response struct for api UpdateRole +type UpdateRoleResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + Role RoleInUpdateRole `json:"Role" xml:"Role"` +} + +// CreateUpdateRoleRequest creates a request to invoke UpdateRole API +func CreateUpdateRoleRequest() (request *UpdateRoleRequest) { + request = &UpdateRoleRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UpdateRole", "Ram", "openAPI") + return +} + +// CreateUpdateRoleResponse creates a response to parse from UpdateRole response +func CreateUpdateRoleResponse() (response *UpdateRoleResponse) { + response = &UpdateRoleResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_user.go b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_user.go new file mode 100644 index 0000000000..9902b46235 --- /dev/null +++ b/vendor/github.com/aliyun/alibaba-cloud-sdk-go/services/ram/update_user.go @@ -0,0 +1,109 @@ +package ram + +//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. +// +// Code generated by Alibaba Cloud SDK Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" +) + +// UpdateUser invokes the ram.UpdateUser API synchronously +// api document: https://help.aliyun.com/api/ram/updateuser.html +func (client *Client) UpdateUser(request *UpdateUserRequest) (response *UpdateUserResponse, err error) { + response = CreateUpdateUserResponse() + err = client.DoAction(request, response) + return +} + +// UpdateUserWithChan invokes the ram.UpdateUser API asynchronously +// api document: https://help.aliyun.com/api/ram/updateuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateUserWithChan(request *UpdateUserRequest) (<-chan *UpdateUserResponse, <-chan error) { + responseChan := make(chan *UpdateUserResponse, 1) + errChan := make(chan error, 1) + err := client.AddAsyncTask(func() { + defer close(responseChan) + defer close(errChan) + response, err := client.UpdateUser(request) + if err != nil { + errChan <- err + } else { + responseChan <- response + } + }) + if err != nil { + errChan <- err + close(responseChan) + close(errChan) + } + return responseChan, errChan +} + +// UpdateUserWithCallback invokes the ram.UpdateUser API asynchronously +// api document: https://help.aliyun.com/api/ram/updateuser.html +// asynchronous document: https://help.aliyun.com/document_detail/66220.html +func (client *Client) UpdateUserWithCallback(request *UpdateUserRequest, callback func(response *UpdateUserResponse, err error)) <-chan int { + result := make(chan int, 1) + err := client.AddAsyncTask(func() { + var response *UpdateUserResponse + var err error + defer close(result) + response, err = client.UpdateUser(request) + callback(response, err) + result <- 1 + }) + if err != nil { + defer close(result) + callback(nil, err) + result <- 0 + } + return result +} + +// UpdateUserRequest is the request struct for api UpdateUser +type UpdateUserRequest struct { + *requests.RpcRequest + NewUserName string `position:"Query" name:"NewUserName"` + NewMobilePhone string `position:"Query" name:"NewMobilePhone"` + NewEmail string `position:"Query" name:"NewEmail"` + NewDisplayName string `position:"Query" name:"NewDisplayName"` + NewComments string `position:"Query" name:"NewComments"` + UserName string `position:"Query" name:"UserName"` +} + +// UpdateUserResponse is the response struct for api UpdateUser +type UpdateUserResponse struct { + *responses.BaseResponse + RequestId string `json:"RequestId" xml:"RequestId"` + User UserInUpdateUser `json:"User" xml:"User"` +} + +// CreateUpdateUserRequest creates a request to invoke UpdateUser API +func CreateUpdateUserRequest() (request *UpdateUserRequest) { + request = &UpdateUserRequest{ + RpcRequest: &requests.RpcRequest{}, + } + request.InitWithApiInfo("Ram", "2015-05-01", "UpdateUser", "Ram", "openAPI") + return +} + +// CreateUpdateUserResponse creates a response to parse from UpdateUser response +func CreateUpdateUserResponse() (response *UpdateUserResponse) { + response = &UpdateUserResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/vendor/gopkg.in/ini.v1/.gitignore b/vendor/gopkg.in/ini.v1/.gitignore new file mode 100644 index 0000000000..12411127b3 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/.gitignore @@ -0,0 +1,6 @@ +testdata/conf_out.ini +ini.sublime-project +ini.sublime-workspace +testdata/conf_reflect.ini +.idea +/.vscode diff --git a/vendor/gopkg.in/ini.v1/LICENSE b/vendor/gopkg.in/ini.v1/LICENSE new file mode 100644 index 0000000000..d361bbcdf5 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright 2014 Unknwon + + 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. diff --git a/vendor/gopkg.in/ini.v1/Makefile b/vendor/gopkg.in/ini.v1/Makefile new file mode 100644 index 0000000000..f3b0dae2d2 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/Makefile @@ -0,0 +1,15 @@ +.PHONY: build test bench vet coverage + +build: vet bench + +test: + go test -v -cover -race + +bench: + go test -v -cover -test.bench=. -test.benchmem + +vet: + go vet + +coverage: + go test -coverprofile=c.out && go tool cover -html=c.out && rm c.out diff --git a/vendor/gopkg.in/ini.v1/README.md b/vendor/gopkg.in/ini.v1/README.md new file mode 100644 index 0000000000..5d65658b29 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/README.md @@ -0,0 +1,43 @@ +# INI + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-ini/ini/Go?logo=github&style=for-the-badge)](https://github.com/go-ini/ini/actions?query=workflow%3AGo) +[![codecov](https://img.shields.io/codecov/c/github/go-ini/ini/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-ini/ini) +[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/go-ini/ini?tab=doc) +[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-ini/ini) + +![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200) + +Package ini provides INI file read and write functionality in Go. + +## Features + +- Load from multiple data sources(file, `[]byte`, `io.Reader` and `io.ReadCloser`) with overwrites. +- Read with recursion values. +- Read with parent-child sections. +- Read with auto-increment key names. +- Read with multiple-line values. +- Read with tons of helper methods. +- Read and convert values to Go types. +- Read and **WRITE** comments of sections and keys. +- Manipulate sections, keys and comments with ease. +- Keep sections and keys in order as you parse and save. + +## Installation + +The minimum requirement of Go is **1.6**. + +```sh +$ go get gopkg.in/ini.v1 +``` + +Please add `-u` flag to update in the future. + +## Getting Help + +- [Getting Started](https://ini.unknwon.io/docs/intro/getting_started) +- [API Documentation](https://gowalker.org/gopkg.in/ini.v1) +- 中国大陆镜像:https://ini.unknwon.cn + +## License + +This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. diff --git a/vendor/gopkg.in/ini.v1/codecov.yml b/vendor/gopkg.in/ini.v1/codecov.yml new file mode 100644 index 0000000000..fc947f2308 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/codecov.yml @@ -0,0 +1,9 @@ +coverage: + range: "60...95" + status: + project: + default: + threshold: 1% + +comment: + layout: 'diff, files' diff --git a/vendor/gopkg.in/ini.v1/data_source.go b/vendor/gopkg.in/ini.v1/data_source.go new file mode 100644 index 0000000000..c3a541f1d1 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/data_source.go @@ -0,0 +1,76 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "os" +) + +var ( + _ dataSource = (*sourceFile)(nil) + _ dataSource = (*sourceData)(nil) + _ dataSource = (*sourceReadCloser)(nil) +) + +// dataSource is an interface that returns object which can be read and closed. +type dataSource interface { + ReadCloser() (io.ReadCloser, error) +} + +// sourceFile represents an object that contains content on the local file system. +type sourceFile struct { + name string +} + +func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { + return os.Open(s.name) +} + +// sourceData represents an object that contains content in memory. +type sourceData struct { + data []byte +} + +func (s *sourceData) ReadCloser() (io.ReadCloser, error) { + return ioutil.NopCloser(bytes.NewReader(s.data)), nil +} + +// sourceReadCloser represents an input stream with Close method. +type sourceReadCloser struct { + reader io.ReadCloser +} + +func (s *sourceReadCloser) ReadCloser() (io.ReadCloser, error) { + return s.reader, nil +} + +func parseDataSource(source interface{}) (dataSource, error) { + switch s := source.(type) { + case string: + return sourceFile{s}, nil + case []byte: + return &sourceData{s}, nil + case io.ReadCloser: + return &sourceReadCloser{s}, nil + case io.Reader: + return &sourceReadCloser{ioutil.NopCloser(s)}, nil + default: + return nil, fmt.Errorf("error parsing data source: unknown type %q", s) + } +} diff --git a/vendor/gopkg.in/ini.v1/deprecated.go b/vendor/gopkg.in/ini.v1/deprecated.go new file mode 100644 index 0000000000..e8bda06e6f --- /dev/null +++ b/vendor/gopkg.in/ini.v1/deprecated.go @@ -0,0 +1,25 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +const ( + // Deprecated: Use "DefaultSection" instead. + DEFAULT_SECTION = DefaultSection +) + +var ( + // Deprecated: AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. + AllCapsUnderscore = SnackCase +) diff --git a/vendor/gopkg.in/ini.v1/error.go b/vendor/gopkg.in/ini.v1/error.go new file mode 100644 index 0000000000..d88347c54b --- /dev/null +++ b/vendor/gopkg.in/ini.v1/error.go @@ -0,0 +1,34 @@ +// Copyright 2016 Unknwon +// +// 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 ini + +import ( + "fmt" +) + +// ErrDelimiterNotFound indicates the error type of no delimiter is found which there should be one. +type ErrDelimiterNotFound struct { + Line string +} + +// IsErrDelimiterNotFound returns true if the given error is an instance of ErrDelimiterNotFound. +func IsErrDelimiterNotFound(err error) bool { + _, ok := err.(ErrDelimiterNotFound) + return ok +} + +func (err ErrDelimiterNotFound) Error() string { + return fmt.Sprintf("key-value delimiter not found: %s", err.Line) +} diff --git a/vendor/gopkg.in/ini.v1/file.go b/vendor/gopkg.in/ini.v1/file.go new file mode 100644 index 0000000000..b96d172cf4 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/file.go @@ -0,0 +1,517 @@ +// Copyright 2017 Unknwon +// +// 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 ini + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "os" + "strings" + "sync" +) + +// File represents a combination of one or more INI files in memory. +type File struct { + options LoadOptions + dataSources []dataSource + + // Should make things safe, but sometimes doesn't matter. + BlockMode bool + lock sync.RWMutex + + // To keep data in order. + sectionList []string + // To keep track of the index of a section with same name. + // This meta list is only used with non-unique section names are allowed. + sectionIndexes []int + + // Actual data is stored here. + sections map[string][]*Section + + NameMapper + ValueMapper +} + +// newFile initializes File object with given data sources. +func newFile(dataSources []dataSource, opts LoadOptions) *File { + if len(opts.KeyValueDelimiters) == 0 { + opts.KeyValueDelimiters = "=:" + } + if len(opts.KeyValueDelimiterOnWrite) == 0 { + opts.KeyValueDelimiterOnWrite = "=" + } + if len(opts.ChildSectionDelimiter) == 0 { + opts.ChildSectionDelimiter = "." + } + + return &File{ + BlockMode: true, + dataSources: dataSources, + sections: make(map[string][]*Section), + options: opts, + } +} + +// Empty returns an empty file object. +func Empty(opts ...LoadOptions) *File { + var opt LoadOptions + if len(opts) > 0 { + opt = opts[0] + } + + // Ignore error here, we are sure our data is good. + f, _ := LoadSources(opt, []byte("")) + return f +} + +// NewSection creates a new section. +func (f *File) NewSection(name string) (*Section, error) { + if len(name) == 0 { + return nil, errors.New("empty section name") + } + + if (f.options.Insensitive || f.options.InsensitiveSections) && name != DefaultSection { + name = strings.ToLower(name) + } + + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + if !f.options.AllowNonUniqueSections && inSlice(name, f.sectionList) { + return f.sections[name][0], nil + } + + f.sectionList = append(f.sectionList, name) + + // NOTE: Append to indexes must happen before appending to sections, + // otherwise index will have off-by-one problem. + f.sectionIndexes = append(f.sectionIndexes, len(f.sections[name])) + + sec := newSection(f, name) + f.sections[name] = append(f.sections[name], sec) + + return sec, nil +} + +// NewRawSection creates a new section with an unparseable body. +func (f *File) NewRawSection(name, body string) (*Section, error) { + section, err := f.NewSection(name) + if err != nil { + return nil, err + } + + section.isRawSection = true + section.rawBody = body + return section, nil +} + +// NewSections creates a list of sections. +func (f *File) NewSections(names ...string) (err error) { + for _, name := range names { + if _, err = f.NewSection(name); err != nil { + return err + } + } + return nil +} + +// GetSection returns section by given name. +func (f *File) GetSection(name string) (*Section, error) { + secs, err := f.SectionsByName(name) + if err != nil { + return nil, err + } + + return secs[0], err +} + +// SectionsByName returns all sections with given name. +func (f *File) SectionsByName(name string) ([]*Section, error) { + if len(name) == 0 { + name = DefaultSection + } + if f.options.Insensitive || f.options.InsensitiveSections { + name = strings.ToLower(name) + } + + if f.BlockMode { + f.lock.RLock() + defer f.lock.RUnlock() + } + + secs := f.sections[name] + if len(secs) == 0 { + return nil, fmt.Errorf("section %q does not exist", name) + } + + return secs, nil +} + +// Section assumes named section exists and returns a zero-value when not. +func (f *File) Section(name string) *Section { + sec, err := f.GetSection(name) + if err != nil { + // Note: It's OK here because the only possible error is empty section name, + // but if it's empty, this piece of code won't be executed. + sec, _ = f.NewSection(name) + return sec + } + return sec +} + +// SectionWithIndex assumes named section exists and returns a new section when not. +func (f *File) SectionWithIndex(name string, index int) *Section { + secs, err := f.SectionsByName(name) + if err != nil || len(secs) <= index { + // NOTE: It's OK here because the only possible error is empty section name, + // but if it's empty, this piece of code won't be executed. + newSec, _ := f.NewSection(name) + return newSec + } + + return secs[index] +} + +// Sections returns a list of Section stored in the current instance. +func (f *File) Sections() []*Section { + if f.BlockMode { + f.lock.RLock() + defer f.lock.RUnlock() + } + + sections := make([]*Section, len(f.sectionList)) + for i, name := range f.sectionList { + sections[i] = f.sections[name][f.sectionIndexes[i]] + } + return sections +} + +// ChildSections returns a list of child sections of given section name. +func (f *File) ChildSections(name string) []*Section { + return f.Section(name).ChildSections() +} + +// SectionStrings returns list of section names. +func (f *File) SectionStrings() []string { + list := make([]string, len(f.sectionList)) + copy(list, f.sectionList) + return list +} + +// DeleteSection deletes a section or all sections with given name. +func (f *File) DeleteSection(name string) { + secs, err := f.SectionsByName(name) + if err != nil { + return + } + + for i := 0; i < len(secs); i++ { + // For non-unique sections, it is always needed to remove the first one so + // in the next iteration, the subsequent section continue having index 0. + // Ignoring the error as index 0 never returns an error. + _ = f.DeleteSectionWithIndex(name, 0) + } +} + +// DeleteSectionWithIndex deletes a section with given name and index. +func (f *File) DeleteSectionWithIndex(name string, index int) error { + if !f.options.AllowNonUniqueSections && index != 0 { + return fmt.Errorf("delete section with non-zero index is only allowed when non-unique sections is enabled") + } + + if len(name) == 0 { + name = DefaultSection + } + if f.options.Insensitive || f.options.InsensitiveSections { + name = strings.ToLower(name) + } + + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + // Count occurrences of the sections + occurrences := 0 + + sectionListCopy := make([]string, len(f.sectionList)) + copy(sectionListCopy, f.sectionList) + + for i, s := range sectionListCopy { + if s != name { + continue + } + + if occurrences == index { + if len(f.sections[name]) <= 1 { + delete(f.sections, name) // The last one in the map + } else { + f.sections[name] = append(f.sections[name][:index], f.sections[name][index+1:]...) + } + + // Fix section lists + f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) + f.sectionIndexes = append(f.sectionIndexes[:i], f.sectionIndexes[i+1:]...) + + } else if occurrences > index { + // Fix the indices of all following sections with this name. + f.sectionIndexes[i-1]-- + } + + occurrences++ + } + + return nil +} + +func (f *File) reload(s dataSource) error { + r, err := s.ReadCloser() + if err != nil { + return err + } + defer r.Close() + + return f.parse(r) +} + +// Reload reloads and parses all data sources. +func (f *File) Reload() (err error) { + for _, s := range f.dataSources { + if err = f.reload(s); err != nil { + // In loose mode, we create an empty default section for nonexistent files. + if os.IsNotExist(err) && f.options.Loose { + _ = f.parse(bytes.NewBuffer(nil)) + continue + } + return err + } + if f.options.ShortCircuit { + return nil + } + } + return nil +} + +// Append appends one or more data sources and reloads automatically. +func (f *File) Append(source interface{}, others ...interface{}) error { + ds, err := parseDataSource(source) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + for _, s := range others { + ds, err = parseDataSource(s) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + } + return f.Reload() +} + +func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { + equalSign := DefaultFormatLeft + f.options.KeyValueDelimiterOnWrite + DefaultFormatRight + + if PrettyFormat || PrettyEqual { + equalSign = fmt.Sprintf(" %s ", f.options.KeyValueDelimiterOnWrite) + } + + // Use buffer to make sure target is safe until finish encoding. + buf := bytes.NewBuffer(nil) + for i, sname := range f.sectionList { + sec := f.SectionWithIndex(sname, f.sectionIndexes[i]) + if len(sec.Comment) > 0 { + // Support multiline comments + lines := strings.Split(sec.Comment, LineBreak) + for i := range lines { + if lines[i][0] != '#' && lines[i][0] != ';' { + lines[i] = "; " + lines[i] + } else { + lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:]) + } + + if _, err := buf.WriteString(lines[i] + LineBreak); err != nil { + return nil, err + } + } + } + + if i > 0 || DefaultHeader || (i == 0 && strings.ToUpper(sec.name) != DefaultSection) { + if _, err := buf.WriteString("[" + sname + "]" + LineBreak); err != nil { + return nil, err + } + } else { + // Write nothing if default section is empty + if len(sec.keyList) == 0 { + continue + } + } + + if sec.isRawSection { + if _, err := buf.WriteString(sec.rawBody); err != nil { + return nil, err + } + + if PrettySection { + // Put a line between sections + if _, err := buf.WriteString(LineBreak); err != nil { + return nil, err + } + } + continue + } + + // Count and generate alignment length and buffer spaces using the + // longest key. Keys may be modified if they contain certain characters so + // we need to take that into account in our calculation. + alignLength := 0 + if PrettyFormat { + for _, kname := range sec.keyList { + keyLength := len(kname) + // First case will surround key by ` and second by """ + if strings.Contains(kname, "\"") || strings.ContainsAny(kname, f.options.KeyValueDelimiters) { + keyLength += 2 + } else if strings.Contains(kname, "`") { + keyLength += 6 + } + + if keyLength > alignLength { + alignLength = keyLength + } + } + } + alignSpaces := bytes.Repeat([]byte(" "), alignLength) + + KeyList: + for _, kname := range sec.keyList { + key := sec.Key(kname) + if len(key.Comment) > 0 { + if len(indent) > 0 && sname != DefaultSection { + buf.WriteString(indent) + } + + // Support multiline comments + lines := strings.Split(key.Comment, LineBreak) + for i := range lines { + if lines[i][0] != '#' && lines[i][0] != ';' { + lines[i] = "; " + strings.TrimSpace(lines[i]) + } else { + lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:]) + } + + if _, err := buf.WriteString(lines[i] + LineBreak); err != nil { + return nil, err + } + } + } + + if len(indent) > 0 && sname != DefaultSection { + buf.WriteString(indent) + } + + switch { + case key.isAutoIncrement: + kname = "-" + case strings.Contains(kname, "\"") || strings.ContainsAny(kname, f.options.KeyValueDelimiters): + kname = "`" + kname + "`" + case strings.Contains(kname, "`"): + kname = `"""` + kname + `"""` + } + + for _, val := range key.ValueWithShadows() { + if _, err := buf.WriteString(kname); err != nil { + return nil, err + } + + if key.isBooleanType { + if kname != sec.keyList[len(sec.keyList)-1] { + buf.WriteString(LineBreak) + } + continue KeyList + } + + // Write out alignment spaces before "=" sign + if PrettyFormat { + buf.Write(alignSpaces[:alignLength-len(kname)]) + } + + // In case key value contains "\n", "`", "\"", "#" or ";" + if strings.ContainsAny(val, "\n`") { + val = `"""` + val + `"""` + } else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") { + val = "`" + val + "`" + } else if len(strings.TrimSpace(val)) != len(val) { + val = `"` + val + `"` + } + if _, err := buf.WriteString(equalSign + val + LineBreak); err != nil { + return nil, err + } + } + + for _, val := range key.nestedValues { + if _, err := buf.WriteString(indent + " " + val + LineBreak); err != nil { + return nil, err + } + } + } + + if PrettySection { + // Put a line between sections + if _, err := buf.WriteString(LineBreak); err != nil { + return nil, err + } + } + } + + return buf, nil +} + +// WriteToIndent writes content into io.Writer with given indention. +// If PrettyFormat has been set to be true, +// it will align "=" sign with spaces under each section. +func (f *File) WriteToIndent(w io.Writer, indent string) (int64, error) { + buf, err := f.writeToBuffer(indent) + if err != nil { + return 0, err + } + return buf.WriteTo(w) +} + +// WriteTo writes file content into io.Writer. +func (f *File) WriteTo(w io.Writer) (int64, error) { + return f.WriteToIndent(w, "") +} + +// SaveToIndent writes content to file system with given value indention. +func (f *File) SaveToIndent(filename, indent string) error { + // Note: Because we are truncating with os.Create, + // so it's safer to save to a temporary file location and rename after done. + buf, err := f.writeToBuffer(indent) + if err != nil { + return err + } + + return ioutil.WriteFile(filename, buf.Bytes(), 0666) +} + +// SaveTo writes content to file system. +func (f *File) SaveTo(filename string) error { + return f.SaveToIndent(filename, "") +} diff --git a/vendor/gopkg.in/ini.v1/helper.go b/vendor/gopkg.in/ini.v1/helper.go new file mode 100644 index 0000000000..f9d80a682a --- /dev/null +++ b/vendor/gopkg.in/ini.v1/helper.go @@ -0,0 +1,24 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +func inSlice(str string, s []string) bool { + for _, v := range s { + if str == v { + return true + } + } + return false +} diff --git a/vendor/gopkg.in/ini.v1/ini.go b/vendor/gopkg.in/ini.v1/ini.go new file mode 100644 index 0000000000..23f07422ef --- /dev/null +++ b/vendor/gopkg.in/ini.v1/ini.go @@ -0,0 +1,176 @@ +// +build go1.6 + +// Copyright 2014 Unknwon +// +// 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 ini provides INI file read and write functionality in Go. +package ini + +import ( + "os" + "regexp" + "runtime" + "strings" +) + +const ( + // DefaultSection is the name of default section. You can use this constant or the string literal. + // In most of cases, an empty string is all you need to access the section. + DefaultSection = "DEFAULT" + + // Maximum allowed depth when recursively substituing variable names. + depthValues = 99 +) + +var ( + // LineBreak is the delimiter to determine or compose a new line. + // This variable will be changed to "\r\n" automatically on Windows at package init time. + LineBreak = "\n" + + // Variable regexp pattern: %(variable)s + varPattern = regexp.MustCompile(`%\(([^)]+)\)s`) + + // DefaultHeader explicitly writes default section header. + DefaultHeader = false + + // PrettySection indicates whether to put a line between sections. + PrettySection = true + // PrettyFormat indicates whether to align "=" sign with spaces to produce pretty output + // or reduce all possible spaces for compact format. + PrettyFormat = true + // PrettyEqual places spaces around "=" sign even when PrettyFormat is false. + PrettyEqual = false + // DefaultFormatLeft places custom spaces on the left when PrettyFormat and PrettyEqual are both disabled. + DefaultFormatLeft = "" + // DefaultFormatRight places custom spaces on the right when PrettyFormat and PrettyEqual are both disabled. + DefaultFormatRight = "" +) + +var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") + +func init() { + if runtime.GOOS == "windows" && !inTest { + LineBreak = "\r\n" + } +} + +// LoadOptions contains all customized options used for load data source(s). +type LoadOptions struct { + // Loose indicates whether the parser should ignore nonexistent files or return error. + Loose bool + // Insensitive indicates whether the parser forces all section and key names to lowercase. + Insensitive bool + // InsensitiveSections indicates whether the parser forces all section to lowercase. + InsensitiveSections bool + // InsensitiveKeys indicates whether the parser forces all key names to lowercase. + InsensitiveKeys bool + // IgnoreContinuation indicates whether to ignore continuation lines while parsing. + IgnoreContinuation bool + // IgnoreInlineComment indicates whether to ignore comments at the end of value and treat it as part of value. + IgnoreInlineComment bool + // SkipUnrecognizableLines indicates whether to skip unrecognizable lines that do not conform to key/value pairs. + SkipUnrecognizableLines bool + // ShortCircuit indicates whether to ignore other configuration sources after loaded the first available configuration source. + ShortCircuit bool + // AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing. + // This type of keys are mostly used in my.cnf. + AllowBooleanKeys bool + // AllowShadows indicates whether to keep track of keys with same name under same section. + AllowShadows bool + // AllowNestedValues indicates whether to allow AWS-like nested values. + // Docs: http://docs.aws.amazon.com/cli/latest/topic/config-vars.html#nested-values + AllowNestedValues bool + // AllowPythonMultilineValues indicates whether to allow Python-like multi-line values. + // Docs: https://docs.python.org/3/library/configparser.html#supported-ini-file-structure + // Relevant quote: Values can also span multiple lines, as long as they are indented deeper + // than the first line of the value. + AllowPythonMultilineValues bool + // SpaceBeforeInlineComment indicates whether to allow comment symbols (\# and \;) inside value. + // Docs: https://docs.python.org/2/library/configparser.html + // Quote: Comments may appear on their own in an otherwise empty line, or may be entered in lines holding values or section names. + // In the latter case, they need to be preceded by a whitespace character to be recognized as a comment. + SpaceBeforeInlineComment bool + // UnescapeValueDoubleQuotes indicates whether to unescape double quotes inside value to regular format + // when value is surrounded by double quotes, e.g. key="a \"value\"" => key=a "value" + UnescapeValueDoubleQuotes bool + // UnescapeValueCommentSymbols indicates to unescape comment symbols (\# and \;) inside value to regular format + // when value is NOT surrounded by any quotes. + // Note: UNSTABLE, behavior might change to only unescape inside double quotes but may noy necessary at all. + UnescapeValueCommentSymbols bool + // UnparseableSections stores a list of blocks that are allowed with raw content which do not otherwise + // conform to key/value pairs. Specify the names of those blocks here. + UnparseableSections []string + // KeyValueDelimiters is the sequence of delimiters that are used to separate key and value. By default, it is "=:". + KeyValueDelimiters string + // KeyValueDelimiterOnWrite is the delimiter that are used to separate key and value output. By default, it is "=". + KeyValueDelimiterOnWrite string + // ChildSectionDelimiter is the delimiter that is used to separate child sections. By default, it is ".". + ChildSectionDelimiter string + // PreserveSurroundedQuote indicates whether to preserve surrounded quote (single and double quotes). + PreserveSurroundedQuote bool + // DebugFunc is called to collect debug information (currently only useful to debug parsing Python-style multiline values). + DebugFunc DebugFunc + // ReaderBufferSize is the buffer size of the reader in bytes. + ReaderBufferSize int + // AllowNonUniqueSections indicates whether to allow sections with the same name multiple times. + AllowNonUniqueSections bool +} + +// DebugFunc is the type of function called to log parse events. +type DebugFunc func(message string) + +// LoadSources allows caller to apply customized options for loading from data source(s). +func LoadSources(opts LoadOptions, source interface{}, others ...interface{}) (_ *File, err error) { + sources := make([]dataSource, len(others)+1) + sources[0], err = parseDataSource(source) + if err != nil { + return nil, err + } + for i := range others { + sources[i+1], err = parseDataSource(others[i]) + if err != nil { + return nil, err + } + } + f := newFile(sources, opts) + if err = f.Reload(); err != nil { + return nil, err + } + return f, nil +} + +// Load loads and parses from INI data sources. +// Arguments can be mixed of file name with string type, or raw data in []byte. +// It will return error if list contains nonexistent files. +func Load(source interface{}, others ...interface{}) (*File, error) { + return LoadSources(LoadOptions{}, source, others...) +} + +// LooseLoad has exactly same functionality as Load function +// except it ignores nonexistent files instead of returning error. +func LooseLoad(source interface{}, others ...interface{}) (*File, error) { + return LoadSources(LoadOptions{Loose: true}, source, others...) +} + +// InsensitiveLoad has exactly same functionality as Load function +// except it forces all section and key names to be lowercased. +func InsensitiveLoad(source interface{}, others ...interface{}) (*File, error) { + return LoadSources(LoadOptions{Insensitive: true}, source, others...) +} + +// ShadowLoad has exactly same functionality as Load function +// except it allows have shadow keys. +func ShadowLoad(source interface{}, others ...interface{}) (*File, error) { + return LoadSources(LoadOptions{AllowShadows: true}, source, others...) +} diff --git a/vendor/gopkg.in/ini.v1/key.go b/vendor/gopkg.in/ini.v1/key.go new file mode 100644 index 0000000000..8baafd9ea6 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/key.go @@ -0,0 +1,829 @@ +// Copyright 2014 Unknwon +// +// 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 ini + +import ( + "bytes" + "errors" + "fmt" + "strconv" + "strings" + "time" +) + +// Key represents a key under a section. +type Key struct { + s *Section + Comment string + name string + value string + isAutoIncrement bool + isBooleanType bool + + isShadow bool + shadows []*Key + + nestedValues []string +} + +// newKey simply return a key object with given values. +func newKey(s *Section, name, val string) *Key { + return &Key{ + s: s, + name: name, + value: val, + } +} + +func (k *Key) addShadow(val string) error { + if k.isShadow { + return errors.New("cannot add shadow to another shadow key") + } else if k.isAutoIncrement || k.isBooleanType { + return errors.New("cannot add shadow to auto-increment or boolean key") + } + + // Deduplicate shadows based on their values. + if k.value == val { + return nil + } + for i := range k.shadows { + if k.shadows[i].value == val { + return nil + } + } + + shadow := newKey(k.s, k.name, val) + shadow.isShadow = true + k.shadows = append(k.shadows, shadow) + return nil +} + +// AddShadow adds a new shadow key to itself. +func (k *Key) AddShadow(val string) error { + if !k.s.f.options.AllowShadows { + return errors.New("shadow key is not allowed") + } + return k.addShadow(val) +} + +func (k *Key) addNestedValue(val string) error { + if k.isAutoIncrement || k.isBooleanType { + return errors.New("cannot add nested value to auto-increment or boolean key") + } + + k.nestedValues = append(k.nestedValues, val) + return nil +} + +// AddNestedValue adds a nested value to the key. +func (k *Key) AddNestedValue(val string) error { + if !k.s.f.options.AllowNestedValues { + return errors.New("nested value is not allowed") + } + return k.addNestedValue(val) +} + +// ValueMapper represents a mapping function for values, e.g. os.ExpandEnv +type ValueMapper func(string) string + +// Name returns name of key. +func (k *Key) Name() string { + return k.name +} + +// Value returns raw value of key for performance purpose. +func (k *Key) Value() string { + return k.value +} + +// ValueWithShadows returns raw values of key and its shadows if any. +func (k *Key) ValueWithShadows() []string { + if len(k.shadows) == 0 { + return []string{k.value} + } + vals := make([]string, len(k.shadows)+1) + vals[0] = k.value + for i := range k.shadows { + vals[i+1] = k.shadows[i].value + } + return vals +} + +// NestedValues returns nested values stored in the key. +// It is possible returned value is nil if no nested values stored in the key. +func (k *Key) NestedValues() []string { + return k.nestedValues +} + +// transformValue takes a raw value and transforms to its final string. +func (k *Key) transformValue(val string) string { + if k.s.f.ValueMapper != nil { + val = k.s.f.ValueMapper(val) + } + + // Fail-fast if no indicate char found for recursive value + if !strings.Contains(val, "%") { + return val + } + for i := 0; i < depthValues; i++ { + vr := varPattern.FindString(val) + if len(vr) == 0 { + break + } + + // Take off leading '%(' and trailing ')s'. + noption := vr[2 : len(vr)-2] + + // Search in the same section. + // If not found or found the key itself, then search again in default section. + nk, err := k.s.GetKey(noption) + if err != nil || k == nk { + nk, _ = k.s.f.Section("").GetKey(noption) + if nk == nil { + // Stop when no results found in the default section, + // and returns the value as-is. + break + } + } + + // Substitute by new value and take off leading '%(' and trailing ')s'. + val = strings.Replace(val, vr, nk.value, -1) + } + return val +} + +// String returns string representation of value. +func (k *Key) String() string { + return k.transformValue(k.value) +} + +// Validate accepts a validate function which can +// return modifed result as key value. +func (k *Key) Validate(fn func(string) string) string { + return fn(k.String()) +} + +// parseBool returns the boolean value represented by the string. +// +// It accepts 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On, +// 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off. +// Any other value returns an error. +func parseBool(str string) (value bool, err error) { + switch str { + case "1", "t", "T", "true", "TRUE", "True", "YES", "yes", "Yes", "y", "ON", "on", "On": + return true, nil + case "0", "f", "F", "false", "FALSE", "False", "NO", "no", "No", "n", "OFF", "off", "Off": + return false, nil + } + return false, fmt.Errorf("parsing \"%s\": invalid syntax", str) +} + +// Bool returns bool type value. +func (k *Key) Bool() (bool, error) { + return parseBool(k.String()) +} + +// Float64 returns float64 type value. +func (k *Key) Float64() (float64, error) { + return strconv.ParseFloat(k.String(), 64) +} + +// Int returns int type value. +func (k *Key) Int() (int, error) { + v, err := strconv.ParseInt(k.String(), 0, 64) + return int(v), err +} + +// Int64 returns int64 type value. +func (k *Key) Int64() (int64, error) { + return strconv.ParseInt(k.String(), 0, 64) +} + +// Uint returns uint type valued. +func (k *Key) Uint() (uint, error) { + u, e := strconv.ParseUint(k.String(), 0, 64) + return uint(u), e +} + +// Uint64 returns uint64 type value. +func (k *Key) Uint64() (uint64, error) { + return strconv.ParseUint(k.String(), 0, 64) +} + +// Duration returns time.Duration type value. +func (k *Key) Duration() (time.Duration, error) { + return time.ParseDuration(k.String()) +} + +// TimeFormat parses with given format and returns time.Time type value. +func (k *Key) TimeFormat(format string) (time.Time, error) { + return time.Parse(format, k.String()) +} + +// Time parses with RFC3339 format and returns time.Time type value. +func (k *Key) Time() (time.Time, error) { + return k.TimeFormat(time.RFC3339) +} + +// MustString returns default value if key value is empty. +func (k *Key) MustString(defaultVal string) string { + val := k.String() + if len(val) == 0 { + k.value = defaultVal + return defaultVal + } + return val +} + +// MustBool always returns value without error, +// it returns false if error occurs. +func (k *Key) MustBool(defaultVal ...bool) bool { + val, err := k.Bool() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatBool(defaultVal[0]) + return defaultVal[0] + } + return val +} + +// MustFloat64 always returns value without error, +// it returns 0.0 if error occurs. +func (k *Key) MustFloat64(defaultVal ...float64) float64 { + val, err := k.Float64() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatFloat(defaultVal[0], 'f', -1, 64) + return defaultVal[0] + } + return val +} + +// MustInt always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt(defaultVal ...int) int { + val, err := k.Int() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatInt(int64(defaultVal[0]), 10) + return defaultVal[0] + } + return val +} + +// MustInt64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt64(defaultVal ...int64) int64 { + val, err := k.Int64() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatInt(defaultVal[0], 10) + return defaultVal[0] + } + return val +} + +// MustUint always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint(defaultVal ...uint) uint { + val, err := k.Uint() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatUint(uint64(defaultVal[0]), 10) + return defaultVal[0] + } + return val +} + +// MustUint64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint64(defaultVal ...uint64) uint64 { + val, err := k.Uint64() + if len(defaultVal) > 0 && err != nil { + k.value = strconv.FormatUint(defaultVal[0], 10) + return defaultVal[0] + } + return val +} + +// MustDuration always returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustDuration(defaultVal ...time.Duration) time.Duration { + val, err := k.Duration() + if len(defaultVal) > 0 && err != nil { + k.value = defaultVal[0].String() + return defaultVal[0] + } + return val +} + +// MustTimeFormat always parses with given format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTimeFormat(format string, defaultVal ...time.Time) time.Time { + val, err := k.TimeFormat(format) + if len(defaultVal) > 0 && err != nil { + k.value = defaultVal[0].Format(format) + return defaultVal[0] + } + return val +} + +// MustTime always parses with RFC3339 format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTime(defaultVal ...time.Time) time.Time { + return k.MustTimeFormat(time.RFC3339, defaultVal...) +} + +// In always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) In(defaultVal string, candidates []string) string { + val := k.String() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InFloat64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InFloat64(defaultVal float64, candidates []float64) float64 { + val := k.MustFloat64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt(defaultVal int, candidates []int) int { + val := k.MustInt() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt64(defaultVal int64, candidates []int64) int64 { + val := k.MustInt64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint(defaultVal uint, candidates []uint) uint { + val := k.MustUint() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint64(defaultVal uint64, candidates []uint64) uint64 { + val := k.MustUint64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTimeFormat always parses with given format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time { + val := k.MustTimeFormat(format) + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTime always parses with RFC3339 format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTime(defaultVal time.Time, candidates []time.Time) time.Time { + return k.InTimeFormat(time.RFC3339, defaultVal, candidates) +} + +// RangeFloat64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeFloat64(defaultVal, min, max float64) float64 { + val := k.MustFloat64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt(defaultVal, min, max int) int { + val := k.MustInt() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt64(defaultVal, min, max int64) int64 { + val := k.MustInt64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeTimeFormat checks if value with given format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTimeFormat(format string, defaultVal, min, max time.Time) time.Time { + val := k.MustTimeFormat(format) + if val.Unix() < min.Unix() || val.Unix() > max.Unix() { + return defaultVal + } + return val +} + +// RangeTime checks if value with RFC3339 format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTime(defaultVal, min, max time.Time) time.Time { + return k.RangeTimeFormat(time.RFC3339, defaultVal, min, max) +} + +// Strings returns list of string divided by given delimiter. +func (k *Key) Strings(delim string) []string { + str := k.String() + if len(str) == 0 { + return []string{} + } + + runes := []rune(str) + vals := make([]string, 0, 2) + var buf bytes.Buffer + escape := false + idx := 0 + for { + if escape { + escape = false + if runes[idx] != '\\' && !strings.HasPrefix(string(runes[idx:]), delim) { + buf.WriteRune('\\') + } + buf.WriteRune(runes[idx]) + } else { + if runes[idx] == '\\' { + escape = true + } else if strings.HasPrefix(string(runes[idx:]), delim) { + idx += len(delim) - 1 + vals = append(vals, strings.TrimSpace(buf.String())) + buf.Reset() + } else { + buf.WriteRune(runes[idx]) + } + } + idx++ + if idx == len(runes) { + break + } + } + + if buf.Len() > 0 { + vals = append(vals, strings.TrimSpace(buf.String())) + } + + return vals +} + +// StringsWithShadows returns list of string divided by given delimiter. +// Shadows will also be appended if any. +func (k *Key) StringsWithShadows(delim string) []string { + vals := k.ValueWithShadows() + results := make([]string, 0, len(vals)*2) + for i := range vals { + if len(vals) == 0 { + continue + } + + results = append(results, strings.Split(vals[i], delim)...) + } + + for i := range results { + results[i] = k.transformValue(strings.TrimSpace(results[i])) + } + return results +} + +// Float64s returns list of float64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Float64s(delim string) []float64 { + vals, _ := k.parseFloat64s(k.Strings(delim), true, false) + return vals +} + +// Ints returns list of int divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Ints(delim string) []int { + vals, _ := k.parseInts(k.Strings(delim), true, false) + return vals +} + +// Int64s returns list of int64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Int64s(delim string) []int64 { + vals, _ := k.parseInt64s(k.Strings(delim), true, false) + return vals +} + +// Uints returns list of uint divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uints(delim string) []uint { + vals, _ := k.parseUints(k.Strings(delim), true, false) + return vals +} + +// Uint64s returns list of uint64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uint64s(delim string) []uint64 { + vals, _ := k.parseUint64s(k.Strings(delim), true, false) + return vals +} + +// Bools returns list of bool divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Bools(delim string) []bool { + vals, _ := k.parseBools(k.Strings(delim), true, false) + return vals +} + +// TimesFormat parses with given format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) TimesFormat(format, delim string) []time.Time { + vals, _ := k.parseTimesFormat(format, k.Strings(delim), true, false) + return vals +} + +// Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) Times(delim string) []time.Time { + return k.TimesFormat(time.RFC3339, delim) +} + +// ValidFloat64s returns list of float64 divided by given delimiter. If some value is not float, then +// it will not be included to result list. +func (k *Key) ValidFloat64s(delim string) []float64 { + vals, _ := k.parseFloat64s(k.Strings(delim), false, false) + return vals +} + +// ValidInts returns list of int divided by given delimiter. If some value is not integer, then it will +// not be included to result list. +func (k *Key) ValidInts(delim string) []int { + vals, _ := k.parseInts(k.Strings(delim), false, false) + return vals +} + +// ValidInt64s returns list of int64 divided by given delimiter. If some value is not 64-bit integer, +// then it will not be included to result list. +func (k *Key) ValidInt64s(delim string) []int64 { + vals, _ := k.parseInt64s(k.Strings(delim), false, false) + return vals +} + +// ValidUints returns list of uint divided by given delimiter. If some value is not unsigned integer, +// then it will not be included to result list. +func (k *Key) ValidUints(delim string) []uint { + vals, _ := k.parseUints(k.Strings(delim), false, false) + return vals +} + +// ValidUint64s returns list of uint64 divided by given delimiter. If some value is not 64-bit unsigned +// integer, then it will not be included to result list. +func (k *Key) ValidUint64s(delim string) []uint64 { + vals, _ := k.parseUint64s(k.Strings(delim), false, false) + return vals +} + +// ValidBools returns list of bool divided by given delimiter. If some value is not 64-bit unsigned +// integer, then it will not be included to result list. +func (k *Key) ValidBools(delim string) []bool { + vals, _ := k.parseBools(k.Strings(delim), false, false) + return vals +} + +// ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimesFormat(format, delim string) []time.Time { + vals, _ := k.parseTimesFormat(format, k.Strings(delim), false, false) + return vals +} + +// ValidTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimes(delim string) []time.Time { + return k.ValidTimesFormat(time.RFC3339, delim) +} + +// StrictFloat64s returns list of float64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictFloat64s(delim string) ([]float64, error) { + return k.parseFloat64s(k.Strings(delim), false, true) +} + +// StrictInts returns list of int divided by given delimiter or error on first invalid input. +func (k *Key) StrictInts(delim string) ([]int, error) { + return k.parseInts(k.Strings(delim), false, true) +} + +// StrictInt64s returns list of int64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictInt64s(delim string) ([]int64, error) { + return k.parseInt64s(k.Strings(delim), false, true) +} + +// StrictUints returns list of uint divided by given delimiter or error on first invalid input. +func (k *Key) StrictUints(delim string) ([]uint, error) { + return k.parseUints(k.Strings(delim), false, true) +} + +// StrictUint64s returns list of uint64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictUint64s(delim string) ([]uint64, error) { + return k.parseUint64s(k.Strings(delim), false, true) +} + +// StrictBools returns list of bool divided by given delimiter or error on first invalid input. +func (k *Key) StrictBools(delim string) ([]bool, error) { + return k.parseBools(k.Strings(delim), false, true) +} + +// StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimesFormat(format, delim string) ([]time.Time, error) { + return k.parseTimesFormat(format, k.Strings(delim), false, true) +} + +// StrictTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimes(delim string) ([]time.Time, error) { + return k.StrictTimesFormat(time.RFC3339, delim) +} + +// parseBools transforms strings to bools. +func (k *Key) parseBools(strs []string, addInvalid, returnOnInvalid bool) ([]bool, error) { + vals := make([]bool, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := parseBool(str) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(bool)) + } + } + return vals, err +} + +// parseFloat64s transforms strings to float64s. +func (k *Key) parseFloat64s(strs []string, addInvalid, returnOnInvalid bool) ([]float64, error) { + vals := make([]float64, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseFloat(str, 64) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(float64)) + } + } + return vals, err +} + +// parseInts transforms strings to ints. +func (k *Key) parseInts(strs []string, addInvalid, returnOnInvalid bool) ([]int, error) { + vals := make([]int, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseInt(str, 0, 64) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, int(val.(int64))) + } + } + return vals, err +} + +// parseInt64s transforms strings to int64s. +func (k *Key) parseInt64s(strs []string, addInvalid, returnOnInvalid bool) ([]int64, error) { + vals := make([]int64, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseInt(str, 0, 64) + return val, err + } + + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(int64)) + } + } + return vals, err +} + +// parseUints transforms strings to uints. +func (k *Key) parseUints(strs []string, addInvalid, returnOnInvalid bool) ([]uint, error) { + vals := make([]uint, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseUint(str, 0, 64) + return val, err + } + + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, uint(val.(uint64))) + } + } + return vals, err +} + +// parseUint64s transforms strings to uint64s. +func (k *Key) parseUint64s(strs []string, addInvalid, returnOnInvalid bool) ([]uint64, error) { + vals := make([]uint64, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseUint(str, 0, 64) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(uint64)) + } + } + return vals, err +} + + +type Parser func(str string) (interface{}, error) + + +// parseTimesFormat transforms strings to times in given format. +func (k *Key) parseTimesFormat(format string, strs []string, addInvalid, returnOnInvalid bool) ([]time.Time, error) { + vals := make([]time.Time, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := time.Parse(format, str) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(time.Time)) + } + } + return vals, err +} + + +// doParse transforms strings to different types +func (k *Key) doParse(strs []string, addInvalid, returnOnInvalid bool, parser Parser) ([]interface{}, error) { + vals := make([]interface{}, 0, len(strs)) + for _, str := range strs { + val, err := parser(str) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// SetValue changes key value. +func (k *Key) SetValue(v string) { + if k.s.f.BlockMode { + k.s.f.lock.Lock() + defer k.s.f.lock.Unlock() + } + + k.value = v + k.s.keysHash[k.name] = v +} diff --git a/vendor/gopkg.in/ini.v1/parser.go b/vendor/gopkg.in/ini.v1/parser.go new file mode 100644 index 0000000000..65147166f9 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/parser.go @@ -0,0 +1,535 @@ +// Copyright 2015 Unknwon +// +// 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 ini + +import ( + "bufio" + "bytes" + "fmt" + "io" + "regexp" + "strconv" + "strings" + "unicode" +) + +const minReaderBufferSize = 4096 + +var pythonMultiline = regexp.MustCompile(`^([\t\f ]+)(.*)`) + +type parserOptions struct { + IgnoreContinuation bool + IgnoreInlineComment bool + AllowPythonMultilineValues bool + SpaceBeforeInlineComment bool + UnescapeValueDoubleQuotes bool + UnescapeValueCommentSymbols bool + PreserveSurroundedQuote bool + DebugFunc DebugFunc + ReaderBufferSize int +} + +type parser struct { + buf *bufio.Reader + options parserOptions + + isEOF bool + count int + comment *bytes.Buffer +} + +func (p *parser) debug(format string, args ...interface{}) { + if p.options.DebugFunc != nil { + p.options.DebugFunc(fmt.Sprintf(format, args...)) + } +} + +func newParser(r io.Reader, opts parserOptions) *parser { + size := opts.ReaderBufferSize + if size < minReaderBufferSize { + size = minReaderBufferSize + } + + return &parser{ + buf: bufio.NewReaderSize(r, size), + options: opts, + count: 1, + comment: &bytes.Buffer{}, + } +} + +// BOM handles header of UTF-8, UTF-16 LE and UTF-16 BE's BOM format. +// http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding +func (p *parser) BOM() error { + mask, err := p.buf.Peek(2) + if err != nil && err != io.EOF { + return err + } else if len(mask) < 2 { + return nil + } + + switch { + case mask[0] == 254 && mask[1] == 255: + fallthrough + case mask[0] == 255 && mask[1] == 254: + _, err = p.buf.Read(mask) + if err != nil { + return err + } + case mask[0] == 239 && mask[1] == 187: + mask, err := p.buf.Peek(3) + if err != nil && err != io.EOF { + return err + } else if len(mask) < 3 { + return nil + } + if mask[2] == 191 { + _, err = p.buf.Read(mask) + if err != nil { + return err + } + } + } + return nil +} + +func (p *parser) readUntil(delim byte) ([]byte, error) { + data, err := p.buf.ReadBytes(delim) + if err != nil { + if err == io.EOF { + p.isEOF = true + } else { + return nil, err + } + } + return data, nil +} + +func cleanComment(in []byte) ([]byte, bool) { + i := bytes.IndexAny(in, "#;") + if i == -1 { + return nil, false + } + return in[i:], true +} + +func readKeyName(delimiters string, in []byte) (string, int, error) { + line := string(in) + + // Check if key name surrounded by quotes. + var keyQuote string + if line[0] == '"' { + if len(line) > 6 && string(line[0:3]) == `"""` { + keyQuote = `"""` + } else { + keyQuote = `"` + } + } else if line[0] == '`' { + keyQuote = "`" + } + + // Get out key name + var endIdx int + if len(keyQuote) > 0 { + startIdx := len(keyQuote) + // FIXME: fail case -> """"""name"""=value + pos := strings.Index(line[startIdx:], keyQuote) + if pos == -1 { + return "", -1, fmt.Errorf("missing closing key quote: %s", line) + } + pos += startIdx + + // Find key-value delimiter + i := strings.IndexAny(line[pos+startIdx:], delimiters) + if i < 0 { + return "", -1, ErrDelimiterNotFound{line} + } + endIdx = pos + i + return strings.TrimSpace(line[startIdx:pos]), endIdx + startIdx + 1, nil + } + + endIdx = strings.IndexAny(line, delimiters) + if endIdx < 0 { + return "", -1, ErrDelimiterNotFound{line} + } + return strings.TrimSpace(line[0:endIdx]), endIdx + 1, nil +} + +func (p *parser) readMultilines(line, val, valQuote string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := string(data) + + pos := strings.LastIndex(next, valQuote) + if pos > -1 { + val += next[:pos] + + comment, has := cleanComment([]byte(next[pos:])) + if has { + p.comment.Write(bytes.TrimSpace(comment)) + } + break + } + val += next + if p.isEOF { + return "", fmt.Errorf("missing closing key quote from %q to %q", line, next) + } + } + return val, nil +} + +func (p *parser) readContinuationLines(val string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := strings.TrimSpace(string(data)) + + if len(next) == 0 { + break + } + val += next + if val[len(val)-1] != '\\' { + break + } + val = val[:len(val)-1] + } + return val, nil +} + +// hasSurroundedQuote check if and only if the first and last characters +// are quotes \" or \'. +// It returns false if any other parts also contain same kind of quotes. +func hasSurroundedQuote(in string, quote byte) bool { + return len(in) >= 2 && in[0] == quote && in[len(in)-1] == quote && + strings.IndexByte(in[1:], quote) == len(in)-2 +} + +func (p *parser) readValue(in []byte, bufferSize int) (string, error) { + + line := strings.TrimLeftFunc(string(in), unicode.IsSpace) + if len(line) == 0 { + if p.options.AllowPythonMultilineValues && len(in) > 0 && in[len(in)-1] == '\n' { + return p.readPythonMultilines(line, bufferSize) + } + return "", nil + } + + var valQuote string + if len(line) > 3 && string(line[0:3]) == `"""` { + valQuote = `"""` + } else if line[0] == '`' { + valQuote = "`" + } else if p.options.UnescapeValueDoubleQuotes && line[0] == '"' { + valQuote = `"` + } + + if len(valQuote) > 0 { + startIdx := len(valQuote) + pos := strings.LastIndex(line[startIdx:], valQuote) + // Check for multi-line value + if pos == -1 { + return p.readMultilines(line, line[startIdx:], valQuote) + } + + if p.options.UnescapeValueDoubleQuotes && valQuote == `"` { + return strings.Replace(line[startIdx:pos+startIdx], `\"`, `"`, -1), nil + } + return line[startIdx : pos+startIdx], nil + } + + lastChar := line[len(line)-1] + // Won't be able to reach here if value only contains whitespace + line = strings.TrimSpace(line) + trimmedLastChar := line[len(line)-1] + + // Check continuation lines when desired + if !p.options.IgnoreContinuation && trimmedLastChar == '\\' { + return p.readContinuationLines(line[:len(line)-1]) + } + + // Check if ignore inline comment + if !p.options.IgnoreInlineComment { + var i int + if p.options.SpaceBeforeInlineComment { + i = strings.Index(line, " #") + if i == -1 { + i = strings.Index(line, " ;") + } + + } else { + i = strings.IndexAny(line, "#;") + } + + if i > -1 { + p.comment.WriteString(line[i:]) + line = strings.TrimSpace(line[:i]) + } + + } + + // Trim single and double quotes + if (hasSurroundedQuote(line, '\'') || + hasSurroundedQuote(line, '"')) && !p.options.PreserveSurroundedQuote { + line = line[1 : len(line)-1] + } else if len(valQuote) == 0 && p.options.UnescapeValueCommentSymbols { + if strings.Contains(line, `\;`) { + line = strings.Replace(line, `\;`, ";", -1) + } + if strings.Contains(line, `\#`) { + line = strings.Replace(line, `\#`, "#", -1) + } + } else if p.options.AllowPythonMultilineValues && lastChar == '\n' { + return p.readPythonMultilines(line, bufferSize) + } + + return line, nil +} + +func (p *parser) readPythonMultilines(line string, bufferSize int) (string, error) { + parserBufferPeekResult, _ := p.buf.Peek(bufferSize) + peekBuffer := bytes.NewBuffer(parserBufferPeekResult) + + indentSize := 0 + for { + peekData, peekErr := peekBuffer.ReadBytes('\n') + if peekErr != nil { + if peekErr == io.EOF { + p.debug("readPythonMultilines: io.EOF, peekData: %q, line: %q", string(peekData), line) + return line, nil + } + + p.debug("readPythonMultilines: failed to peek with error: %v", peekErr) + return "", peekErr + } + + p.debug("readPythonMultilines: parsing %q", string(peekData)) + + peekMatches := pythonMultiline.FindStringSubmatch(string(peekData)) + p.debug("readPythonMultilines: matched %d parts", len(peekMatches)) + for n, v := range peekMatches { + p.debug(" %d: %q", n, v) + } + + // Return if not a Python multiline value. + if len(peekMatches) != 3 { + p.debug("readPythonMultilines: end of value, got: %q", line) + return line, nil + } + + // Determine indent size and line prefix. + currentIndentSize := len(peekMatches[1]) + if indentSize < 1 { + indentSize = currentIndentSize + p.debug("readPythonMultilines: indent size is %d", indentSize) + } + + // Make sure each line is indented at least as far as first line. + if currentIndentSize < indentSize { + p.debug("readPythonMultilines: end of value, current indent: %d, expected indent: %d, line: %q", currentIndentSize, indentSize, line) + return line, nil + } + + // Advance the parser reader (buffer) in-sync with the peek buffer. + _, err := p.buf.Discard(len(peekData)) + if err != nil { + p.debug("readPythonMultilines: failed to skip to the end, returning error") + return "", err + } + + // Handle indented empty line. + line += "\n" + peekMatches[1][indentSize:] + peekMatches[2] + } +} + +// parse parses data through an io.Reader. +func (f *File) parse(reader io.Reader) (err error) { + p := newParser(reader, parserOptions{ + IgnoreContinuation: f.options.IgnoreContinuation, + IgnoreInlineComment: f.options.IgnoreInlineComment, + AllowPythonMultilineValues: f.options.AllowPythonMultilineValues, + SpaceBeforeInlineComment: f.options.SpaceBeforeInlineComment, + UnescapeValueDoubleQuotes: f.options.UnescapeValueDoubleQuotes, + UnescapeValueCommentSymbols: f.options.UnescapeValueCommentSymbols, + PreserveSurroundedQuote: f.options.PreserveSurroundedQuote, + DebugFunc: f.options.DebugFunc, + ReaderBufferSize: f.options.ReaderBufferSize, + }) + if err = p.BOM(); err != nil { + return fmt.Errorf("BOM: %v", err) + } + + // Ignore error because default section name is never empty string. + name := DefaultSection + if f.options.Insensitive || f.options.InsensitiveSections { + name = strings.ToLower(DefaultSection) + } + section, _ := f.NewSection(name) + + // This "last" is not strictly equivalent to "previous one" if current key is not the first nested key + var isLastValueEmpty bool + var lastRegularKey *Key + + var line []byte + var inUnparseableSection bool + + // NOTE: Iterate and increase `currentPeekSize` until + // the size of the parser buffer is found. + // TODO(unknwon): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`. + parserBufferSize := 0 + // NOTE: Peek 4kb at a time. + currentPeekSize := minReaderBufferSize + + if f.options.AllowPythonMultilineValues { + for { + peekBytes, _ := p.buf.Peek(currentPeekSize) + peekBytesLength := len(peekBytes) + + if parserBufferSize >= peekBytesLength { + break + } + + currentPeekSize *= 2 + parserBufferSize = peekBytesLength + } + } + + for !p.isEOF { + line, err = p.readUntil('\n') + if err != nil { + return err + } + + if f.options.AllowNestedValues && + isLastValueEmpty && len(line) > 0 { + if line[0] == ' ' || line[0] == '\t' { + err = lastRegularKey.addNestedValue(string(bytes.TrimSpace(line))) + if err != nil { + return err + } + continue + } + } + + line = bytes.TrimLeftFunc(line, unicode.IsSpace) + if len(line) == 0 { + continue + } + + // Comments + if line[0] == '#' || line[0] == ';' { + // Note: we do not care ending line break, + // it is needed for adding second line, + // so just clean it once at the end when set to value. + p.comment.Write(line) + continue + } + + // Section + if line[0] == '[' { + // Read to the next ']' (TODO: support quoted strings) + closeIdx := bytes.LastIndexByte(line, ']') + if closeIdx == -1 { + return fmt.Errorf("unclosed section: %s", line) + } + + name := string(line[1:closeIdx]) + section, err = f.NewSection(name) + if err != nil { + return err + } + + comment, has := cleanComment(line[closeIdx+1:]) + if has { + p.comment.Write(comment) + } + + section.Comment = strings.TrimSpace(p.comment.String()) + + // Reset auto-counter and comments + p.comment.Reset() + p.count = 1 + + inUnparseableSection = false + for i := range f.options.UnparseableSections { + if f.options.UnparseableSections[i] == name || + ((f.options.Insensitive || f.options.InsensitiveSections) && strings.EqualFold(f.options.UnparseableSections[i], name)) { + inUnparseableSection = true + continue + } + } + continue + } + + if inUnparseableSection { + section.isRawSection = true + section.rawBody += string(line) + continue + } + + kname, offset, err := readKeyName(f.options.KeyValueDelimiters, line) + if err != nil { + // Treat as boolean key when desired, and whole line is key name. + if IsErrDelimiterNotFound(err) { + switch { + case f.options.AllowBooleanKeys: + kname, err := p.readValue(line, parserBufferSize) + if err != nil { + return err + } + key, err := section.NewBooleanKey(kname) + if err != nil { + return err + } + key.Comment = strings.TrimSpace(p.comment.String()) + p.comment.Reset() + continue + + case f.options.SkipUnrecognizableLines: + continue + } + } + return err + } + + // Auto increment. + isAutoIncr := false + if kname == "-" { + isAutoIncr = true + kname = "#" + strconv.Itoa(p.count) + p.count++ + } + + value, err := p.readValue(line[offset:], parserBufferSize) + if err != nil { + return err + } + isLastValueEmpty = len(value) == 0 + + key, err := section.NewKey(kname, value) + if err != nil { + return err + } + key.isAutoIncrement = isAutoIncr + key.Comment = strings.TrimSpace(p.comment.String()) + p.comment.Reset() + lastRegularKey = key + } + return nil +} diff --git a/vendor/gopkg.in/ini.v1/section.go b/vendor/gopkg.in/ini.v1/section.go new file mode 100644 index 0000000000..afaa97c97e --- /dev/null +++ b/vendor/gopkg.in/ini.v1/section.go @@ -0,0 +1,256 @@ +// Copyright 2014 Unknwon +// +// 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 ini + +import ( + "errors" + "fmt" + "strings" +) + +// Section represents a config section. +type Section struct { + f *File + Comment string + name string + keys map[string]*Key + keyList []string + keysHash map[string]string + + isRawSection bool + rawBody string +} + +func newSection(f *File, name string) *Section { + return &Section{ + f: f, + name: name, + keys: make(map[string]*Key), + keyList: make([]string, 0, 10), + keysHash: make(map[string]string), + } +} + +// Name returns name of Section. +func (s *Section) Name() string { + return s.name +} + +// Body returns rawBody of Section if the section was marked as unparseable. +// It still follows the other rules of the INI format surrounding leading/trailing whitespace. +func (s *Section) Body() string { + return strings.TrimSpace(s.rawBody) +} + +// SetBody updates body content only if section is raw. +func (s *Section) SetBody(body string) { + if !s.isRawSection { + return + } + s.rawBody = body +} + +// NewKey creates a new key to given section. +func (s *Section) NewKey(name, val string) (*Key, error) { + if len(name) == 0 { + return nil, errors.New("error creating new key: empty key name") + } else if s.f.options.Insensitive || s.f.options.InsensitiveKeys { + name = strings.ToLower(name) + } + + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + if inSlice(name, s.keyList) { + if s.f.options.AllowShadows { + if err := s.keys[name].addShadow(val); err != nil { + return nil, err + } + } else { + s.keys[name].value = val + s.keysHash[name] = val + } + return s.keys[name], nil + } + + s.keyList = append(s.keyList, name) + s.keys[name] = newKey(s, name, val) + s.keysHash[name] = val + return s.keys[name], nil +} + +// NewBooleanKey creates a new boolean type key to given section. +func (s *Section) NewBooleanKey(name string) (*Key, error) { + key, err := s.NewKey(name, "true") + if err != nil { + return nil, err + } + + key.isBooleanType = true + return key, nil +} + +// GetKey returns key in section by given name. +func (s *Section) GetKey(name string) (*Key, error) { + if s.f.BlockMode { + s.f.lock.RLock() + } + if s.f.options.Insensitive || s.f.options.InsensitiveKeys { + name = strings.ToLower(name) + } + key := s.keys[name] + if s.f.BlockMode { + s.f.lock.RUnlock() + } + + if key == nil { + // Check if it is a child-section. + sname := s.name + for { + if i := strings.LastIndex(sname, s.f.options.ChildSectionDelimiter); i > -1 { + sname = sname[:i] + sec, err := s.f.GetSection(sname) + if err != nil { + continue + } + return sec.GetKey(name) + } + break + } + return nil, fmt.Errorf("error when getting key of section %q: key %q not exists", s.name, name) + } + return key, nil +} + +// HasKey returns true if section contains a key with given name. +func (s *Section) HasKey(name string) bool { + key, _ := s.GetKey(name) + return key != nil +} + +// Deprecated: Use "HasKey" instead. +func (s *Section) Haskey(name string) bool { + return s.HasKey(name) +} + +// HasValue returns true if section contains given raw value. +func (s *Section) HasValue(value string) bool { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + for _, k := range s.keys { + if value == k.value { + return true + } + } + return false +} + +// Key assumes named Key exists in section and returns a zero-value when not. +func (s *Section) Key(name string) *Key { + key, err := s.GetKey(name) + if err != nil { + // It's OK here because the only possible error is empty key name, + // but if it's empty, this piece of code won't be executed. + key, _ = s.NewKey(name, "") + return key + } + return key +} + +// Keys returns list of keys of section. +func (s *Section) Keys() []*Key { + keys := make([]*Key, len(s.keyList)) + for i := range s.keyList { + keys[i] = s.Key(s.keyList[i]) + } + return keys +} + +// ParentKeys returns list of keys of parent section. +func (s *Section) ParentKeys() []*Key { + var parentKeys []*Key + sname := s.name + for { + if i := strings.LastIndex(sname, s.f.options.ChildSectionDelimiter); i > -1 { + sname = sname[:i] + sec, err := s.f.GetSection(sname) + if err != nil { + continue + } + parentKeys = append(parentKeys, sec.Keys()...) + } else { + break + } + + } + return parentKeys +} + +// KeyStrings returns list of key names of section. +func (s *Section) KeyStrings() []string { + list := make([]string, len(s.keyList)) + copy(list, s.keyList) + return list +} + +// KeysHash returns keys hash consisting of names and values. +func (s *Section) KeysHash() map[string]string { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + hash := map[string]string{} + for key, value := range s.keysHash { + hash[key] = value + } + return hash +} + +// DeleteKey deletes a key from section. +func (s *Section) DeleteKey(name string) { + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + for i, k := range s.keyList { + if k == name { + s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) + delete(s.keys, name) + delete(s.keysHash, name) + return + } + } +} + +// ChildSections returns a list of child sections of current section. +// For example, "[parent.child1]" and "[parent.child12]" are child sections +// of section "[parent]". +func (s *Section) ChildSections() []*Section { + prefix := s.name + s.f.options.ChildSectionDelimiter + children := make([]*Section, 0, 3) + for _, name := range s.f.sectionList { + if strings.HasPrefix(name, prefix) { + children = append(children, s.f.sections[name]...) + } + } + return children +} diff --git a/vendor/gopkg.in/ini.v1/struct.go b/vendor/gopkg.in/ini.v1/struct.go new file mode 100644 index 0000000000..a486b2fe0f --- /dev/null +++ b/vendor/gopkg.in/ini.v1/struct.go @@ -0,0 +1,747 @@ +// Copyright 2014 Unknwon +// +// 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 ini + +import ( + "bytes" + "errors" + "fmt" + "reflect" + "strings" + "time" + "unicode" +) + +// NameMapper represents a ini tag name mapper. +type NameMapper func(string) string + +// Built-in name getters. +var ( + // SnackCase converts to format SNACK_CASE. + SnackCase NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + } + newstr = append(newstr, unicode.ToUpper(chr)) + } + return string(newstr) + } + // TitleUnderscore converts to format title_underscore. + TitleUnderscore NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + chr -= 'A' - 'a' + } + newstr = append(newstr, chr) + } + return string(newstr) + } +) + +func (s *Section) parseFieldName(raw, actual string) string { + if len(actual) > 0 { + return actual + } + if s.f.NameMapper != nil { + return s.f.NameMapper(raw) + } + return raw +} + +func parseDelim(actual string) string { + if len(actual) > 0 { + return actual + } + return "," +} + +var reflectTime = reflect.TypeOf(time.Now()).Kind() + +// setSliceWithProperType sets proper values to slice based on its type. +func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowShadow, isStrict bool) error { + var strs []string + if allowShadow { + strs = key.StringsWithShadows(delim) + } else { + strs = key.Strings(delim) + } + + numVals := len(strs) + if numVals == 0 { + return nil + } + + var vals interface{} + var err error + + sliceOf := field.Type().Elem().Kind() + switch sliceOf { + case reflect.String: + vals = strs + case reflect.Int: + vals, err = key.parseInts(strs, true, false) + case reflect.Int64: + vals, err = key.parseInt64s(strs, true, false) + case reflect.Uint: + vals, err = key.parseUints(strs, true, false) + case reflect.Uint64: + vals, err = key.parseUint64s(strs, true, false) + case reflect.Float64: + vals, err = key.parseFloat64s(strs, true, false) + case reflect.Bool: + vals, err = key.parseBools(strs, true, false) + case reflectTime: + vals, err = key.parseTimesFormat(time.RFC3339, strs, true, false) + default: + return fmt.Errorf("unsupported type '[]%s'", sliceOf) + } + if err != nil && isStrict { + return err + } + + slice := reflect.MakeSlice(field.Type(), numVals, numVals) + for i := 0; i < numVals; i++ { + switch sliceOf { + case reflect.String: + slice.Index(i).Set(reflect.ValueOf(vals.([]string)[i])) + case reflect.Int: + slice.Index(i).Set(reflect.ValueOf(vals.([]int)[i])) + case reflect.Int64: + slice.Index(i).Set(reflect.ValueOf(vals.([]int64)[i])) + case reflect.Uint: + slice.Index(i).Set(reflect.ValueOf(vals.([]uint)[i])) + case reflect.Uint64: + slice.Index(i).Set(reflect.ValueOf(vals.([]uint64)[i])) + case reflect.Float64: + slice.Index(i).Set(reflect.ValueOf(vals.([]float64)[i])) + case reflect.Bool: + slice.Index(i).Set(reflect.ValueOf(vals.([]bool)[i])) + case reflectTime: + slice.Index(i).Set(reflect.ValueOf(vals.([]time.Time)[i])) + } + } + field.Set(slice) + return nil +} + +func wrapStrictError(err error, isStrict bool) error { + if isStrict { + return err + } + return nil +} + +// setWithProperType sets proper value to field based on its type, +// but it does not return error for failing parsing, +// because we want to use default value that is already assigned to struct. +func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string, allowShadow, isStrict bool) error { + vt := t + isPtr := t.Kind() == reflect.Ptr + if isPtr { + vt = t.Elem() + } + switch vt.Kind() { + case reflect.String: + stringVal := key.String() + if isPtr { + field.Set(reflect.ValueOf(&stringVal)) + } else if len(stringVal) > 0 { + field.SetString(key.String()) + } + case reflect.Bool: + boolVal, err := key.Bool() + if err != nil { + return wrapStrictError(err, isStrict) + } + if isPtr { + field.Set(reflect.ValueOf(&boolVal)) + } else { + field.SetBool(boolVal) + } + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + // ParseDuration will not return err for `0`, so check the type name + if vt.Name() == "Duration" { + durationVal, err := key.Duration() + if err != nil { + if intVal, err := key.Int64(); err == nil { + field.SetInt(intVal) + return nil + } + return wrapStrictError(err, isStrict) + } + if isPtr { + field.Set(reflect.ValueOf(&durationVal)) + } else if int64(durationVal) > 0 { + field.Set(reflect.ValueOf(durationVal)) + } + return nil + } + + intVal, err := key.Int64() + if err != nil { + return wrapStrictError(err, isStrict) + } + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetInt(intVal) + field.Set(pv) + } else { + field.SetInt(intVal) + } + // byte is an alias for uint8, so supporting uint8 breaks support for byte + case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + durationVal, err := key.Duration() + // Skip zero value + if err == nil && uint64(durationVal) > 0 { + if isPtr { + field.Set(reflect.ValueOf(&durationVal)) + } else { + field.Set(reflect.ValueOf(durationVal)) + } + return nil + } + + uintVal, err := key.Uint64() + if err != nil { + return wrapStrictError(err, isStrict) + } + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetUint(uintVal) + field.Set(pv) + } else { + field.SetUint(uintVal) + } + + case reflect.Float32, reflect.Float64: + floatVal, err := key.Float64() + if err != nil { + return wrapStrictError(err, isStrict) + } + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetFloat(floatVal) + field.Set(pv) + } else { + field.SetFloat(floatVal) + } + case reflectTime: + timeVal, err := key.Time() + if err != nil { + return wrapStrictError(err, isStrict) + } + if isPtr { + field.Set(reflect.ValueOf(&timeVal)) + } else { + field.Set(reflect.ValueOf(timeVal)) + } + case reflect.Slice: + return setSliceWithProperType(key, field, delim, allowShadow, isStrict) + default: + return fmt.Errorf("unsupported type %q", t) + } + return nil +} + +func parseTagOptions(tag string) (rawName string, omitEmpty bool, allowShadow bool, allowNonUnique bool, extends bool) { + opts := strings.SplitN(tag, ",", 5) + rawName = opts[0] + for _, opt := range opts[1:] { + omitEmpty = omitEmpty || (opt == "omitempty") + allowShadow = allowShadow || (opt == "allowshadow") + allowNonUnique = allowNonUnique || (opt == "nonunique") + extends = extends || (opt == "extends") + } + return rawName, omitEmpty, allowShadow, allowNonUnique, extends +} + +// mapToField maps the given value to the matching field of the given section. +// The sectionIndex is the index (if non unique sections are enabled) to which the value should be added. +func (s *Section) mapToField(val reflect.Value, isStrict bool, sectionIndex int, sectionName string) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + rawName, _, allowShadow, allowNonUnique, extends := parseTagOptions(tag) + fieldName := s.parseFieldName(tpField.Name, rawName) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + isStruct := tpField.Type.Kind() == reflect.Struct + isStructPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct + isAnonymousPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous + if isAnonymousPtr { + field.Set(reflect.New(tpField.Type.Elem())) + } + + if extends && (isAnonymousPtr || (isStruct && tpField.Anonymous)) { + if isStructPtr && field.IsNil() { + field.Set(reflect.New(tpField.Type.Elem())) + } + fieldSection := s + if rawName != "" { + sectionName = s.name + s.f.options.ChildSectionDelimiter + rawName + if secs, err := s.f.SectionsByName(sectionName); err == nil && sectionIndex < len(secs) { + fieldSection = secs[sectionIndex] + } + } + if err := fieldSection.mapToField(field, isStrict, sectionIndex, sectionName); err != nil { + return fmt.Errorf("map to field %q: %v", fieldName, err) + } + } else if isAnonymousPtr || isStruct || isStructPtr { + if secs, err := s.f.SectionsByName(fieldName); err == nil { + if len(secs) <= sectionIndex { + return fmt.Errorf("there are not enough sections (%d <= %d) for the field %q", len(secs), sectionIndex, fieldName) + } + // Only set the field to non-nil struct value if we have a section for it. + // Otherwise, we end up with a non-nil struct ptr even though there is no data. + if isStructPtr && field.IsNil() { + field.Set(reflect.New(tpField.Type.Elem())) + } + if err = secs[sectionIndex].mapToField(field, isStrict, sectionIndex, fieldName); err != nil { + return fmt.Errorf("map to field %q: %v", fieldName, err) + } + continue + } + } + + // Map non-unique sections + if allowNonUnique && tpField.Type.Kind() == reflect.Slice { + newField, err := s.mapToSlice(fieldName, field, isStrict) + if err != nil { + return fmt.Errorf("map to slice %q: %v", fieldName, err) + } + + field.Set(newField) + continue + } + + if key, err := s.GetKey(fieldName); err == nil { + delim := parseDelim(tpField.Tag.Get("delim")) + if err = setWithProperType(tpField.Type, key, field, delim, allowShadow, isStrict); err != nil { + return fmt.Errorf("set field %q: %v", fieldName, err) + } + } + } + return nil +} + +// mapToSlice maps all sections with the same name and returns the new value. +// The type of the Value must be a slice. +func (s *Section) mapToSlice(secName string, val reflect.Value, isStrict bool) (reflect.Value, error) { + secs, err := s.f.SectionsByName(secName) + if err != nil { + return reflect.Value{}, err + } + + typ := val.Type().Elem() + for i, sec := range secs { + elem := reflect.New(typ) + if err = sec.mapToField(elem, isStrict, i, sec.name); err != nil { + return reflect.Value{}, fmt.Errorf("map to field from section %q: %v", secName, err) + } + + val = reflect.Append(val, elem.Elem()) + } + return val, nil +} + +// mapTo maps a section to object v. +func (s *Section) mapTo(v interface{}, isStrict bool) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return errors.New("not a pointer to a struct") + } + + if typ.Kind() == reflect.Slice { + newField, err := s.mapToSlice(s.name, val, isStrict) + if err != nil { + return err + } + + val.Set(newField) + return nil + } + + return s.mapToField(val, isStrict, 0, s.name) +} + +// MapTo maps section to given struct. +func (s *Section) MapTo(v interface{}) error { + return s.mapTo(v, false) +} + +// StrictMapTo maps section to given struct in strict mode, +// which returns all possible error including value parsing error. +func (s *Section) StrictMapTo(v interface{}) error { + return s.mapTo(v, true) +} + +// MapTo maps file to given struct. +func (f *File) MapTo(v interface{}) error { + return f.Section("").MapTo(v) +} + +// StrictMapTo maps file to given struct in strict mode, +// which returns all possible error including value parsing error. +func (f *File) StrictMapTo(v interface{}) error { + return f.Section("").StrictMapTo(v) +} + +// MapToWithMapper maps data sources to given struct with name mapper. +func MapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error { + cfg, err := Load(source, others...) + if err != nil { + return err + } + cfg.NameMapper = mapper + return cfg.MapTo(v) +} + +// StrictMapToWithMapper maps data sources to given struct with name mapper in strict mode, +// which returns all possible error including value parsing error. +func StrictMapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error { + cfg, err := Load(source, others...) + if err != nil { + return err + } + cfg.NameMapper = mapper + return cfg.StrictMapTo(v) +} + +// MapTo maps data sources to given struct. +func MapTo(v, source interface{}, others ...interface{}) error { + return MapToWithMapper(v, nil, source, others...) +} + +// StrictMapTo maps data sources to given struct in strict mode, +// which returns all possible error including value parsing error. +func StrictMapTo(v, source interface{}, others ...interface{}) error { + return StrictMapToWithMapper(v, nil, source, others...) +} + +// reflectSliceWithProperType does the opposite thing as setSliceWithProperType. +func reflectSliceWithProperType(key *Key, field reflect.Value, delim string, allowShadow bool) error { + slice := field.Slice(0, field.Len()) + if field.Len() == 0 { + return nil + } + sliceOf := field.Type().Elem().Kind() + + if allowShadow { + var keyWithShadows *Key + for i := 0; i < field.Len(); i++ { + var val string + switch sliceOf { + case reflect.String: + val = slice.Index(i).String() + case reflect.Int, reflect.Int64: + val = fmt.Sprint(slice.Index(i).Int()) + case reflect.Uint, reflect.Uint64: + val = fmt.Sprint(slice.Index(i).Uint()) + case reflect.Float64: + val = fmt.Sprint(slice.Index(i).Float()) + case reflect.Bool: + val = fmt.Sprint(slice.Index(i).Bool()) + case reflectTime: + val = slice.Index(i).Interface().(time.Time).Format(time.RFC3339) + default: + return fmt.Errorf("unsupported type '[]%s'", sliceOf) + } + + if i == 0 { + keyWithShadows = newKey(key.s, key.name, val) + } else { + _ = keyWithShadows.AddShadow(val) + } + } + *key = *keyWithShadows + return nil + } + + var buf bytes.Buffer + for i := 0; i < field.Len(); i++ { + switch sliceOf { + case reflect.String: + buf.WriteString(slice.Index(i).String()) + case reflect.Int, reflect.Int64: + buf.WriteString(fmt.Sprint(slice.Index(i).Int())) + case reflect.Uint, reflect.Uint64: + buf.WriteString(fmt.Sprint(slice.Index(i).Uint())) + case reflect.Float64: + buf.WriteString(fmt.Sprint(slice.Index(i).Float())) + case reflect.Bool: + buf.WriteString(fmt.Sprint(slice.Index(i).Bool())) + case reflectTime: + buf.WriteString(slice.Index(i).Interface().(time.Time).Format(time.RFC3339)) + default: + return fmt.Errorf("unsupported type '[]%s'", sliceOf) + } + buf.WriteString(delim) + } + key.SetValue(buf.String()[:buf.Len()-len(delim)]) + return nil +} + +// reflectWithProperType does the opposite thing as setWithProperType. +func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string, allowShadow bool) error { + switch t.Kind() { + case reflect.String: + key.SetValue(field.String()) + case reflect.Bool: + key.SetValue(fmt.Sprint(field.Bool())) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + key.SetValue(fmt.Sprint(field.Int())) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + key.SetValue(fmt.Sprint(field.Uint())) + case reflect.Float32, reflect.Float64: + key.SetValue(fmt.Sprint(field.Float())) + case reflectTime: + key.SetValue(fmt.Sprint(field.Interface().(time.Time).Format(time.RFC3339))) + case reflect.Slice: + return reflectSliceWithProperType(key, field, delim, allowShadow) + case reflect.Ptr: + if !field.IsNil() { + return reflectWithProperType(t.Elem(), key, field.Elem(), delim, allowShadow) + } + default: + return fmt.Errorf("unsupported type %q", t) + } + return nil +} + +// CR: copied from encoding/json/encode.go with modifications of time.Time support. +// TODO: add more test coverage. +func isEmptyValue(v reflect.Value) bool { + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + case reflectTime: + t, ok := v.Interface().(time.Time) + return ok && t.IsZero() + } + return false +} + +// StructReflector is the interface implemented by struct types that can extract themselves into INI objects. +type StructReflector interface { + ReflectINIStruct(*File) error +} + +func (s *Section) reflectFrom(val reflect.Value) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + if !val.Field(i).CanInterface() { + continue + } + + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + rawName, omitEmpty, allowShadow, allowNonUnique, extends := parseTagOptions(tag) + if omitEmpty && isEmptyValue(field) { + continue + } + + if r, ok := field.Interface().(StructReflector); ok { + return r.ReflectINIStruct(s.f) + } + + fieldName := s.parseFieldName(tpField.Name, rawName) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + if extends && tpField.Anonymous && (tpField.Type.Kind() == reflect.Ptr || tpField.Type.Kind() == reflect.Struct) { + if err := s.reflectFrom(field); err != nil { + return fmt.Errorf("reflect from field %q: %v", fieldName, err) + } + continue + } + + if (tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct) || + (tpField.Type.Kind() == reflect.Struct && tpField.Type.Name() != "Time") { + // Note: The only error here is section doesn't exist. + sec, err := s.f.GetSection(fieldName) + if err != nil { + // Note: fieldName can never be empty here, ignore error. + sec, _ = s.f.NewSection(fieldName) + } + + // Add comment from comment tag + if len(sec.Comment) == 0 { + sec.Comment = tpField.Tag.Get("comment") + } + + if err = sec.reflectFrom(field); err != nil { + return fmt.Errorf("reflect from field %q: %v", fieldName, err) + } + continue + } + + if allowNonUnique && tpField.Type.Kind() == reflect.Slice { + slice := field.Slice(0, field.Len()) + if field.Len() == 0 { + return nil + } + sliceOf := field.Type().Elem().Kind() + + for i := 0; i < field.Len(); i++ { + if sliceOf != reflect.Struct && sliceOf != reflect.Ptr { + return fmt.Errorf("field %q is not a slice of pointer or struct", fieldName) + } + + sec, err := s.f.NewSection(fieldName) + if err != nil { + return err + } + + // Add comment from comment tag + if len(sec.Comment) == 0 { + sec.Comment = tpField.Tag.Get("comment") + } + + if err := sec.reflectFrom(slice.Index(i)); err != nil { + return fmt.Errorf("reflect from field %q: %v", fieldName, err) + } + } + continue + } + + // Note: Same reason as section. + key, err := s.GetKey(fieldName) + if err != nil { + key, _ = s.NewKey(fieldName, "") + } + + // Add comment from comment tag + if len(key.Comment) == 0 { + key.Comment = tpField.Tag.Get("comment") + } + + delim := parseDelim(tpField.Tag.Get("delim")) + if err = reflectWithProperType(tpField.Type, key, field, delim, allowShadow); err != nil { + return fmt.Errorf("reflect field %q: %v", fieldName, err) + } + + } + return nil +} + +// ReflectFrom reflects section from given struct. It overwrites existing ones. +func (s *Section) ReflectFrom(v interface{}) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + + if s.name != DefaultSection && s.f.options.AllowNonUniqueSections && + (typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr) { + // Clear sections to make sure none exists before adding the new ones + s.f.DeleteSection(s.name) + + if typ.Kind() == reflect.Ptr { + sec, err := s.f.NewSection(s.name) + if err != nil { + return err + } + return sec.reflectFrom(val.Elem()) + } + + slice := val.Slice(0, val.Len()) + sliceOf := val.Type().Elem().Kind() + if sliceOf != reflect.Ptr { + return fmt.Errorf("not a slice of pointers") + } + + for i := 0; i < slice.Len(); i++ { + sec, err := s.f.NewSection(s.name) + if err != nil { + return err + } + + err = sec.reflectFrom(slice.Index(i)) + if err != nil { + return fmt.Errorf("reflect from %dth field: %v", i, err) + } + } + + return nil + } + + if typ.Kind() == reflect.Ptr { + val = val.Elem() + } else { + return errors.New("not a pointer to a struct") + } + + return s.reflectFrom(val) +} + +// ReflectFrom reflects file from given struct. +func (f *File) ReflectFrom(v interface{}) error { + return f.Section("").ReflectFrom(v) +} + +// ReflectFromWithMapper reflects data sources from given struct with name mapper. +func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error { + cfg.NameMapper = mapper + return cfg.ReflectFrom(v) +} + +// ReflectFrom reflects data sources from given struct. +func ReflectFrom(cfg *File, v interface{}) error { + return ReflectFromWithMapper(cfg, v, nil) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index dbd5ed679c..116cd1bd05 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -65,6 +65,19 @@ github.com/PuerkitoBio/purell # github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 ## explicit github.com/PuerkitoBio/urlesc +# github.com/aliyun/alibaba-cloud-sdk-go v1.61.1323 +## explicit; go 1.13 +github.com/aliyun/alibaba-cloud-sdk-go/sdk +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider +github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers +github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints +github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors +github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests +github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses +github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils +github.com/aliyun/alibaba-cloud-sdk-go/services/ram # github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d ## explicit; go 1.13 github.com/asaskevich/govalidator @@ -654,6 +667,9 @@ gopkg.in/go-playground/validator.v9 # gopkg.in/inf.v0 v0.9.1 ## explicit gopkg.in/inf.v0 +# gopkg.in/ini.v1 v1.62.0 +## explicit +gopkg.in/ini.v1 # gopkg.in/square/go-jose.v2 v2.5.1 ## explicit gopkg.in/square/go-jose.v2 From 2e757c851352732a3da6006767fd2794231eae55 Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Sun, 28 Nov 2021 20:52:22 +0800 Subject: [PATCH 3/8] add create/delete ram users subcommands --- pkg/alibabacloud/client.go | 81 ++++- pkg/alibabacloud/mock/client_generated.go | 151 +++++++- pkg/apis/cloudcredential/v1/types_alibaba.go | 4 - pkg/cmd/provisioning/alibabacloud/README.md | 83 ----- pkg/cmd/provisioning/alibabacloud/alibaba.go | 16 +- .../alibabacloud/attach-ram-policy.go | 265 -------------- .../alibabacloud/create-ram-users.go | 339 ++++++++++++++++++ ...olicy_test.go => create-ram-users_test.go} | 83 ++++- .../alibabacloud/delete-ram-users.go | 112 ++++++ .../alibabacloud/delete-ram-users_test.go | 117 ++++++ pkg/cmd/provisioning/alibabacloud/utils.go | 148 ++++++++ 11 files changed, 1001 insertions(+), 398 deletions(-) delete mode 100644 pkg/cmd/provisioning/alibabacloud/README.md delete mode 100644 pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go create mode 100644 pkg/cmd/provisioning/alibabacloud/create-ram-users.go rename pkg/cmd/provisioning/alibabacloud/{attach-ram-policy_test.go => create-ram-users_test.go} (72%) create mode 100644 pkg/cmd/provisioning/alibabacloud/delete-ram-users.go create mode 100644 pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go create mode 100644 pkg/cmd/provisioning/alibabacloud/utils.go diff --git a/pkg/alibabacloud/client.go b/pkg/alibabacloud/client.go index 01a2a78d16..a25f284532 100644 --- a/pkg/alibabacloud/client.go +++ b/pkg/alibabacloud/client.go @@ -17,7 +17,10 @@ limitations under the License. package alibabacloud import ( + "github.com/aliyun/alibaba-cloud-sdk-go/sdk" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider" "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + "log" ) //go:generate mockgen -source=./client.go -destination=./mock/client_generated.go -package=mock @@ -26,32 +29,92 @@ import ( type Client interface { //RAM CreatePolicy(*ram.CreatePolicyRequest) (*ram.CreatePolicyResponse, error) + GetPolicy(*ram.GetPolicyRequest) (*ram.GetPolicyResponse, error) + CreatePolicyVersion(*ram.CreatePolicyVersionRequest) (*ram.CreatePolicyVersionResponse, error) AttachPolicyToUser(*ram.AttachPolicyToUserRequest) (*ram.AttachPolicyToUserResponse, error) - DeletePolicy(*ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) - DetachPolicyFromUser(*ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) + CreateUser(*ram.CreateUserRequest) (*ram.CreateUserResponse, error) + GetUser(*ram.GetUserRequest) (*ram.GetUserResponse, error) + DeleteUser(*ram.DeleteUserRequest) (*ram.DeleteUserResponse, error) + CreateAccessKey(*ram.CreateAccessKeyRequest) (*ram.CreateAccessKeyResponse, error) + ListAccessKeys(*ram.ListAccessKeysRequest) (*ram.ListAccessKeysResponse, error) + DeleteAccessKey(*ram.DeleteAccessKeyRequest) (*ram.DeleteAccessKeyResponse, error) + DeletePolicy(request *ram.DeletePolicyRequest) (response *ram.DeletePolicyResponse, err error) + DetachPolicyFromUser(request *ram.DetachPolicyFromUserRequest) (response *ram.DetachPolicyFromUserResponse, err error) + ListPoliciesForUser(request *ram.ListPoliciesForUserRequest) (response *ram.ListPoliciesForUserResponse, err error) } type alibabaCloudClient struct { - ramClient ram.Client + ramClient *ram.Client } func (c *alibabaCloudClient) CreatePolicy(request *ram.CreatePolicyRequest) (response *ram.CreatePolicyResponse, err error) { return c.ramClient.CreatePolicy(request) } +func (c *alibabaCloudClient) GetPolicy(request *ram.GetPolicyRequest) (response *ram.GetPolicyResponse, err error) { + return c.ramClient.GetPolicy(request) +} + +func (c *alibabaCloudClient) CreatePolicyVersion(request *ram.CreatePolicyVersionRequest) (response *ram.CreatePolicyVersionResponse, err error) { + return c.ramClient.CreatePolicyVersion(request) +} + func (c *alibabaCloudClient) AttachPolicyToUser(input *ram.AttachPolicyToUserRequest) (*ram.AttachPolicyToUserResponse, error) { return c.ramClient.AttachPolicyToUser(input) } -func (c *alibabaCloudClient) DeletePolicy(input *ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) { - return c.ramClient.DeletePolicy(input) +func (c *alibabaCloudClient) DeletePolicy(request *ram.DeletePolicyRequest) (response *ram.DeletePolicyResponse, err error) { + return c.ramClient.DeletePolicy(request) +} + +func (c *alibabaCloudClient) DetachPolicyFromUser(request *ram.DetachPolicyFromUserRequest) (response *ram.DetachPolicyFromUserResponse, err error) { + return c.ramClient.DetachPolicyFromUser(request) +} + +func (c *alibabaCloudClient) ListPoliciesForUser(request *ram.ListPoliciesForUserRequest) (response *ram.ListPoliciesForUserResponse, err error) { + return c.ramClient.ListPoliciesForUser(request) +} + +func (c *alibabaCloudClient) CreateUser(input *ram.CreateUserRequest) (*ram.CreateUserResponse, error) { + return c.ramClient.CreateUser(input) } -func (c *alibabaCloudClient) DetachPolicyFromUser(input *ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) { - return c.ramClient.DetachPolicyFromUser(input) +func (c *alibabaCloudClient) GetUser(input *ram.GetUserRequest) (*ram.GetUserResponse, error) { + return c.ramClient.GetUser(input) +} + +func (c *alibabaCloudClient) DeleteUser(input *ram.DeleteUserRequest) (*ram.DeleteUserResponse, error) { + return c.ramClient.DeleteUser(input) +} + +func (c *alibabaCloudClient) ListAccessKeys(input *ram.ListAccessKeysRequest) (*ram.ListAccessKeysResponse, error) { + return c.ramClient.ListAccessKeys(input) +} + +func (c *alibabaCloudClient) CreateAccessKey(input *ram.CreateAccessKeyRequest) (*ram.CreateAccessKeyResponse, error) { + return c.ramClient.CreateAccessKey(input) +} + +func (c *alibabaCloudClient) DeleteAccessKey(input *ram.DeleteAccessKeyRequest) (*ram.DeleteAccessKeyResponse, error) { + return c.ramClient.DeleteAccessKey(input) } // NewClient creates our client wrapper object for the actual Alibaba Cloud clients we use. -func NewClient(accessKeyID, accessKeySecret, region string) (Client, error) { - return ram.NewClientWithAccessKey(region, accessKeyID, accessKeySecret) +func NewClient(regionId string) (Client, error) { + envProvider := provider.NewEnvProvider() + profileProvider := provider.NewProfileProvider() + pc := provider.NewProviderChain([]provider.Provider{envProvider, profileProvider}) + credential, err := pc.Resolve() + if err != nil { + log.Fatalf("Failed to resolve an authentication provider: %v", err) + } + config := sdk.NewConfig().WithScheme("https") + + rc, err := ram.NewClientWithOptions(regionId, config, credential) + if err != nil { + return nil, err + } + return &alibabaCloudClient{ + ramClient: rc, + }, nil } diff --git a/pkg/alibabacloud/mock/client_generated.go b/pkg/alibabacloud/mock/client_generated.go index 5264866ac6..4395476aff 100644 --- a/pkg/alibabacloud/mock/client_generated.go +++ b/pkg/alibabacloud/mock/client_generated.go @@ -49,6 +49,21 @@ func (mr *MockClientMockRecorder) AttachPolicyToUser(arg0 interface{}) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttachPolicyToUser", reflect.TypeOf((*MockClient)(nil).AttachPolicyToUser), arg0) } +// CreateAccessKey mocks base method. +func (m *MockClient) CreateAccessKey(arg0 *ram.CreateAccessKeyRequest) (*ram.CreateAccessKeyResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateAccessKey", arg0) + ret0, _ := ret[0].(*ram.CreateAccessKeyResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateAccessKey indicates an expected call of CreateAccessKey. +func (mr *MockClientMockRecorder) CreateAccessKey(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccessKey", reflect.TypeOf((*MockClient)(nil).CreateAccessKey), arg0) +} + // CreatePolicy mocks base method. func (m *MockClient) CreatePolicy(arg0 *ram.CreatePolicyRequest) (*ram.CreatePolicyResponse, error) { m.ctrl.T.Helper() @@ -64,32 +79,152 @@ func (mr *MockClientMockRecorder) CreatePolicy(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePolicy", reflect.TypeOf((*MockClient)(nil).CreatePolicy), arg0) } +// CreatePolicyVersion mocks base method. +func (m *MockClient) CreatePolicyVersion(arg0 *ram.CreatePolicyVersionRequest) (*ram.CreatePolicyVersionResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreatePolicyVersion", arg0) + ret0, _ := ret[0].(*ram.CreatePolicyVersionResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreatePolicyVersion indicates an expected call of CreatePolicyVersion. +func (mr *MockClientMockRecorder) CreatePolicyVersion(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePolicyVersion", reflect.TypeOf((*MockClient)(nil).CreatePolicyVersion), arg0) +} + +// CreateUser mocks base method. +func (m *MockClient) CreateUser(arg0 *ram.CreateUserRequest) (*ram.CreateUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", arg0) + ret0, _ := ret[0].(*ram.CreateUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockClientMockRecorder) CreateUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockClient)(nil).CreateUser), arg0) +} + +// DeleteAccessKey mocks base method. +func (m *MockClient) DeleteAccessKey(arg0 *ram.DeleteAccessKeyRequest) (*ram.DeleteAccessKeyResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteAccessKey", arg0) + ret0, _ := ret[0].(*ram.DeleteAccessKeyResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteAccessKey indicates an expected call of DeleteAccessKey. +func (mr *MockClientMockRecorder) DeleteAccessKey(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccessKey", reflect.TypeOf((*MockClient)(nil).DeleteAccessKey), arg0) +} + // DeletePolicy mocks base method. -func (m *MockClient) DeletePolicy(arg0 *ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) { +func (m *MockClient) DeletePolicy(request *ram.DeletePolicyRequest) (*ram.DeletePolicyResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeletePolicy", arg0) + ret := m.ctrl.Call(m, "DeletePolicy", request) ret0, _ := ret[0].(*ram.DeletePolicyResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // DeletePolicy indicates an expected call of DeletePolicy. -func (mr *MockClientMockRecorder) DeletePolicy(arg0 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) DeletePolicy(request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockClient)(nil).DeletePolicy), request) +} + +// DeleteUser mocks base method. +func (m *MockClient) DeleteUser(arg0 *ram.DeleteUserRequest) (*ram.DeleteUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteUser", arg0) + ret0, _ := ret[0].(*ram.DeleteUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteUser indicates an expected call of DeleteUser. +func (mr *MockClientMockRecorder) DeleteUser(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockClient)(nil).DeletePolicy), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUser", reflect.TypeOf((*MockClient)(nil).DeleteUser), arg0) } // DetachPolicyFromUser mocks base method. -func (m *MockClient) DetachPolicyFromUser(arg0 *ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) { +func (m *MockClient) DetachPolicyFromUser(request *ram.DetachPolicyFromUserRequest) (*ram.DetachPolicyFromUserResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DetachPolicyFromUser", arg0) + ret := m.ctrl.Call(m, "DetachPolicyFromUser", request) ret0, _ := ret[0].(*ram.DetachPolicyFromUserResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // DetachPolicyFromUser indicates an expected call of DetachPolicyFromUser. -func (mr *MockClientMockRecorder) DetachPolicyFromUser(arg0 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) DetachPolicyFromUser(request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachPolicyFromUser", reflect.TypeOf((*MockClient)(nil).DetachPolicyFromUser), request) +} + +// GetPolicy mocks base method. +func (m *MockClient) GetPolicy(arg0 *ram.GetPolicyRequest) (*ram.GetPolicyResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPolicy", arg0) + ret0, _ := ret[0].(*ram.GetPolicyResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPolicy indicates an expected call of GetPolicy. +func (mr *MockClientMockRecorder) GetPolicy(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicy", reflect.TypeOf((*MockClient)(nil).GetPolicy), arg0) +} + +// GetUser mocks base method. +func (m *MockClient) GetUser(arg0 *ram.GetUserRequest) (*ram.GetUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUser", arg0) + ret0, _ := ret[0].(*ram.GetUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockClientMockRecorder) GetUser(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockClient)(nil).GetUser), arg0) +} + +// ListAccessKeys mocks base method. +func (m *MockClient) ListAccessKeys(arg0 *ram.ListAccessKeysRequest) (*ram.ListAccessKeysResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListAccessKeys", arg0) + ret0, _ := ret[0].(*ram.ListAccessKeysResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListAccessKeys indicates an expected call of ListAccessKeys. +func (mr *MockClientMockRecorder) ListAccessKeys(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAccessKeys", reflect.TypeOf((*MockClient)(nil).ListAccessKeys), arg0) +} + +// ListPoliciesForUser mocks base method. +func (m *MockClient) ListPoliciesForUser(request *ram.ListPoliciesForUserRequest) (*ram.ListPoliciesForUserResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListPoliciesForUser", request) + ret0, _ := ret[0].(*ram.ListPoliciesForUserResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListPoliciesForUser indicates an expected call of ListPoliciesForUser. +func (mr *MockClientMockRecorder) ListPoliciesForUser(request interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachPolicyFromUser", reflect.TypeOf((*MockClient)(nil).DetachPolicyFromUser), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPoliciesForUser", reflect.TypeOf((*MockClient)(nil).ListPoliciesForUser), request) } diff --git a/pkg/apis/cloudcredential/v1/types_alibaba.go b/pkg/apis/cloudcredential/v1/types_alibaba.go index 4ee13eba04..5c7f183b48 100644 --- a/pkg/apis/cloudcredential/v1/types_alibaba.go +++ b/pkg/apis/cloudcredential/v1/types_alibaba.go @@ -44,8 +44,4 @@ type AlibabaStatementEntry struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type AlibabaCloudProviderStatus struct { metav1.TypeMeta `json:",inline"` - // User is the name of the User created in AlibabaCloud for these credentials. - User string `json:"user"` - // Policy is the name of the policy attached to the user in AlibabaCloud. - Policy string `json:"policy"` } diff --git a/pkg/cmd/provisioning/alibabacloud/README.md b/pkg/cmd/provisioning/alibabacloud/README.md deleted file mode 100644 index 4199d78409..0000000000 --- a/pkg/cmd/provisioning/alibabacloud/README.md +++ /dev/null @@ -1,83 +0,0 @@ -# Alibaba Cloud Manual Mode - -This is the guide for using manual mode on alibaba cloud, for more use info about manual mode, please reference to [cco-mode-manual](https://docs.openshift.com/container-platform/4.9/authentication/managing_cloud_provider_credentials/cco-mode-manual.html). - -In alibaba cloud manual mode, the CCO utility (`ccoctl`) binary would generate long-lived RAM AK credentials for individual OpenShift Container Platform cluster components. The ram user who owns the AK would be attached the ram policy with the permission defined in each components, and a root ram user who required `ram:CreatePolicy` and `ram:AttachPolicyToUser` pemission as least is needed for attaching the permission for each component. - -## Prerequisite - -1. Extract and prepare the ccoctl binary from the release image. - -2. [create a ram user](https://partners-intl.aliyun.com/help/doc-detail/93720.htm)(has no permission in default) for binding the cluster components permission, and get the ram accesskey id/accesskey secret/user name as the input parameters of the alibaba cloud ccoctl command. - -3. choose an existing ram user who required `ram:CreatePolicy` and `ram:AttachPolicyToUser` pemission as least, and get this ram user's accesskey id/accesskey secret for attaching the specific component permission to the ram user created in step 2. - - - -## Procedure - -1. Extract the list of CredentialsRequest custom resources (CRs) from the OpenShift Container Platform release image: - - ```bash - $ oc adm release extract --credentials-requests --cloud=alibabacloud --to=/credrequests quay.io//ocp-release: - - ``` - -2. For each CredentialsRequest CR in the release image, ensure that a namespace that matches the text in the spec.secretRef.namespace field exists in the cluster. This field is where the generated secrets that hold the credentials configuration are stored. - - Sample Alibaba Cloud CredentialsRequest object - - ```yaml - apiVersion: cloudcredential.openshift.io/v1 - kind: CredentialsRequest - metadata: - name: cloud-credential-operator-ram-ro - namespace: openshift-cloud-credential-operator - spec: - providerSpec: - apiVersion: cloudcredential.openshift.io/v1 - kind: AlibabaCloudProviderSpec - statementEntries: - - action: - - ecs:CopySnapshot - - ecs:DeleteDisk - - ecs:DescribeInstanceAttribute - - ecs:DescribeInstances - effect: Allow - resource: '*' - secretRef: - namespace: cloud-credential-operator-ram-ro-creds - name: openshift-cloud-credential-operator - ``` - -3. For any `CredentialsRequest` CR for which the cluster does not already have a namespace with the name specified in `spec.secretRef.namespace`, create the namespace: - - ``` - $ oc create namespace - ``` - -4. Use the `ccoctl` tool to process all `CredentialsRequest` objects in the `credrequests` directory: - - ```bash - $ ccoctl alibabacloud attach-ram-policy --name --region= --credentials-requests-dir=/credrequests --root-access-key=xxxxx --root-access-key-secret=xxxxx --user-name=testuser --component-access-key=xxxxxx --component-access-secret=xxxxxx --output-dir=xxxxxx - ``` - - where: - - - `name` is the name used to tag any cloud resources that are created for tracking. - - `region` is the Alibaba Cloud region in which cloud resources will be created. - - `credentials-requests-dir` is the directory containing files of component CredentialsRequests. - - `root-access-key` is the ram user ak with ram permission such as CreatePolicy/AttachPolicyToUser as least. - - `root-access-key-secret` is the ram user sk with ram permission such as CreatePolicy/AttachPolicyToUser as least. - - `user-name` is the ram user name who created for binding components required ram permission. - - `component-access-key` is the ram user ak who created for binding components required ram permission. - - `component-access-secret` is the ram user sk who created for binding components required ram permission. - - `output-dir`/manifests is the directory containing files of component credentials secret. - -5. Apply the secrets to your cluster: - - ```bash - $ ls /manifests/*-credentials.yaml | xargs -I{} oc apply -f {} - ``` - - \ No newline at end of file diff --git a/pkg/cmd/provisioning/alibabacloud/alibaba.go b/pkg/cmd/provisioning/alibabacloud/alibaba.go index b10e9f8ed8..8e2431b3a2 100644 --- a/pkg/cmd/provisioning/alibabacloud/alibaba.go +++ b/pkg/cmd/provisioning/alibabacloud/alibaba.go @@ -5,15 +5,10 @@ import ( ) type options struct { - TargetDir string - Name string - Region string - RootAccessKeyId string - RootAccessKeySecret string - ComponentAccessKeyId string - ComponentAccessKeySecret string - CredRequestDir string - UserName string + TargetDir string + Name string + Region string + CredRequestDir string } // NewAliababaCloudCmd implements the "alibabacloud" subcommand for the credentials provisioning @@ -24,7 +19,8 @@ func NewAliababaCloudCmd() *cobra.Command { Long: "Creating/deleting cloud credentials objects for alibaba cloud", } - createCmd.AddCommand(NewAttachRAMPolicyCmd()) + createCmd.AddCommand(NewCreateRAMUsersCmd()) + createCmd.AddCommand(NewDeleteRAMUsersCmd()) return createCmd } diff --git a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go b/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go deleted file mode 100644 index f20d37de63..0000000000 --- a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy.go +++ /dev/null @@ -1,265 +0,0 @@ -package alibabacloud - -import ( - "encoding/json" - "fmt" - "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" - "io/ioutil" - "log" - "os" - "path/filepath" - - "github.com/openshift/cloud-credential-operator/pkg/alibabacloud" - credreqv1 "github.com/openshift/cloud-credential-operator/pkg/apis/cloudcredential/v1" - "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -const ( - secretManifestsTemplate = `apiVersion: v1 -data: - access_key_id: %s - access_key_secret: %s -kind: Secret -metadata: - name: %s - namespace: %s -type: Opaque` - - // Https for ram client scheme - Https = "https" - // Custom is ram policy type - Custom = "Custom" -) - -var ( - // AttachRAMPolicyOpts captures the options that affect creation/updating - // of the RAM Roles. - AttachRAMPolicyOpts = options{ - TargetDir: "", - } -) - -type ComponenntSecretInfo struct { - componentAccessKeyId string - componentAccessKeySecret string - targetDir string - userName string -} - -func attachRAMPolicy(client alibabacloud.Client, name, credReqDir string, componenntSecretInfo ComponenntSecretInfo) error { - // Process directory - credRequests, err := provisioning.GetListOfCredentialsRequests(credReqDir) - if err != nil { - return errors.Wrap(err, "Failed to process files containing CredentialsRequests") - } - - // Create RAM Roles (with policies) - if err := processCredentialsRequests(client, credRequests, name, componenntSecretInfo); err != nil { - return errors.Wrap(err, "Failed while processing each CredentialsRequest") - } - - return nil -} - -func processCredentialsRequests(client alibabacloud.Client, credReqs []*credreqv1.CredentialsRequest, name string, componenntSecretInfo ComponenntSecretInfo) error { - for _, cr := range credReqs { - // infraName-targetNamespace-targetSecretName - err := createAndAttachPolicy(client, name, cr, componenntSecretInfo) - if err != nil { - return err - } - } - return nil -} - -func attachRAMPolicyCmd(cmd *cobra.Command, args []string) { - client, err := alibabacloud.NewClient(AttachRAMPolicyOpts.Region, AttachRAMPolicyOpts.RootAccessKeyId, AttachRAMPolicyOpts.RootAccessKeySecret) - if err != nil { - log.Fatal(err) - } - var componentSecretInfo = ComponenntSecretInfo{ - componentAccessKeyId: AttachRAMPolicyOpts.ComponentAccessKeyId, - componentAccessKeySecret: AttachRAMPolicyOpts.ComponentAccessKeySecret, - targetDir: AttachRAMPolicyOpts.TargetDir, - userName: AttachRAMPolicyOpts.UserName, - } - if componentSecretInfo.componentAccessKeyId == "" || componentSecretInfo.componentAccessKeySecret == "" || componentSecretInfo.userName == "" { - log.Fatal(errors.New("invalid empty value for component-access-key/component-access-secret or user-name")) - } - err = attachRAMPolicy(client, AttachRAMPolicyOpts.Name, AttachRAMPolicyOpts.CredRequestDir, componentSecretInfo) - if err != nil { - log.Fatal(err) - } -} - -func createAndAttachPolicy(client alibabacloud.Client, name string, credReq *credreqv1.CredentialsRequest, componenntSecretInfo ComponenntSecretInfo) error { - policyName := fmt.Sprintf("%s-%s-policy", name, credReq.Spec.SecretRef.Name) - - // Decode Alibaba CloudProviderSpec - codec, err := credreqv1.NewCodec() - if err != nil { - return errors.Wrap(err, "Failed to create credReq codec") - } - - alibabaProviderSpec := credreqv1.AlibabaCloudProviderSpec{} - if err := codec.DecodeProviderSpec(credReq.Spec.ProviderSpec, &alibabaProviderSpec); err != nil { - return errors.Wrap(err, "Failed to decode the provider spec") - } - - if alibabaProviderSpec.Kind != "AlibabaCloudProviderSpec" { - return fmt.Errorf("CredentialsRequest %s/%s is not of type Alibaba Cloud", credReq.Namespace, credReq.Name) - } - - err = createComponentPolicy(client, policyName, alibabaProviderSpec.StatementEntries) - if err != nil { - return err - } - log.Printf("ram policy %s has created", policyName) - - err = attachComponentPolicy(client, componenntSecretInfo.userName, policyName) - if err != nil { - return err - } - log.Printf("policy %s has attached on user %s", policyName, componenntSecretInfo.userName) - - if err := writeCredReqSecret(credReq, componenntSecretInfo); err != nil { - return errors.Wrap(err, "failed to save Secret for install manifests") - } - return nil -} - -// StatementEntry is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. -type StatementEntry struct { - Effect string - Action []string - Resource string - // Must "omitempty" otherwise we send unacceptable JSON to the Alibaba Cloud API when no - // condition is defined. - Condition credreqv1.RAMPolicyCondition `json:",omitempty"` -} - -// PolicyDocument is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. -type PolicyDocument struct { - Version string - Statement []StatementEntry -} - -func createComponentPolicy(client alibabacloud.Client, policyName string, statements []credreqv1.AlibabaStatementEntry) error { - policyDocument := PolicyDocument{ - Version: "1", - Statement: []StatementEntry{}, - } - - for _, entry := range statements { - policyDocument.Statement = append(policyDocument.Statement, - StatementEntry{ - Effect: entry.Effect, - Action: entry.Action, - Resource: entry.Resource, - Condition: entry.PolicyCondition, - }) - } - - policyBytes, err := json.Marshal(&policyDocument) - if err != nil { - log.Fatalf("Failed to marshal the policy to JSON: %s", err) - } - - req := ram.CreatePolicyRequest{} - req.Scheme = Https - req.PolicyName = policyName - req.PolicyDocument = string(policyBytes) - _, err = client.CreatePolicy(&req) - return err -} - -func attachComponentPolicy(client alibabacloud.Client, user, policyName string) error { - req := ram.AttachPolicyToUserRequest{} - req.Scheme = Https - req.PolicyName = policyName - req.UserName = user - req.PolicyType = Custom - _, err := client.AttachPolicyToUser(&req) - return err -} - -// writeCredReqSecret will take a credentialsRequest and return -// a Secret with the AK/SK of a ram user who has grant component permission defined in credentialsRequest. -func writeCredReqSecret(cr *credreqv1.CredentialsRequest, componenntSecretInfo ComponenntSecretInfo) error { - manifestsDir := filepath.Join(componenntSecretInfo.targetDir, provisioning.ManifestsDirName) - - fileName := fmt.Sprintf("%s-%s-credentials.yaml", cr.Spec.SecretRef.Namespace, cr.Spec.SecretRef.Name) - filePath := filepath.Join(manifestsDir, fileName) - - fileData := fmt.Sprintf(secretManifestsTemplate, componenntSecretInfo.componentAccessKeyId, componenntSecretInfo.componentAccessKeySecret, cr.Spec.SecretRef.Name, cr.Spec.SecretRef.Namespace) - - if err := ioutil.WriteFile(filePath, []byte(fileData), 0600); err != nil { - return errors.Wrap(err, "Failed to save Secret file") - } - - log.Printf("Saved credentials configuration to: %s", filePath) - - return nil -} - -// initEnvForAttachRAMPolicyCmd will ensure the destination directory is ready to receive the generated -// files, and will create the directory if necessary. -func initEnvForAttachRAMPolicyCmd(cmd *cobra.Command, args []string) { - if AttachRAMPolicyOpts.TargetDir == "" { - pwd, err := os.Getwd() - if err != nil { - log.Fatalf("Failed to get current directory: %s", err) - } - - AttachRAMPolicyOpts.TargetDir = pwd - } - - fPath, err := filepath.Abs(AttachRAMPolicyOpts.TargetDir) - if err != nil { - log.Fatalf("Failed to resolve full path: %s", err) - } - - // create target dir if necessary - err = provisioning.EnsureDir(fPath) - if err != nil { - log.Fatalf("failed to create target directory at %s", fPath) - } - - // create manifests dir if necessary - manifestsDir := filepath.Join(fPath, provisioning.ManifestsDirName) - err = provisioning.EnsureDir(manifestsDir) - if err != nil { - log.Fatalf("failed to create manifests directory at %s", manifestsDir) - } -} - -// NewCreateRAMPolicyCmd provides the "attach-ram-policy" subcommand -func NewAttachRAMPolicyCmd() *cobra.Command { - attachRAMPolicyCmd := &cobra.Command{ - Use: "attach-ram-policy", - Short: "Attach RAM Policy", - Run: attachRAMPolicyCmd, - PersistentPreRun: initEnvForAttachRAMPolicyCmd, - } - - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.Name, "name", "", "User-define name for all created Alibaba Cloud resources (can be separate from the cluster's infra-id)") - attachRAMPolicyCmd.MarkPersistentFlagRequired("name") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.CredRequestDir, "credentials-requests-dir", "", "Directory containing files of CredentialsRequests to create RAM AK for (can be created by running 'oc adm release extract --credentials-requests --cloud=alibabacloud' against an OpenShift release image)") - attachRAMPolicyCmd.MarkPersistentFlagRequired("credentials-requests-dir") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.RootAccessKeyId, "root-access-key", "", "The root user ak with ram permission such as CreatePolicy/AttachPolicyToUser") - attachRAMPolicyCmd.MarkPersistentFlagRequired("root-access-key") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.RootAccessKeySecret, "root-access-key-secret", "", "The root user sk with ram permission such as CreatePolicy/AttachPolicyToUser") - attachRAMPolicyCmd.MarkPersistentFlagRequired("root-access-key-secret") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.UserName, "user-name", "", "The specific ram user name, the user would attach all permission defined in CredentialsRequests") - attachRAMPolicyCmd.MarkPersistentFlagRequired("user-name") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.ComponentAccessKeyId, "component-access-key", "", "The created component user ak with ram permission defined in CredentialsRequests") - attachRAMPolicyCmd.MarkPersistentFlagRequired("component-access-key") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.ComponentAccessKeySecret, "component-access-secret", "", "The created component user sk with ram permission defined in CredentialsRequests") - attachRAMPolicyCmd.MarkPersistentFlagRequired("component-access-secret") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.Region, "region", "", "Alibaba Cloud region endpoint only required for GovCloud") - attachRAMPolicyCmd.PersistentFlags().StringVar(&AttachRAMPolicyOpts.TargetDir, "output-dir", "", "Directory to place generated files (defaults to current directory)") - - return attachRAMPolicyCmd -} diff --git a/pkg/cmd/provisioning/alibabacloud/create-ram-users.go b/pkg/cmd/provisioning/alibabacloud/create-ram-users.go new file mode 100644 index 0000000000..ca08f7076b --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/create-ram-users.go @@ -0,0 +1,339 @@ +package alibabacloud + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + + alibabaerrors "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + + "github.com/openshift/cloud-credential-operator/pkg/alibabacloud" + credreqv1 "github.com/openshift/cloud-credential-operator/pkg/apis/cloudcredential/v1" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" +) + +const ( + secretManifestsTemplate = `apiVersion: v1 +stringData: + credentials: |- + [default] + type = access_key + access_key_id = %s + access_key_secret = %s +kind: Secret +metadata: + name: %s + namespace: %s +type: Opaque` + + // ramPolicyType is the default policy type used for created Policies + ramPolicyType = "Custom" + // autoRotateStrategy will delete the earliest inactive policy version + autoRotateStrategy = "DeleteOldestNonDefaultVersionWhenLimitExceeded" +) + +var ( + // CreateRAMUsersOpts captures the options that affect creation/updating + // of the RAM Uers/Policies. + CreateRAMUsersOpts = options{ + Region: "", + TargetDir: "", + Name: "", + CredRequestDir: "", + } +) + +func createRAMUsersCmd(cmd *cobra.Command, args []string) { + client, err := alibabacloud.NewClient(CreateRAMUsersOpts.Region) + if err != nil { + log.Fatalf("Failed to create a client: %v", err) + } + + err = createRAMUsers(client, CreateRAMUsersOpts.Name, CreateRAMUsersOpts.CredRequestDir, CreateRAMUsersOpts.TargetDir) + if err != nil { + log.Fatalf("failed to create RAM users and policies: %s", err) + } +} + +//createRAMUsers will create a ram user for the given credenital request and attach the specific ram policy +func createRAMUsers(client alibabacloud.Client, name, credReqDir, targetDir string) error { + // Process directory + credRequests, err := provisioning.GetListOfCredentialsRequests(credReqDir) + if err != nil { + return errors.Wrap(err, "Failed to process files containing CredentialsRequests") + } + + // Create RAM Roles (with policies) + if err := processNewCredentialsRequests(client, credRequests, name, targetDir); err != nil { + return errors.Wrap(err, "Failed while processing each CredentialsRequest") + } + + return nil +} + +// StatementEntry is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. +type StatementEntry struct { + Effect string + Action []string + Resource string +} + +// PolicyDocument is a simple type used to serialize to Alibaba Cloud' PolicyDocument format. +type PolicyDocument struct { + Version string + Statement []StatementEntry +} + +func createComponentPolicy(client alibabacloud.Client, policyName string, statements []credreqv1.AlibabaStatementEntry) error { + policyDocument := PolicyDocument{ + Version: "1", + Statement: []StatementEntry{}, + } + + for _, entry := range statements { + policyDocument.Statement = append(policyDocument.Statement, + StatementEntry{ + Effect: entry.Effect, + Action: entry.Action, + Resource: entry.Resource, + }) + } + + policyBytes, err := json.Marshal(&policyDocument) + if err != nil { + log.Fatalf("Failed to marshal the policy to JSON: %s", err) + } + + req := ram.CreateGetPolicyRequest() + req.PolicyName = policyName + req.PolicyType = ramPolicyType + _, err = client.GetPolicy(req) + if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + if ok && aErr.ErrorCode() == errorPolicyNotExists { + //create new policy + log.Printf("Ready for creating new ram policy %s", policyName) + preq := ram.CreateCreatePolicyRequest() + preq.PolicyName = policyName + preq.PolicyDocument = string(policyBytes) + preq.Description = "Created by OpenShift ccoctl" + _, err = client.CreatePolicy(preq) + if err == nil { + return nil + } + } + log.Fatalf("Failed to create new ram policy %s, err is %v", policyName, err) + } + //create new policy with new version and set it to the default one + vreq := ram.CreateCreatePolicyVersionRequest() + vreq.PolicyName = policyName + vreq.PolicyDocument = string(policyBytes) + vreq.RotateStrategy = autoRotateStrategy + vreq.SetAsDefault = "true" + _, err = client.CreatePolicyVersion(vreq) + return err +} + +//attachComponentPolicy will attach the given policy to the preset component user +func attachComponentPolicy(client alibabacloud.Client, user, policyName string) error { + req := ram.CreateAttachPolicyToUserRequest() + req.PolicyName = policyName + req.UserName = user + req.PolicyType = ramPolicyType + _, err := client.AttachPolicyToUser(req) + return err +} + +func processNewCredentialsRequests(client alibabacloud.Client, credReqs []*credreqv1.CredentialsRequest, name, targetDir string) error { + for _, cr := range credReqs { + err := createUserAndAttachPolicy(client, name, targetDir, cr) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("Failed to create user and attach policy for CredentialsRequest %s", cr.Name)) + } + } + return nil +} + +func createUser(client alibabacloud.Client, name string, credReq *credreqv1.CredentialsRequest) (string, error) { + userName := fmt.Sprintf("%s-%s-%s", name, credReq.Namespace, credReq.Name) + shortName, displayName := generateRAMUserName(userName) + + userReq := ram.CreateCreateUserRequest() + userReq.UserName = shortName + userReq.DisplayName = displayName + + user, err := client.CreateUser(userReq) + if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + if ok && aErr.ErrorCode() == errorUserAlreadyExists { + log.Printf("RAM User %s already exists, continuing", shortName) + return shortName, nil + } else { + return "", errors.Wrap(err, "failed to create RAM user") + } + } + + log.Printf("Created RAM User: %s", user.User.UserName) + return user.User.UserName, nil +} + +func generateUserAccessKeys(client alibabacloud.Client, userName string) (*ram.CreateAccessKeyResponse, error) { + accessKeyReq := ram.CreateCreateAccessKeyRequest() + accessKeyReq.UserName = userName + accessKeyResp, err := client.CreateAccessKey(accessKeyReq) + if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + if ok && aErr.ErrorCode() == errorAKLimitExceeded { + log.Printf("RAM User %s's accesskey number limit exceeded, will delete original accesskeys", userName) + listKeyReq := ram.CreateListAccessKeysRequest() + listKeyReq.UserName = userName + listKeyRes, err := client.ListAccessKeys(listKeyReq) + //get the older one or the keys with in-active status to delete + deleteKeys, err := getDeleteAccessKeys(listKeyRes.AccessKeys.AccessKey) + if err != nil { + return nil, errors.Wrap(err, "failed to get the older ram accesskey") + } + for _, oneAK := range deleteKeys { + log.Printf("Ready to delete user %s accesskey %s", userName, oneAK.AccessKeyId) + deleteKeyReq := ram.CreateDeleteAccessKeyRequest() + deleteKeyReq.UserName = userName + deleteKeyReq.UserAccessKeyId = oneAK.AccessKeyId + _, err := client.DeleteAccessKey(deleteKeyReq) + if err != nil { + return nil, err + } + } + + accessKeyResp, err = client.CreateAccessKey(accessKeyReq) + if err != nil { + return nil, err + } + log.Printf("Created access keys for RAM User: %s", userName) + return accessKeyResp, nil + } + return nil, errors.Wrap(err, "failed to create RAM user access keys") + } + log.Printf("Created access keys for RAM User: %s", userName) + return accessKeyResp, nil +} + +func createUserAndAttachPolicy(client alibabacloud.Client, name, targetDir string, credReq *credreqv1.CredentialsRequest) error { + policyName := generatePolicyName(fmt.Sprintf("%s-%s-%s-policy", name, credReq.Spec.SecretRef.Namespace, credReq.Spec.SecretRef.Name)) + + // Decode Alibaba CloudProviderSpec + codec, err := credreqv1.NewCodec() + if err != nil { + return errors.Wrap(err, "Failed to create credReq codec") + } + + alibabaProviderSpec := credreqv1.AlibabaCloudProviderSpec{} + if err := codec.DecodeProviderSpec(credReq.Spec.ProviderSpec, &alibabaProviderSpec); err != nil { + return errors.Wrap(err, "Failed to decode the provider spec") + } + + if alibabaProviderSpec.Kind != "AlibabaCloudProviderSpec" { + return fmt.Errorf("CredentialsRequest %s/%s is not of type Alibaba Cloud", credReq.Namespace, credReq.Name) + } + + ramUserName, err := createUser(client, name, credReq) + if err != nil { + return errors.Wrap(err, "Failed while creating RAM User") + } + + err = createComponentPolicy(client, policyName, alibabaProviderSpec.StatementEntries) + if err != nil { + return refineMissingRegionIdErr(err) + } + log.Printf("RAM policy %s has created", policyName) + + err = attachComponentPolicy(client, ramUserName, policyName) + if err != nil { + return refineMissingRegionIdErr(err) + } + log.Printf("Policy %s has attached on user %s", policyName, ramUserName) + + accessKeys, err := generateUserAccessKeys(client, ramUserName) + if err != nil { + return errors.Wrap(err, "Failed to generate RAM User access keys") + } + if err := writeCredReqSecret(credReq, targetDir, accessKeys.AccessKey.AccessKeyId, accessKeys.AccessKey.AccessKeySecret); err != nil { + return errors.Wrap(err, "Failed to save Secret for install manifests") + } + + return nil +} + +// writeCredReqSecret will take a CredentialsRequest and return +// a Secret with the AK/SK of a ram user who has grant component permission defined in CredentialsRequest. +func writeCredReqSecret(cr *credreqv1.CredentialsRequest, targetDir, accessKeyId, accessKeySecret string) error { + manifestsDir := filepath.Join(targetDir, provisioning.ManifestsDirName) + + fileName := fmt.Sprintf("%s-%s-credentials.yaml", cr.Spec.SecretRef.Namespace, cr.Spec.SecretRef.Name) + filePath := filepath.Join(manifestsDir, fileName) + + fileData := fmt.Sprintf(secretManifestsTemplate, accessKeyId, accessKeySecret, cr.Spec.SecretRef.Name, cr.Spec.SecretRef.Namespace) + + if err := ioutil.WriteFile(filePath, []byte(fileData), 0600); err != nil { + return errors.Wrap(err, "Failed to save Secret file") + } + + log.Printf("Saved credentials configuration to: %s", filePath) + + return nil +} + +// initEnvForCreateRAMUsersCmd ensure destination directory is ready to receive the generated files, and will create the directory if necessary. +func initEnvForCreateRAMUsersCmd(cmd *cobra.Command, args []string) { + if CreateRAMUsersOpts.TargetDir == "" { + pwd, err := os.Getwd() + if err != nil { + log.Fatalf("Failed to get current directory: %s", err) + } + + CreateRAMUsersOpts.TargetDir = pwd + } + + fPath, err := filepath.Abs(CreateRAMUsersOpts.TargetDir) + if err != nil { + log.Fatalf("Failed to resolve full path: %s", err) + } + + // create target dir if necessary + err = provisioning.EnsureDir(fPath) + if err != nil { + log.Fatalf("Failed to create target directory at %s", fPath) + } + + // create manifests dir if necessary + manifestsDir := filepath.Join(fPath, provisioning.ManifestsDirName) + err = provisioning.EnsureDir(manifestsDir) + if err != nil { + log.Fatalf("Failed to create manifests directory at %s", manifestsDir) + } +} + +// NewCreateRAMUsersCmd provides the "create-ram-users" subcommand +func NewCreateRAMUsersCmd() *cobra.Command { + createRAMUsersCmd := &cobra.Command{ + Use: "create-ram-users", + Short: "Create RAM Users and policies", + Run: createRAMUsersCmd, + PersistentPreRun: initEnvForCreateRAMUsersCmd, + } + + createRAMUsersCmd.PersistentFlags().StringVar(&CreateRAMUsersOpts.Name, "name", "", "User-defined name for all created Alibaba Cloud resources (can be separate from the cluster's infra-id)") + createRAMUsersCmd.MarkPersistentFlagRequired("name") + createRAMUsersCmd.PersistentFlags().StringVar(&CreateRAMUsersOpts.CredRequestDir, "credentials-requests-dir", "", "Directory containing files of CredentialsRequests to create RAM AK for (can be created by running 'oc adm release extract --credentials-requests --cloud=alibabacloud' against an OpenShift release image)") + createRAMUsersCmd.MarkPersistentFlagRequired("credentials-requests-dir") + createRAMUsersCmd.PersistentFlags().StringVar(&CreateRAMUsersOpts.Region, "region", "", "Alibaba Cloud region endpoint only required for GovCloud") + createRAMUsersCmd.PersistentFlags().StringVar(&CreateRAMUsersOpts.TargetDir, "output-dir", "", "Directory to place generated files (defaults to current directory)") + + return createRAMUsersCmd +} diff --git a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go b/pkg/cmd/provisioning/alibabacloud/create-ram-users_test.go similarity index 72% rename from pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go rename to pkg/cmd/provisioning/alibabacloud/create-ram-users_test.go index d4f094dadd..b72965f3d6 100644 --- a/pkg/cmd/provisioning/alibabacloud/attach-ram-policy_test.go +++ b/pkg/cmd/provisioning/alibabacloud/create-ram-users_test.go @@ -18,22 +18,41 @@ import ( ) const ( - testNamePrefix = "test-cluster1" - testUserName = "test-user" - testDirPrefix = "ramtestdir" - testComponentAccessKeyId = "testAK" - testComponentAccessKeySecret = "testSK" + testNamePrefix = "test-cluster1" + testDirPrefix = "ramtestdir" ) var mockPolicyInCreatePolicy = ram.PolicyInCreatePolicy{ - PolicyName: "alibaba-mock-test", + PolicyName: "alibaba-mock-default-test", PolicyType: "Custom", Description: "alibaba-mock-test", DefaultVersion: "v1", CreateDate: "2021-01-23T12:33:18Z", } -func TestAttachRAMPolicy(t *testing.T) { +var mockPolicyInGetPolicy = ram.PolicyInGetPolicy{ + PolicyName: "alibaba-mock-default-test", + PolicyType: "Custom", + Description: "alibaba-mock-test", + DefaultVersion: "v1", + CreateDate: "2021-01-23T12:33:18Z", +} + +var mockPolicyVersionInCreatePolicyVersion = ram.PolicyVersionInCreatePolicyVersion{ + VersionId: "v2", + IsDefaultVersion: true, +} + +var mockUserInCreateUser = ram.UserInCreateUser{ + UserName: "mock-ram-user-name", +} + +var mockAccessKeyInCreateAccessKey = ram.AccessKeyInCreateAccessKey{ + AccessKeyId: "test-ak", + AccessKeySecret: "test-sk", +} + +func TestCreateRAMUsers(t *testing.T) { tests := []struct { name string mockAlibabaClient func(mockCtrl *gomock.Controller) *mockalibaba.MockClient @@ -68,8 +87,12 @@ func TestAttachRAMPolicy(t *testing.T) { generateOnly: true, mockAlibabaClient: func(mockCtrl *gomock.Controller) *mockalibaba.MockClient { mockAlibabaClient := mockalibaba.NewMockClient(mockCtrl) + mockCreateUser(mockAlibabaClient) mockCreatePolicy(mockAlibabaClient) mockAttachPolicyToUser(mockAlibabaClient) + mockCreateAccessKey(mockAlibabaClient) + mockGetPolicy(mockAlibabaClient) + mockCreatePolicyVersion(mockAlibabaClient) return mockAlibabaClient }, setup: func(t *testing.T) string { @@ -110,13 +133,7 @@ func TestAttachRAMPolicy(t *testing.T) { require.NoError(t, err, "unexpected error creating manifests dir for test") defer os.RemoveAll(manifestsDir) - var componentSecretInfo = ComponenntSecretInfo{ - componentAccessKeyId: testComponentAccessKeyId, - componentAccessKeySecret: testComponentAccessKeySecret, - targetDir: targetDir, - userName: testUserName, - } - err = attachRAMPolicy(mockAlibabaClient, testNamePrefix, credReqDir, componentSecretInfo) + err = createRAMUsers(mockAlibabaClient, testNamePrefix, credReqDir, targetDir) if test.expectError { require.Error(t, err, "expected error returned") @@ -171,15 +188,43 @@ spec: return nil } +func mockCreateUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().CreateUser(gomock.Any()).Return( + &ram.CreateUserResponse{ + User: mockUserInCreateUser, + }, nil).AnyTimes() +} + +func mockCreateAccessKey(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().CreateAccessKey(gomock.Any()).Return( + &ram.CreateAccessKeyResponse{ + AccessKey: mockAccessKeyInCreateAccessKey, + }, nil).AnyTimes() +} + +func mockAttachPolicyToUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().AttachPolicyToUser(gomock.Any()).Return( + &ram.AttachPolicyToUserResponse{}, nil, + ).AnyTimes() +} + func mockCreatePolicy(mockAlibabaClient *mockalibaba.MockClient) { mockAlibabaClient.EXPECT().CreatePolicy(gomock.Any()).Return( &ram.CreatePolicyResponse{ Policy: mockPolicyInCreatePolicy, - }, nil).Times(1) + }, nil).AnyTimes() } -func mockAttachPolicyToUser(mockAlibabaClient *mockalibaba.MockClient) { - mockAlibabaClient.EXPECT().AttachPolicyToUser(gomock.Any()).Return( - &ram.AttachPolicyToUserResponse{}, nil, - ).Times(1) +func mockGetPolicy(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().GetPolicy(gomock.Any()).Return( + &ram.GetPolicyResponse{ + Policy: mockPolicyInGetPolicy, + }, nil).AnyTimes() +} + +func mockCreatePolicyVersion(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().CreatePolicyVersion(gomock.Any()).Return( + &ram.CreatePolicyVersionResponse{ + PolicyVersion: mockPolicyVersionInCreatePolicyVersion, + }, nil).AnyTimes() } diff --git a/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go new file mode 100644 index 0000000000..e9c1bc2d57 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go @@ -0,0 +1,112 @@ +package alibabacloud + +import ( + "fmt" + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + "github.com/openshift/cloud-credential-operator/pkg/alibabacloud" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "log" +) + +var ( + // DeleteRAMUsersOpts captures the options that affect detaching of ram roles. + DeleteRAMUsersOpts = options{ + Region: "", + Name: "", + CredRequestDir: "", + } +) + +//detachComponentPolicy detach the specific ram policy from the ram user +func detachComponentPolicy(client alibabacloud.Client, policyName, userName string) error { + req := ram.CreateDetachPolicyFromUserRequest() + req.PolicyName = policyName + req.PolicyType = ramPolicyType + req.UserName = userName + _, err := client.DetachPolicyFromUser(req) + return err +} + +//deleteComponentPolicy delete the specific ram policy +func deleteComponentPolicy(client alibabacloud.Client, policyName string) error { + req := ram.CreateDeletePolicyRequest() + req.PolicyName = policyName + _, err := client.DeletePolicy(req) + return err +} + +//deleteComponentUser delete the specific component ram user +func deleteComponentUser(client alibabacloud.Client, userName string) error { + req := ram.CreateDeleteUserRequest() + req.UserName = userName + _, err := client.DeleteUser(req) + return err +} + +func deleteRAMUsers(client alibabacloud.Client, name, credReqDir string) error { + // Process directory + credRequests, err := provisioning.GetListOfCredentialsRequests(credReqDir) + if err != nil { + return errors.Wrap(err, "Failed to process files containing CredentialsRequests") + } + + for _, credReq := range credRequests { + userName, _ := generateRAMUserName(fmt.Sprintf("%s-%s-%s", name, credReq.Namespace, credReq.Name)) + listPoliciesReq := ram.CreateListPoliciesForUserRequest() + listPoliciesReq.UserName = userName + listPoliciesRes, err := client.ListPoliciesForUser(listPoliciesReq) + if err != nil { + return errors.Wrap(err, "Failed to list ram policies for component user") + } + //detach each policy from user + for _, userPolicy := range listPoliciesRes.Policies.Policy { + //detach component policy from the existing ram user + err := detachComponentPolicy(client, userPolicy.PolicyName, userName) + if err != nil { + return errors.Wrap(err, "Failed to detach ram policy from user") + } + //delete component ram policy + err = deleteComponentPolicy(client, userPolicy.PolicyName) + if err != nil { + return errors.Wrap(err, "Failed to delete component ram policy after detaching from user please clean up leaked policy manually") + } + } + //delete component ram user + err = deleteComponentUser(client, userName) + if err != nil { + return errors.Wrap(err, "Failed to delete component user") + } + } + return nil +} + +func deleteRAMUsersCmd(cmd *cobra.Command, args []string) { + client, err := alibabacloud.NewClient(DeleteRAMUsersOpts.Region) + if err != nil { + log.Fatalf("Failed to create a client: %v", err) + } + + err = deleteRAMUsers(client, DeleteRAMUsersOpts.Name, DeleteRAMUsersOpts.CredRequestDir) + if err != nil { + log.Fatalf("Failed to detach and delete the ram policy: %v", err) + } +} + +// NewDeleteRAMUsersCmd provides the "delete-ram-users" subcommand +func NewDeleteRAMUsersCmd() *cobra.Command { + detachCmd := &cobra.Command{ + Use: "delete-ram-users", + Short: "Detach RAM Policy from existing user", + Run: deleteRAMUsersCmd, + } + + detachCmd.PersistentFlags().StringVar(&DeleteRAMUsersOpts.Name, "name", "", "User-defined name for all created Alibaba Cloud resources (can be separate from the cluster's infra-id)") + detachCmd.MarkPersistentFlagRequired("name") + detachCmd.PersistentFlags().StringVar(&DeleteRAMUsersOpts.CredRequestDir, "credentials-requests-dir", "", "Directory containing files of CredentialsRequests to create RAM AK for (can be created by running 'oc adm release extract --credentials-requests --cloud=alibabacloud' against an OpenShift release image)") + detachCmd.MarkPersistentFlagRequired("credentials-requests-dir") + detachCmd.PersistentFlags().StringVar(&DeleteRAMUsersOpts.Region, "region", "", "Alibaba Cloud region endpoint only required for GovCloud") + + return detachCmd +} diff --git a/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go b/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go new file mode 100644 index 0000000000..ac1d907195 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go @@ -0,0 +1,117 @@ +package alibabacloud + +import ( + "io/ioutil" + "os" + "testing" + + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + "github.com/golang/mock/gomock" + mockalibaba "github.com/openshift/cloud-credential-operator/pkg/alibabacloud/mock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var mockPolicyInListPoliciesForUser = ram.PolicyInListPoliciesForUser{ + PolicyName: "alibaba-mock-default-test", + PolicyType: "Custom", + Description: "alibaba-mock-test", + DefaultVersion: "v1", + AttachDate: "2021-01-23T12:33:18Z", +} + +var mockPoliciesInListPoliciesForUser = ram.PoliciesInListPoliciesForUser{ + Policy: []ram.PolicyInListPoliciesForUser{mockPolicyInListPoliciesForUser}, +} + +func TestDetachRAMPolicy(t *testing.T) { + tests := []struct { + name string + mockAlibabaClient func(mockCtrl *gomock.Controller) *mockalibaba.MockClient + setup func(*testing.T) string + verify func(t *testing.T, manifestDir string) + cleanup func(*testing.T) + generateOnly bool + expectError bool + }{ + { + name: "No CredReqs", + generateOnly: true, + mockAlibabaClient: func(mockCtrl *gomock.Controller) *mockalibaba.MockClient { + mockAlibabaClient := mockalibaba.NewMockClient(mockCtrl) + mockDetachPolicyFromUser(mockAlibabaClient) + return mockAlibabaClient + }, + setup: func(t *testing.T) string { + tempDirName, err := ioutil.TempDir(os.TempDir(), testDirPrefix) + require.NoError(t, err, "Failed to create temp directory") + return tempDirName + }, + expectError: false, + }, + { + name: "detach ram policy for one CredReq", + generateOnly: true, + mockAlibabaClient: func(mockCtrl *gomock.Controller) *mockalibaba.MockClient { + mockAlibabaClient := mockalibaba.NewMockClient(mockCtrl) + mockDetachPolicyFromUser(mockAlibabaClient) + mockDeletePolicy(mockAlibabaClient) + mockListPoliciesForUser(mockAlibabaClient) + mockDeleteUser(mockAlibabaClient) + return mockAlibabaClient + }, + setup: func(t *testing.T) string { + tempDirName, err := ioutil.TempDir(os.TempDir(), testDirPrefix) + require.NoError(t, err, "Failed to create temp directory") + + err = testCredentialsRequest(t, "firstcredreq", "namespace1", "secretName1", tempDirName) + require.NoError(t, err, "errored while setting up test CredReq files") + + return tempDirName + }, + expectError: false, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + mockAlibabaClient := test.mockAlibabaClient(mockCtrl) + + credReqDir := test.setup(t) + defer os.RemoveAll(credReqDir) + + err := deleteRAMUsers(mockAlibabaClient, testNamePrefix, credReqDir) + if test.expectError { + require.Error(t, err, "expected error returned") + } else { + assert.NoError(t, err) + } + }) + } +} + +func mockDeletePolicy(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().DeletePolicy(gomock.Any()).Return( + &ram.DeletePolicyResponse{}, nil).Times(1) +} + +func mockDeleteUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().DeleteUser(gomock.Any()).Return( + &ram.DeleteUserResponse{}, nil).Times(1) +} + +func mockDetachPolicyFromUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().DetachPolicyFromUser(gomock.Any()).Return( + &ram.DetachPolicyFromUserResponse{}, nil, + ).AnyTimes() +} + +func mockListPoliciesForUser(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().ListPoliciesForUser(gomock.Any()).Return( + &ram.ListPoliciesForUserResponse{ + Policies: mockPoliciesInListPoliciesForUser, + }, nil).AnyTimes() +} diff --git a/pkg/cmd/provisioning/alibabacloud/utils.go b/pkg/cmd/provisioning/alibabacloud/utils.go new file mode 100644 index 0000000000..2faee87181 --- /dev/null +++ b/pkg/cmd/provisioning/alibabacloud/utils.go @@ -0,0 +1,148 @@ +package alibabacloud + +import ( + "errors" + "fmt" + "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" + "strings" + "time" +) + +const ( + arnDelimiter = ":" + arnSections = 5 + arnPrefix = "acs:" + arnUser = "user" + + // zero-indexed + sectionPartition = 0 + sectionService = 1 + sectionRegion = 2 + sectionAccountID = 3 + sectionResource = 4 + + // errors + invalidPrefix = "acs: invalid prefix" + invalidSections = "acs: not enough sections" + emptyRegion = "RegionId is empty, please set a valid RegionId." + newEmptyRegion = "Parameter region is empty, please set a valid region id." + + //ram error code + errorUserAlreadyExists = "EntityAlreadyExists.User" + errorUserNotExist = "EntityNotExist.User" + errorPolicyNotExists = "EntityNotExist.Policy" + errorAKLimitExceeded = "LimitExceeded.User.AccessKey" + + //ram accesskey status + ramActiveStatus = "Active" +) + +// ARN captures the individual fields of an RAM Resource Name. +type ARN struct { + // The partition that the resource is in. + Partition string + + // The service namespace that identifies the product (for example, RAM). + Service string + + // The region the resource resides in. Note that the ARNs for some resources do not require a region, so this + // component might be omitted. + Region string + + // The ID of the RAM account that owns the resource, without the hyphens. For example, 123456789012. Note that the + // ARNs for some resources don't require an account number, so this component might be omitted. + AccountID string + + // The content of this part of the ARN varies by service. + Resource string +} + +// Parse parses an ARN into its constituent parts. +// +// Some example ARNs: +// acs:ram::123456789012:user/tester +// acs:ram::123456789012:role/defaultrole​​​ +func parseArn(arn string) (ARN, error) { + if !strings.HasPrefix(arn, arnPrefix) { + return ARN{}, errors.New(invalidPrefix) + } + sections := strings.SplitN(arn, arnDelimiter, arnSections) + if len(sections) != arnSections { + return ARN{}, errors.New(invalidSections) + } + return ARN{ + Partition: sections[sectionPartition], + Service: sections[sectionService], + Region: sections[sectionRegion], + AccountID: sections[sectionAccountID], + Resource: sections[sectionResource], + }, nil +} + +//getRAMUserName return the RAM username in the given ARN +func getRAMUserName(arn string) (string, error) { + parsed, err := parseArn(arn) + if err != nil { + return "", fmt.Errorf("arn '%s' is invalid: %v", arn, err) + } + parts := strings.Split(parsed.Resource, "/") + resource := parts[0] + + if resource != arnUser || len(parts) != 2 { + return "", fmt.Errorf("arn '%s' is not ram user's format", arn) + } + return parts[1], nil +} + +//generateRAMUserName generate ram user name and displayname(the max length of display name is 128 characters) +func generateRAMUserName(userName string) (string, string) { + var shortenedUserName string + if len(userName) > 64 { + shortenedUserName = userName[0:64] + } else { + shortenedUserName = userName + } + + displayName := fmt.Sprintf("ccoctl user for %s", userName) + if len(displayName) > 128 { + displayName = displayName[0:128] + } + return shortenedUserName, displayName +} + +//generatePolicyName generate ram policy for given name, the max length of policy name is 128 characters +func generatePolicyName(name string) string { + if len(name) > 121 { + name = name[0:121] + } + return fmt.Sprintf("%s-policy", name) +} + +func refineMissingRegionIdErr(err error) error { + if err.Error() == emptyRegion { + return errors.New(newEmptyRegion) + } + return err +} + +//getDeleteAccessKeys return which accesskey would be deleted, including the older one and the ones with in-active status +func getDeleteAccessKeys(keys []ram.AccessKeyInListAccessKeys) ([]ram.AccessKeyInListAccessKeys, error) { + var deleteAccessKeys = make([]ram.AccessKeyInListAccessKeys, 0) + var keysCreated = make([]time.Time, 2) + for i, key := range keys { + if key.Status != ramActiveStatus { + deleteAccessKeys = append(deleteAccessKeys, key) + } + t, err := time.Parse(time.RFC3339, key.CreateDate) + if err != nil { + return deleteAccessKeys, err + } + keysCreated[i] = t + } + if keysCreated[0].Before(keysCreated[1]) { + deleteAccessKeys = append(deleteAccessKeys, keys[0]) + } else { + deleteAccessKeys = append(deleteAccessKeys, keys[1]) + } + return deleteAccessKeys, nil +} From 0ecbd8a12d705ceb5208ba16933667278c3787b6 Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Sun, 28 Nov 2021 20:52:51 +0800 Subject: [PATCH 4/8] add docs for alibaba cloud manual mode --- docs/ccoctl.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/docs/ccoctl.md b/docs/ccoctl.md index f563a7d273..02f8ef9875 100644 --- a/docs/ccoctl.md +++ b/docs/ccoctl.md @@ -215,3 +215,124 @@ This command will delete the service id from the IBM Cloud ```bash ccoctl ibmcloud delete-service-id --credentials-requests-dir --name ``` + +## Alibaba Cloud + +This part is the guide for using manual mode on alibaba cloud, for more use info about manual mode, please reference to [cco-mode-manual](https://github.com/openshift/cloud-credential-operator/blob/master/docs/mode-manual-creds.md). + +In alibaba cloud manual mode, the CCO utility (`ccoctl`) binary will create Secret manifests for the OpenShift installer that will create multiple users and use a long-lived RAM AK credentials for each OpenShift Container Platform cluster components. and every ram user who owns the AK would be attached the mapping ram policies with the permission defined in each component's CredentialsRequest, and a root ram user with required ram permission is needed for creating ram users, ram polices and also attaching the policy to each target component ram user. + +### Prerequisite + +1. Extract and prepare the ccoctl binary from the release image. + +2. Choose an existing ram user who has the ram pemissions below as least, and get this ram user's accesskey id/accesskey secret for creating the ram users and policies for each component and attaching the specific component permission to the mapping ram user. + + ``` +ram:CreatePolicy +ram:GetPolicy +ram:CreatePolicyVersion +ram:DeletePolicy +ram:DetachPolicyFromUser +ram:ListPoliciesForUser +ram:AttachPolicyToUser +ram:CreateUser +ram:GetUser +ram:DeleteUser +ram:CreateAccessKey +ram:ListAccessKeys +ram:DeleteAccessKey + ``` + +3. Use the selected ram user’s accesskey id/secret to configure the Alibaba Cloud SDK client's creadential provider chain with [Envionment Creadentials](https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md#1-environment-credentials) mode or through [Credentials File](https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md#2-credentials-file) mode + +### Procedure + +1. Extract the list of CredentialsRequest custom resources (CRs) from the OpenShift Container Platform release image: + + ```bash + $ oc adm release extract --credentials-requests --cloud=alibabacloud --to=/credrequests quay.io//ocp-release: + + ``` + +**step 2&3 are only need when preparing for upgrading clusters with manually maintained credentials. When doing a fresh installation please skip step 2&3** + +2. For each CredentialsRequest CR in the release image, ensure that a namespace that matches the text in the spec.secretRef.namespace field exists in the cluster. This field is where the generated secrets that hold the credentials configuration are stored. + + Sample Alibaba Cloud CredentialsRequest object + + ```yaml + apiVersion: cloudcredential.openshift.io/v1 + kind: CredentialsRequest + metadata: + name: cloud-credential-operator-ram-ro + namespace: openshift-cloud-credential-operator + spec: + providerSpec: + apiVersion: cloudcredential.openshift.io/v1 + kind: AlibabaCloudProviderSpec + statementEntries: + - action: + - ecs:CopySnapshot + - ecs:DeleteDisk + - ecs:DescribeInstanceAttribute + - ecs:DescribeInstances + effect: Allow + resource: '*' + secretRef: + namespace: cloud-credential-operator-ram-ro-creds + name: openshift-cloud-credential-operator + ``` + + 3. For any `CredentialsRequest` CR for which the cluster does not already have a namespace with the name specified in `spec.secretRef.namespace`, create the namespace: + + ```bash + $ oc create namespace + ``` + +4. Use the `ccoctl` tool to process all `CredentialsRequest` objects in the `credrequests` directory: + + ```bash + $ ccoctl alibabacloud create-ram-users --name --region= --credentials-requests-dir=/credrequests --output-dir=xxxxxx + ``` + + where: + + - `name` is the name used to tag any cloud resources that are created for tracking. + - `region` is the Alibaba Cloud region in which cloud resources will be created. + - `credentials-requests-dir` is the directory containing files of component CredentialsRequests. + - `output-dir`/manifests is the directory containing files of component credentials secret. + +5. Prepare to run the OpenShift Container Platform installer: + + a. Create the install-config.yaml file: + ```bash + $ openshift-install create install-config --dir ./path/to/installation/dir + ``` + b. Configure the cluster to install with the CCO in manual mode: + + ```bash + $ echo "credentialsMode: Manual" >> ./path/to/installation/dir/install-config.yaml + ``` + + c. Create install manifests: + + ```bash + $ openshift-install create manifests --dir ./path/to/installation/dir + ``` + + d. Copy the generated credential files to the target manifests directory: + + ```bash + $ cp /manifests/*credentials.yaml ./path/to/installation/dir/manifests/ + ``` +6. To delete resources created by ccoctl, run + + ```bash + $ ccoctl alibabacloud delete-ram-users --name --region= --credentials-requests-dir=/credrequests + ``` +where: + - `name` is the name used to tag any cloud resources that are created for tracking. + - `region` is the Alibaba Cloud region in which cloud resources will be created. + - `credentials-requests-dir` is the directory containing files of component CredentialsRequests. + \ No newline at end of file From ca9ab61fca061bc14240f3cd1f8b30c743483b88 Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Wed, 1 Dec 2021 21:58:59 +0800 Subject: [PATCH 5/8] refine component ram users name and doc --- docs/ccoctl.md | 10 +++++----- pkg/cmd/provisioning/alibabacloud/create-ram-users.go | 2 +- pkg/cmd/provisioning/alibabacloud/delete-ram-users.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/ccoctl.md b/docs/ccoctl.md index 02f8ef9875..a3061d8802 100644 --- a/docs/ccoctl.md +++ b/docs/ccoctl.md @@ -218,15 +218,15 @@ ccoctl ibmcloud delete-service-id --credentials-requests-dir Date: Fri, 3 Dec 2021 00:37:14 +0800 Subject: [PATCH 6/8] clean all accesskeys before delete ram user and fix the policy re-attach issue --- .../alibabacloud/create-ram-users.go | 17 +++++++++++---- .../alibabacloud/delete-ram-users.go | 21 +++++++++++++++++-- pkg/cmd/provisioning/alibabacloud/utils.go | 8 +++---- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/provisioning/alibabacloud/create-ram-users.go b/pkg/cmd/provisioning/alibabacloud/create-ram-users.go index 9b7c4f193f..0d4c95f687 100644 --- a/pkg/cmd/provisioning/alibabacloud/create-ram-users.go +++ b/pkg/cmd/provisioning/alibabacloud/create-ram-users.go @@ -58,7 +58,7 @@ func createRAMUsersCmd(cmd *cobra.Command, args []string) { err = createRAMUsers(client, CreateRAMUsersOpts.Name, CreateRAMUsersOpts.CredRequestDir, CreateRAMUsersOpts.TargetDir) if err != nil { - log.Fatalf("failed to create RAM users and policies: %s", err) + log.Fatalf(err.Error()) } } @@ -148,6 +148,12 @@ func attachComponentPolicy(client alibabacloud.Client, user, policyName string) req.UserName = user req.PolicyType = ramPolicyType _, err := client.AttachPolicyToUser(req) + if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + if ok && aErr.ErrorCode() == errorUserAleadyAttachedPolicy { + return nil + } + } return err } @@ -176,7 +182,7 @@ func createUser(client alibabacloud.Client, name string, credReq *credreqv1.Cred log.Printf("RAM User %s already exists, continuing", shortName) return shortName, nil } else { - return "", errors.Wrap(err, "failed to create RAM user") + return "", errors.Wrap(err, "Failed to create RAM user") } } @@ -195,10 +201,13 @@ func generateUserAccessKeys(client alibabacloud.Client, userName string) (*ram.C listKeyReq := ram.CreateListAccessKeysRequest() listKeyReq.UserName = userName listKeyRes, err := client.ListAccessKeys(listKeyReq) + if err != nil { + return nil, errors.Wrap(err, "Failed to list accesskeys") + } //get the older one or the keys with in-active status to delete deleteKeys, err := getDeleteAccessKeys(listKeyRes.AccessKeys.AccessKey) if err != nil { - return nil, errors.Wrap(err, "failed to get the older ram accesskey") + return nil, errors.Wrap(err, "Failed to get the older ram accesskey") } for _, oneAK := range deleteKeys { log.Printf("Ready to delete user %s accesskey %s", userName, oneAK.AccessKeyId) @@ -218,7 +227,7 @@ func generateUserAccessKeys(client alibabacloud.Client, userName string) (*ram.C log.Printf("Created access keys for RAM User: %s", userName) return accessKeyResp, nil } - return nil, errors.Wrap(err, "failed to create RAM user access keys") + return nil, errors.Wrap(err, "Failed to create RAM user access keys") } log.Printf("Created access keys for RAM User: %s", userName) return accessKeyResp, nil diff --git a/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go index 0ff6f57eb5..f3364ef0df 100644 --- a/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go +++ b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go @@ -39,9 +39,26 @@ func deleteComponentPolicy(client alibabacloud.Client, policyName string) error //deleteComponentUser delete the specific component ram user func deleteComponentUser(client alibabacloud.Client, userName string) error { + //remove all user AccessKeys firstly + listKeyReq := ram.CreateListAccessKeysRequest() + listKeyReq.UserName = userName + listKeyRes, err := client.ListAccessKeys(listKeyReq) + if err != nil { + return errors.Wrap(err, "Failed to list accesskeys") + } + for _, oneKey := range listKeyRes.AccessKeys.AccessKey { + log.Printf("Ready to delete user %s accesskey %s", userName, oneKey.AccessKeyId) + deleteKeyReq := ram.CreateDeleteAccessKeyRequest() + deleteKeyReq.UserName = userName + deleteKeyReq.UserAccessKeyId = oneKey.AccessKeyId + _, err := client.DeleteAccessKey(deleteKeyReq) + if err != nil { + return err + } + } req := ram.CreateDeleteUserRequest() req.UserName = userName - _, err := client.DeleteUser(req) + _, err = client.DeleteUser(req) return err } @@ -90,7 +107,7 @@ func deleteRAMUsersCmd(cmd *cobra.Command, args []string) { err = deleteRAMUsers(client, DeleteRAMUsersOpts.Name, DeleteRAMUsersOpts.CredRequestDir) if err != nil { - log.Fatalf("Failed to detach and delete the ram policy: %v", err) + log.Fatalf(err.Error()) } } diff --git a/pkg/cmd/provisioning/alibabacloud/utils.go b/pkg/cmd/provisioning/alibabacloud/utils.go index 2faee87181..22a5a37211 100644 --- a/pkg/cmd/provisioning/alibabacloud/utils.go +++ b/pkg/cmd/provisioning/alibabacloud/utils.go @@ -28,10 +28,10 @@ const ( newEmptyRegion = "Parameter region is empty, please set a valid region id." //ram error code - errorUserAlreadyExists = "EntityAlreadyExists.User" - errorUserNotExist = "EntityNotExist.User" - errorPolicyNotExists = "EntityNotExist.Policy" - errorAKLimitExceeded = "LimitExceeded.User.AccessKey" + errorUserAlreadyExists = "EntityAlreadyExists.User" + errorUserAleadyAttachedPolicy = "EntityAlreadyExists.User.Policy" + errorPolicyNotExists = "EntityNotExist.Policy" + errorAKLimitExceeded = "LimitExceeded.User.AccessKey" //ram accesskey status ramActiveStatus = "Active" From 567919bcccdff6c4c144c372bd0f2bcfe5d6afb2 Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Fri, 3 Dec 2021 16:19:50 +0800 Subject: [PATCH 7/8] enhancement for back-to-back deleting ram user --- pkg/alibabacloud/client.go | 10 ++++ pkg/alibabacloud/mock/client_generated.go | 30 ++++++++++++ .../alibabacloud/delete-ram-users.go | 47 +++++++++++++++++-- .../alibabacloud/delete-ram-users_test.go | 18 ++++++- pkg/cmd/provisioning/alibabacloud/utils.go | 2 + 5 files changed, 101 insertions(+), 6 deletions(-) diff --git a/pkg/alibabacloud/client.go b/pkg/alibabacloud/client.go index a25f284532..1c4fd287c7 100644 --- a/pkg/alibabacloud/client.go +++ b/pkg/alibabacloud/client.go @@ -41,6 +41,8 @@ type Client interface { DeletePolicy(request *ram.DeletePolicyRequest) (response *ram.DeletePolicyResponse, err error) DetachPolicyFromUser(request *ram.DetachPolicyFromUserRequest) (response *ram.DetachPolicyFromUserResponse, err error) ListPoliciesForUser(request *ram.ListPoliciesForUserRequest) (response *ram.ListPoliciesForUserResponse, err error) + DeletePolicyVersion(request *ram.DeletePolicyVersionRequest) (response *ram.DeletePolicyVersionResponse, err error) + ListPolicyVersions(request *ram.ListPolicyVersionsRequest) (response *ram.ListPolicyVersionsResponse, err error) } type alibabaCloudClient struct { @@ -99,6 +101,14 @@ func (c *alibabaCloudClient) DeleteAccessKey(input *ram.DeleteAccessKeyRequest) return c.ramClient.DeleteAccessKey(input) } +func (c *alibabaCloudClient) DeletePolicyVersion(input *ram.DeletePolicyVersionRequest) (*ram.DeletePolicyVersionResponse, error) { + return c.ramClient.DeletePolicyVersion(input) +} + +func (c *alibabaCloudClient) ListPolicyVersions(input *ram.ListPolicyVersionsRequest) (*ram.ListPolicyVersionsResponse, error) { + return c.ramClient.ListPolicyVersions(input) +} + // NewClient creates our client wrapper object for the actual Alibaba Cloud clients we use. func NewClient(regionId string) (Client, error) { envProvider := provider.NewEnvProvider() diff --git a/pkg/alibabacloud/mock/client_generated.go b/pkg/alibabacloud/mock/client_generated.go index 4395476aff..752ce637a6 100644 --- a/pkg/alibabacloud/mock/client_generated.go +++ b/pkg/alibabacloud/mock/client_generated.go @@ -139,6 +139,21 @@ func (mr *MockClientMockRecorder) DeletePolicy(request interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockClient)(nil).DeletePolicy), request) } +// DeletePolicyVersion mocks base method. +func (m *MockClient) DeletePolicyVersion(request *ram.DeletePolicyVersionRequest) (*ram.DeletePolicyVersionResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeletePolicyVersion", request) + ret0, _ := ret[0].(*ram.DeletePolicyVersionResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeletePolicyVersion indicates an expected call of DeletePolicyVersion. +func (mr *MockClientMockRecorder) DeletePolicyVersion(request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicyVersion", reflect.TypeOf((*MockClient)(nil).DeletePolicyVersion), request) +} + // DeleteUser mocks base method. func (m *MockClient) DeleteUser(arg0 *ram.DeleteUserRequest) (*ram.DeleteUserResponse, error) { m.ctrl.T.Helper() @@ -228,3 +243,18 @@ func (mr *MockClientMockRecorder) ListPoliciesForUser(request interface{}) *gomo mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPoliciesForUser", reflect.TypeOf((*MockClient)(nil).ListPoliciesForUser), request) } + +// ListPolicyVersions mocks base method. +func (m *MockClient) ListPolicyVersions(request *ram.ListPolicyVersionsRequest) (*ram.ListPolicyVersionsResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListPolicyVersions", request) + ret0, _ := ret[0].(*ram.ListPolicyVersionsResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListPolicyVersions indicates an expected call of ListPolicyVersions. +func (mr *MockClientMockRecorder) ListPolicyVersions(request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPolicyVersions", reflect.TypeOf((*MockClient)(nil).ListPolicyVersions), request) +} diff --git a/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go index f3364ef0df..cfbff80a40 100644 --- a/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go +++ b/pkg/cmd/provisioning/alibabacloud/delete-ram-users.go @@ -2,6 +2,7 @@ package alibabacloud import ( "fmt" + alibabaerrors "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors" "github.com/aliyun/alibaba-cloud-sdk-go/services/ram" "github.com/openshift/cloud-credential-operator/pkg/alibabacloud" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning" @@ -31,10 +32,36 @@ func detachComponentPolicy(client alibabacloud.Client, policyName, userName stri //deleteComponentPolicy delete the specific ram policy func deleteComponentPolicy(client alibabacloud.Client, policyName string) error { - req := ram.CreateDeletePolicyRequest() - req.PolicyName = policyName - _, err := client.DeletePolicy(req) - return err + lpvReq := ram.CreateListPolicyVersionsRequest() + lpvReq.PolicyName = policyName + lpvReq.PolicyType = ramPolicyType + lpvRes, err := client.ListPolicyVersions(lpvReq) + if err != nil { + return err + } + for _, policyVersion := range lpvRes.PolicyVersions.PolicyVersion { + if !policyVersion.IsDefaultVersion { + req := ram.CreateDeletePolicyVersionRequest() + req.PolicyName = policyName + req.VersionId = policyVersion.VersionId + _, err := client.DeletePolicyVersion(req) + if err != nil { + return err + } + log.Printf("Version %s of policy %s removed", policyVersion.VersionId, policyName) + } + } + dpReq := ram.CreateDeletePolicyRequest() + dpReq.PolicyName = policyName + _, err = client.DeletePolicy(dpReq) + if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + //the policy may attached by other ram user + if ok && aErr.ErrorCode() != errorDeleteConlictPolicyUser { + return err + } + } + return nil } //deleteComponentUser delete the specific component ram user @@ -75,6 +102,12 @@ func deleteRAMUsers(client alibabacloud.Client, name, credReqDir string) error { listPoliciesReq.UserName = userName listPoliciesRes, err := client.ListPoliciesForUser(listPoliciesReq) if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + //the user may already deleted + if ok && aErr.ErrorCode() == errorUserNotExists { + log.Printf("Ram user %s has already deleted", userName) + continue + } return errors.Wrap(err, "Failed to list ram policies for component user") } //detach each policy from user @@ -82,6 +115,12 @@ func deleteRAMUsers(client alibabacloud.Client, name, credReqDir string) error { //detach component policy from the existing ram user err := detachComponentPolicy(client, userPolicy.PolicyName, userName) if err != nil { + aErr, ok := err.(*alibabaerrors.ServerError) + if ok && aErr.ErrorCode() == errorPolicyNotExists { + //create new policy + log.Printf("Ram policy %s has already deleted", userPolicy.PolicyName) + continue + } return errors.Wrap(err, "Failed to detach ram policy from user") } //delete component ram policy diff --git a/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go b/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go index ac1d907195..9601488a2b 100644 --- a/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go +++ b/pkg/cmd/provisioning/alibabacloud/delete-ram-users_test.go @@ -57,6 +57,8 @@ func TestDetachRAMPolicy(t *testing.T) { mockDetachPolicyFromUser(mockAlibabaClient) mockDeletePolicy(mockAlibabaClient) mockListPoliciesForUser(mockAlibabaClient) + mockListPolicyVersions(mockAlibabaClient) + mockListAccessKeys(mockAlibabaClient) mockDeleteUser(mockAlibabaClient) return mockAlibabaClient }, @@ -95,12 +97,12 @@ func TestDetachRAMPolicy(t *testing.T) { func mockDeletePolicy(mockAlibabaClient *mockalibaba.MockClient) { mockAlibabaClient.EXPECT().DeletePolicy(gomock.Any()).Return( - &ram.DeletePolicyResponse{}, nil).Times(1) + &ram.DeletePolicyResponse{}, nil).AnyTimes() } func mockDeleteUser(mockAlibabaClient *mockalibaba.MockClient) { mockAlibabaClient.EXPECT().DeleteUser(gomock.Any()).Return( - &ram.DeleteUserResponse{}, nil).Times(1) + &ram.DeleteUserResponse{}, nil).AnyTimes() } func mockDetachPolicyFromUser(mockAlibabaClient *mockalibaba.MockClient) { @@ -115,3 +117,15 @@ func mockListPoliciesForUser(mockAlibabaClient *mockalibaba.MockClient) { Policies: mockPoliciesInListPoliciesForUser, }, nil).AnyTimes() } + +func mockListPolicyVersions(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().ListPolicyVersions(gomock.Any()).Return( + &ram.ListPolicyVersionsResponse{}, nil, + ).AnyTimes() +} + +func mockListAccessKeys(mockAlibabaClient *mockalibaba.MockClient) { + mockAlibabaClient.EXPECT().ListAccessKeys(gomock.Any()).Return( + &ram.ListAccessKeysResponse{}, nil, + ).AnyTimes() +} diff --git a/pkg/cmd/provisioning/alibabacloud/utils.go b/pkg/cmd/provisioning/alibabacloud/utils.go index 22a5a37211..c2d61f348f 100644 --- a/pkg/cmd/provisioning/alibabacloud/utils.go +++ b/pkg/cmd/provisioning/alibabacloud/utils.go @@ -29,6 +29,8 @@ const ( //ram error code errorUserAlreadyExists = "EntityAlreadyExists.User" + errorUserNotExists = "EntityNotExist.User" + errorDeleteConlictPolicyUser = "DeleteConflict.Policy.User" errorUserAleadyAttachedPolicy = "EntityAlreadyExists.User.Policy" errorPolicyNotExists = "EntityNotExist.Policy" errorAKLimitExceeded = "LimitExceeded.User.AccessKey" From de9cc738e2183f483819a062ce2c5175ea274e3b Mon Sep 17 00:00:00 2001 From: "dahu.kdh" Date: Thu, 9 Dec 2021 10:49:33 +0800 Subject: [PATCH 8/8] refine ccoctl.md for alibabacloud manual mode --- cmd/ccoctl/main.go | 2 +- docs/ccoctl.md | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/ccoctl/main.go b/cmd/ccoctl/main.go index 6ea2026738..24be476e6a 100644 --- a/cmd/ccoctl/main.go +++ b/cmd/ccoctl/main.go @@ -5,10 +5,10 @@ import ( "github.com/spf13/cobra" + "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/alibabacloud" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/aws" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/gcp" "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/ibmcloud" - "github.com/openshift/cloud-credential-operator/pkg/cmd/provisioning/alibabacloud" ) func main() { diff --git a/docs/ccoctl.md b/docs/ccoctl.md index a3061d8802..b488385e30 100644 --- a/docs/ccoctl.md +++ b/docs/ccoctl.md @@ -228,20 +228,20 @@ For alibaba cloud, the CCO utility (`ccoctl`) binary will create credentials Se 2. Choose an existing RAM user who has the below permissions, and get this user's accesskey id/secret for creating the RAM users and policies for each in-cluster component. - ``` -ram:CreatePolicy -ram:GetPolicy -ram:CreatePolicyVersion -ram:DeletePolicy -ram:DetachPolicyFromUser -ram:ListPoliciesForUser -ram:AttachPolicyToUser -ram:CreateUser -ram:GetUser -ram:DeleteUser -ram:CreateAccessKey -ram:ListAccessKeys -ram:DeleteAccessKey + ```bash + ram:CreatePolicy + ram:GetPolicy + ram:CreatePolicyVersion + ram:DeletePolicy + ram:DetachPolicyFromUser + ram:ListPoliciesForUser + ram:AttachPolicyToUser + ram:CreateUser + ram:GetUser + ram:DeleteUser + ram:CreateAccessKey + ram:ListAccessKeys + ram:DeleteAccessKey ``` 3. Use the selected RAM user’s accesskey id/secret to configure the Alibaba Cloud SDK client's credential provider chain with [Envionment Creadentials](https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md#1-environment-credentials) mode or through [Credentials File](https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md#2-credentials-file) mode @@ -255,7 +255,7 @@ ram:DeleteAccessKey ``` -**step 2&3 are only needed when preparing for upgrading clusters with manually maintained credentials. When doing a fresh installation please skip step 2&3** + > step 2&3 are only needed when preparing for upgrading clusters with manually maintained credentials. When doing a fresh installation please skip step 2&3** 2. For each CredentialsRequest CR in the release image, ensure that a namespace that matches the text in the spec.secretRef.namespace field exists in the cluster. This field is where the generated secrets that hold the credentials configuration are stored. @@ -284,7 +284,7 @@ ram:DeleteAccessKey name: openshift-cloud-credential-operator ``` - 3. For any `CredentialsRequest` CR for which the cluster does not already have a namespace with the name specified in `spec.secretRef.namespace`, create the namespace: +3. For any `CredentialsRequest` CR for which the cluster does not already have a namespace with the name specified in `spec.secretRef.namespace`, create the namespace: ```bash $ oc create namespace @@ -302,6 +302,8 @@ ram:DeleteAccessKey - `region` is the Alibaba Cloud region in which cloud resources will be created. - `credentials-requests-dir` is the directory containing files of component CredentialsRequests. - `output-dir`/manifests is the directory containing files of component credentials secret. + + > Note: A ram user can have up to two accesskeys at the same time, so when the `ccoctl alibabacloud create-ram-users` command is run more than twice, the previous generated manifests secret will become stale and you should apply the new generated secrets again.** 5. Prepare to run the OpenShift Container Platform installer: @@ -331,7 +333,7 @@ ram:DeleteAccessKey ```bash $ ccoctl alibabacloud delete-ram-users --name --region= --credentials-requests-dir=/credrequests ``` -where: + where: - `name` is the name used to tag any cloud resources that are created for tracking. - `region` is the Alibaba Cloud region in which cloud resources will be created. - `credentials-requests-dir` is the directory containing files of component CredentialsRequests.