Best Syzkaller code snippet using adb.Create
service_alicloud_adb.go
Source:service_alicloud_adb.go
...12type AdbService struct {13 client *connectivity.AliyunClient14}15func (s *AdbService) DescribeAdbCluster(id string) (instance *adb.DBClusterInDescribeDBClusters, err error) {16 request := adb.CreateDescribeDBClustersRequest()17 request.RegionId = s.client.RegionId18 dbClusterIds := []string{}19 dbClusterIds = append(dbClusterIds, id)20 request.DBClusterIds = id21 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {22 return adbClient.DescribeDBClusters(request)23 })24 if err != nil {25 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {26 return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)27 }28 return nil, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)29 }30 addDebug(request.GetActionName(), raw, request.RpcRequest, request)31 response, _ := raw.(*adb.DescribeDBClustersResponse)32 if len(response.Items.DBCluster) < 1 {33 return nil, WrapErrorf(Error(GetNotFoundMessage("Cluster", id)), NotFoundMsg, ProviderERROR)34 }35 return &response.Items.DBCluster[0], nil36}37func (s *AdbService) DescribeAdbClusterAttribute(id string) (instance *adb.DBCluster, err error) {38 request := adb.CreateDescribeDBClusterAttributeRequest()39 request.RegionId = s.client.RegionId40 request.DBClusterId = id41 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {42 return adbClient.DescribeDBClusterAttribute(request)43 })44 if err != nil {45 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {46 return instance, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)47 }48 return instance, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)49 }50 addDebug(request.GetActionName(), raw, request.RpcRequest, request)51 response, _ := raw.(*adb.DescribeDBClusterAttributeResponse)52 if len(response.Items.DBCluster) < 1 {53 return nil, WrapErrorf(Error(GetNotFoundMessage("Cluster", id)), NotFoundMsg, ProviderERROR)54 }55 return &response.Items.DBCluster[0], nil56}57func (s *AdbService) DescribeAdbAutoRenewAttribute(id string) (instance *adb.AutoRenewAttribute, err error) {58 request := adb.CreateDescribeAutoRenewAttributeRequest()59 request.RegionId = s.client.RegionId60 request.DBClusterIds = id61 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {62 return adbClient.DescribeAutoRenewAttribute(request)63 })64 if err != nil {65 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {66 return instance, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)67 }68 return instance, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)69 }70 addDebug(request.GetActionName(), raw, request.RpcRequest, request)71 response, _ := raw.(*adb.DescribeAutoRenewAttributeResponse)72 if len(response.Items.AutoRenewAttribute) < 1 {73 return nil, WrapErrorf(Error(GetNotFoundMessage("Cluster", id)), NotFoundMsg, ProviderERROR)74 }75 return &response.Items.AutoRenewAttribute[0], nil76}77func (s *AdbService) WaitForAdbConnection(id string, status Status, timeout int) error {78 deadline := time.Now().Add(time.Duration(timeout) * time.Second)79 for {80 object, err := s.DescribeAdbConnection(id)81 if err != nil {82 if NotFoundError(err) {83 if status == Deleted {84 return nil85 }86 } else {87 return WrapError(err)88 }89 }90 if status != Deleted && object != nil && object.ConnectionString != "" {91 return nil92 }93 if time.Now().After(deadline) {94 return WrapErrorf(err, WaitTimeoutMsg, id, GetFunc(1), timeout, object.ConnectionString, id, ProviderERROR)95 }96 time.Sleep(DefaultIntervalShort * time.Second)97 }98}99func (s *AdbService) DescribeAdbConnection(id string) (*adb.Address, error) {100 parts, err := ParseResourceId(id, 2)101 if err != nil {102 return nil, WrapError(err)103 }104 deadline := time.Now().Add(time.Duration(DefaultIntervalLong) * time.Second)105 for {106 object, err := s.DescribeAdbClusterNetInfo(parts[0])107 if err != nil {108 if NotFoundError(err) {109 return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)110 }111 return nil, WrapError(err)112 }113 if object != nil {114 for _, p := range object {115 if p.NetType == "Public" {116 return &p, nil117 }118 }119 }120 time.Sleep(DefaultIntervalMini * time.Second)121 if time.Now().After(deadline) {122 break123 }124 }125 return nil, WrapErrorf(Error(GetNotFoundMessage("DBConnection", id)), NotFoundMsg, ProviderERROR)126}127func (s *AdbService) DescribeAdbClusterNetInfo(id string) ([]adb.Address, error) {128 request := adb.CreateDescribeDBClusterNetInfoRequest()129 request.RegionId = s.client.RegionId130 request.DBClusterId = id131 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {132 return adbClient.DescribeDBClusterNetInfo(request)133 })134 if err != nil {135 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {136 return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)137 }138 return nil, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)139 }140 addDebug(request.GetActionName(), raw, request.RpcRequest, request)141 response, _ := raw.(*adb.DescribeDBClusterNetInfoResponse)142 if len(response.Items.Address) < 1 {143 return nil, WrapErrorf(Error(GetNotFoundMessage("DBInstanceNetInfo", id)), NotFoundMsg, ProviderERROR)144 }145 return response.Items.Address, nil146}147func (s *AdbService) WaitForAdbAccount(id string, status Status, timeout int) error {148 deadline := time.Now().Add(time.Duration(timeout) * time.Second)149 for {150 object, err := s.DescribeAdbAccount(id)151 if err != nil {152 if NotFoundError(err) {153 if status == Deleted {154 return nil155 }156 } else {157 return WrapError(err)158 }159 }160 if object.AccountStatus == string(status) {161 break162 }163 if time.Now().After(deadline) {164 return WrapErrorf(err, WaitTimeoutMsg, id, GetFunc(1), timeout, object.AccountStatus, status, ProviderERROR)165 }166 time.Sleep(DefaultIntervalShort * time.Second)167 }168 return nil169}170func (s *AdbService) DescribeAdbAccount(id string) (ds *adb.DBAccount, err error) {171 parts, err := ParseResourceId(id, 2)172 if err != nil {173 err = WrapError(err)174 return175 }176 request := adb.CreateDescribeAccountsRequest()177 request.RegionId = s.client.RegionId178 request.DBClusterId = parts[0]179 request.AccountName = parts[1]180 invoker := NewInvoker()181 invoker.AddCatcher(DBInstanceStatusCatcher)182 var response *adb.DescribeAccountsResponse183 if err := invoker.Run(func() error {184 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {185 return adbClient.DescribeAccounts(request)186 })187 if err != nil {188 return err189 }190 addDebug(request.GetActionName(), raw, request.RpcRequest, request)191 response, _ = raw.(*adb.DescribeAccountsResponse)192 return nil193 }); err != nil {194 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {195 return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)196 }197 return nil, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)198 }199 if len(response.AccountList.DBAccount) < 1 {200 return nil, WrapErrorf(Error(GetNotFoundMessage("DBAccount", id)), NotFoundMsg, ProviderERROR)201 }202 return &response.AccountList.DBAccount[0], nil203}204// WaitForInstance waits for instance to given status205func (s *AdbService) WaitForAdbInstance(id string, status Status, timeout int) error {206 deadline := time.Now().Add(time.Duration(timeout) * time.Second)207 for {208 object, err := s.DescribeAdbCluster(id)209 if err != nil {210 if NotFoundError(err) {211 if status == Deleted {212 return nil213 }214 } else {215 return WrapError(err)216 }217 }218 if strings.ToLower(object.DBClusterStatus) == strings.ToLower(string(status)) {219 break220 }221 if time.Now().After(deadline) {222 return WrapErrorf(err, WaitTimeoutMsg, id, GetFunc(1), timeout, object.DBClusterStatus, status, ProviderERROR)223 }224 time.Sleep(DefaultIntervalShort * time.Second)225 }226 return nil227}228func (s *AdbService) setClusterTags(d *schema.ResourceData) error {229 if d.HasChange("tags") {230 oraw, nraw := d.GetChange("tags")231 o := oraw.(map[string]interface{})232 n := nraw.(map[string]interface{})233 create, remove := s.diffTags(s.tagsFromMap(o), s.tagsFromMap(n))234 if len(remove) > 0 {235 var tagKey []string236 for _, v := range remove {237 tagKey = append(tagKey, v.Key)238 }239 request := adb.CreateUntagResourcesRequest()240 request.ResourceId = &[]string{d.Id()}241 request.ResourceType = "cluster"242 request.TagKey = &tagKey243 request.RegionId = s.client.RegionId244 raw, err := s.client.WithAdbClient(func(client *adb.Client) (interface{}, error) {245 return client.UntagResources(request)246 })247 if err != nil {248 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)249 }250 addDebug(request.GetActionName(), raw, request.RpcRequest, request)251 }252 if len(create) > 0 {253 request := adb.CreateTagResourcesRequest()254 request.ResourceId = &[]string{d.Id()}255 request.Tag = &create256 request.ResourceType = "cluster"257 request.RegionId = s.client.RegionId258 raw, err := s.client.WithAdbClient(func(client *adb.Client) (interface{}, error) {259 return client.TagResources(request)260 })261 if err != nil {262 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)263 }264 addDebug(request.GetActionName(), raw, request.RpcRequest, request)265 }266 d.SetPartial("tags")267 }268 return nil269}270func (s *AdbService) diffTags(oldTags, newTags []adb.TagResourcesTag) ([]adb.TagResourcesTag, []adb.TagResourcesTag) {271 // First, we're creating everything we have272 create := make(map[string]interface{})273 for _, t := range newTags {274 create[t.Key] = t.Value275 }276 // Build the list of what to remove277 var remove []adb.TagResourcesTag278 for _, t := range oldTags {279 old, ok := create[t.Key]280 if !ok || old != t.Value {281 // Delete it!282 remove = append(remove, t)283 }284 }285 return s.tagsFromMap(create), remove286}287func (s *AdbService) tagsToMap(tags []adb.TagResource) map[string]string {288 result := make(map[string]string)289 for _, t := range tags {290 if !s.ignoreTag(t) {291 result[t.TagKey] = t.TagValue292 }293 }294 return result295}296func (s *AdbService) tagsFromMap(m map[string]interface{}) []adb.TagResourcesTag {297 result := make([]adb.TagResourcesTag, 0, len(m))298 for k, v := range m {299 result = append(result, adb.TagResourcesTag{300 Key: k,301 Value: v.(string),302 })303 }304 return result305}306func (s *AdbService) ignoreTag(t adb.TagResource) bool {307 filter := []string{"^aliyun", "^acs:", "^http://", "^https://"}308 for _, v := range filter {309 log.Printf("[DEBUG] Matching prefix %v with %v\n", v, t.TagKey)310 ok, _ := regexp.MatchString(v, t.TagValue)311 if ok {312 log.Printf("[DEBUG] Found Alibaba Cloud specific t %s (val: %s), ignoring.\n", t.TagKey, t.TagValue)313 return true314 }315 }316 return false317}318func (s *AdbService) DescribeTags(resourceId string, resourceType TagResourceType) (tags []adb.TagResource, err error) {319 request := adb.CreateListTagResourcesRequest()320 request.RegionId = s.client.RegionId321 request.ResourceType = string(resourceType)322 request.ResourceId = &[]string{resourceId}323 raw, err := s.client.WithAdbClient(func(client *adb.Client) (interface{}, error) {324 return client.ListTagResources(request)325 })326 if err != nil {327 err = WrapErrorf(err, DefaultErrorMsg, resourceId, request.GetActionName(), AlibabaCloudSdkGoERROR)328 return329 }330 addDebug(request.GetActionName(), raw, request.RpcRequest, request)331 response, _ := raw.(*adb.ListTagResourcesResponse)332 return response.TagResources.TagResource, nil333}334// WaitForCluster waits for cluster to given status335func (s *AdbService) WaitForCluster(id string, status Status, timeout int) error {336 deadline := time.Now().Add(time.Duration(timeout) * time.Second)337 for {338 object, err := s.DescribeAdbClusterAttribute(id)339 if err != nil {340 if NotFoundError(err) {341 if status == Deleted {342 return nil343 }344 } else {345 return WrapError(err)346 }347 }348 if strings.ToLower(object.DBClusterStatus) == strings.ToLower(string(status)) {349 break350 }351 if time.Now().After(deadline) {352 return WrapErrorf(err, WaitTimeoutMsg, id, GetFunc(1), timeout, object.DBClusterStatus, status, ProviderERROR)353 }354 time.Sleep(DefaultIntervalShort * time.Second)355 }356 return nil357}358func (s *AdbService) DescribeDBSecurityIps(clusterId string) (ips []string, err error) {359 request := adb.CreateDescribeDBClusterAccessWhiteListRequest()360 request.RegionId = s.client.RegionId361 request.DBClusterId = clusterId362 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {363 return adbClient.DescribeDBClusterAccessWhiteList(request)364 })365 if err != nil {366 return ips, WrapErrorf(err, DefaultErrorMsg, clusterId, request.GetActionName(), AlibabaCloudSdkGoERROR)367 }368 addDebug(request.GetActionName(), raw, request.RpcRequest, request)369 resp, _ := raw.(*adb.DescribeDBClusterAccessWhiteListResponse)370 var ipstr, separator string371 ipsMap := make(map[string]string)372 for _, ip := range resp.Items.IPArray {373 if ip.DBClusterIPArrayAttribute != "hidden" {374 ipstr += separator + ip.SecurityIPList375 separator = COMMA_SEPARATED376 }377 }378 for _, ip := range strings.Split(ipstr, COMMA_SEPARATED) {379 ipsMap[ip] = ip380 }381 var finalIps []string382 if len(ipsMap) > 0 {383 for key := range ipsMap {384 finalIps = append(finalIps, key)385 }386 }387 return finalIps, nil388}389func (s *AdbService) ModifyDBSecurityIps(clusterId, ips string) error {390 request := adb.CreateModifyDBClusterAccessWhiteListRequest()391 request.RegionId = s.client.RegionId392 request.DBClusterId = clusterId393 request.SecurityIps = ips394 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {395 return adbClient.ModifyDBClusterAccessWhiteList(request)396 })397 if err != nil {398 return WrapErrorf(err, DefaultErrorMsg, clusterId, request.GetActionName(), AlibabaCloudSdkGoERROR)399 }400 addDebug(request.GetActionName(), raw, request.RpcRequest, request)401 if err := s.WaitForCluster(clusterId, Running, DefaultTimeoutMedium); err != nil {402 return WrapError(err)403 }404 return nil405}406func (s *AdbService) DescribeAdbBackupPolicy(id string) (policy *adb.DescribeBackupPolicyResponse, err error) {407 request := adb.CreateDescribeBackupPolicyRequest()408 request.DBClusterId = id409 request.RegionId = s.client.RegionId410 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {411 return adbClient.DescribeBackupPolicy(request)412 })413 if err != nil {414 if IsExpectedErrors(err, []string{"InvalidDBClusterId.NotFound"}) {415 return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR)416 }417 return policy, WrapErrorf(err, DefaultErrorMsg, id, request.GetActionName(), AlibabaCloudSdkGoERROR)418 }419 addDebug(request.GetActionName(), raw, request.RpcRequest, request)420 return raw.(*adb.DescribeBackupPolicyResponse), nil421}422func (s *AdbService) ModifyAdbBackupPolicy(clusterId, backupTime, backupPeriod string) error {423 request := adb.CreateModifyBackupPolicyRequest()424 request.RegionId = s.client.RegionId425 request.DBClusterId = clusterId426 request.PreferredBackupPeriod = backupPeriod427 request.PreferredBackupTime = backupTime428 raw, err := s.client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {429 return adbClient.ModifyBackupPolicy(request)430 })431 if err != nil {432 return WrapErrorf(err, DefaultErrorMsg, clusterId, request.GetActionName(), AlibabaCloudSdkGoERROR)433 }434 addDebug(request.GetActionName(), raw, request.RpcRequest, request)435 if err := s.WaitForCluster(clusterId, Running, DefaultTimeoutMedium); err != nil {436 return WrapError(err)437 }...
resource_alicloud_adb_cluster.go
Source:resource_alicloud_adb_cluster.go
...10 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"11)12func resourceAlicloudAdbCluster() *schema.Resource {13 return &schema.Resource{14 Create: resourceAlicloudAdbClusterCreate,15 Read: resourceAlicloudAdbClusterRead,16 Update: resourceAlicloudAdbClusterUpdate,17 Delete: resourceAlicloudAdbClusterDelete,18 Importer: &schema.ResourceImporter{19 State: schema.ImportStatePassthrough,20 },21 Timeouts: &schema.ResourceTimeout{22 Create: schema.DefaultTimeout(50 * time.Minute),23 Delete: schema.DefaultTimeout(10 * time.Minute),24 Update: schema.DefaultTimeout(72 * time.Hour),25 },26 Schema: map[string]*schema.Schema{27 "db_cluster_version": {28 Type: schema.TypeString,29 ForceNew: true,30 ValidateFunc: validation.StringInSlice([]string{"3.0"}, false),31 Optional: true,32 Default: "3.0",33 },34 "db_cluster_category": {35 Type: schema.TypeString,36 ForceNew: true,37 ValidateFunc: validation.StringInSlice([]string{"Basic", "Cluster"}, false),38 Required: true,39 },40 "db_node_class": {41 Type: schema.TypeString,42 Required: true,43 },44 "db_node_count": {45 Type: schema.TypeInt,46 Required: true,47 },48 "db_node_storage": {49 Type: schema.TypeInt,50 Required: true,51 },52 "zone_id": {53 Type: schema.TypeString,54 Optional: true,55 Computed: true,56 },57 "pay_type": {58 Type: schema.TypeString,59 ForceNew: true,60 ValidateFunc: validation.StringInSlice([]string{string(PostPaid), string(PrePaid)}, false),61 Optional: true,62 Default: PostPaid,63 },64 "renewal_status": {65 Type: schema.TypeString,66 Optional: true,67 Default: RenewNotRenewal,68 ValidateFunc: validation.StringInSlice([]string{69 string(RenewAutoRenewal),70 string(RenewNormal),71 string(RenewNotRenewal)}, false),72 DiffSuppressFunc: adbPostPaidDiffSuppressFunc,73 },74 "auto_renew_period": {75 Type: schema.TypeInt,76 Optional: true,77 Default: 1,78 ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 6, 12, 24, 36}),79 DiffSuppressFunc: adbPostPaidAndRenewDiffSuppressFunc,80 },81 "period": {82 Type: schema.TypeInt,83 ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36}),84 Optional: true,85 Default: 1,86 DiffSuppressFunc: adbPostPaidDiffSuppressFunc,87 },88 "security_ips": {89 Type: schema.TypeSet,90 Elem: &schema.Schema{Type: schema.TypeString},91 Computed: true,92 Optional: true,93 },94 "vswitch_id": {95 Type: schema.TypeString,96 ForceNew: true,97 Required: true,98 },99 "maintain_time": {100 Type: schema.TypeString,101 Optional: true,102 Computed: true,103 },104 "description": {105 Type: schema.TypeString,106 Optional: true,107 ValidateFunc: validation.StringLenBetween(2, 256),108 },109 "tags": tagsSchema(),110 "connection_string": {111 Type: schema.TypeString,112 Computed: true,113 },114 },115 }116}117func resourceAlicloudAdbClusterCreate(d *schema.ResourceData, meta interface{}) error {118 client := meta.(*connectivity.AliyunClient)119 adbService := AdbService{client}120 request, err := buildAdbCreateRequest(d, meta)121 if err != nil {122 return WrapError(err)123 }124 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {125 return adbClient.CreateDBCluster(request)126 })127 if err != nil {128 return WrapErrorf(err, DefaultErrorMsg, "alicloud_adb_cluster", request.GetActionName(), AlibabaCloudSdkGoERROR)129 }130 addDebug(request.GetActionName(), raw, request.RpcRequest, request)131 response, _ := raw.(*adb.CreateDBClusterResponse)132 d.SetId(response.DBClusterId)133 // wait cluster status change from Creating to running134 stateConf := BuildStateConf([]string{"Preparing", "Creating"}, []string{"Running"}, d.Timeout(schema.TimeoutCreate), 15*time.Minute, adbService.AdbClusterStateRefreshFunc(d.Id(), []string{"Deleting"}))135 if _, err := stateConf.WaitForState(); err != nil {136 return WrapErrorf(err, IdMsg, d.Id())137 }138 return resourceAlicloudAdbClusterUpdate(d, meta)139}140func resourceAlicloudAdbClusterUpdate(d *schema.ResourceData, meta interface{}) error {141 client := meta.(*connectivity.AliyunClient)142 adbService := AdbService{client}143 d.Partial(true)144 if err := adbService.setClusterTags(d); err != nil {145 return WrapError(err)146 }147 if (d.Get("pay_type").(string) == string(PrePaid)) &&148 (d.HasChange("renewal_status") || d.HasChange("auto_renew_period")) {149 status := d.Get("renewal_status").(string)150 request := adb.CreateModifyAutoRenewAttributeRequest()151 request.DBClusterId = d.Id()152 request.RenewalStatus = status153 if status == string(RenewAutoRenewal) {154 period := d.Get("auto_renew_period").(int)155 request.Duration = strconv.Itoa(period)156 request.PeriodUnit = string(Month)157 if period > 9 {158 request.Duration = strconv.Itoa(period / 12)159 request.PeriodUnit = string(Year)160 }161 }162 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {163 return adbClient.ModifyAutoRenewAttribute(request)164 })165 if err != nil {166 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)167 }168 addDebug(request.GetActionName(), raw, request.RpcRequest, request)169 d.SetPartial("renewal_status")170 d.SetPartial("auto_renew_period")171 }172 if d.HasChange("maintain_time") {173 request := adb.CreateModifyDBClusterMaintainTimeRequest()174 request.RegionId = client.RegionId175 request.DBClusterId = d.Id()176 request.MaintainTime = d.Get("maintain_time").(string)177 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {178 return adbClient.ModifyDBClusterMaintainTime(request)179 })180 if err != nil {181 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)182 }183 addDebug(request.GetActionName(), raw, request.RpcRequest, request)184 d.SetPartial("maintain_time")185 }186 if d.IsNewResource() {187 d.Partial(false)188 return resourceAlicloudAdbClusterRead(d, meta)189 }190 if d.HasChange("description") {191 request := adb.CreateModifyDBClusterDescriptionRequest()192 request.RegionId = client.RegionId193 request.DBClusterId = d.Id()194 request.DBClusterDescription = d.Get("description").(string)195 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {196 return adbClient.ModifyDBClusterDescription(request)197 })198 if err != nil {199 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)200 }201 addDebug(request.GetActionName(), raw, request.RpcRequest, request)202 d.SetPartial("description")203 }204 if d.HasChange("security_ips") {205 ipList := expandStringList(d.Get("security_ips").(*schema.Set).List())206 ipstr := strings.Join(ipList[:], COMMA_SEPARATED)207 // default disable connect from outside208 if ipstr == "" {209 ipstr = LOCAL_HOST_IP210 }211 if err := adbService.ModifyDBSecurityIps(d.Id(), ipstr); err != nil {212 return WrapError(err)213 }214 d.SetPartial("security_ips")215 }216 if d.HasChange("db_node_class") || d.HasChange("db_node_count") || d.HasChange("db_node_storage") {217 request := adb.CreateModifyDBClusterRequest()218 request.RegionId = client.RegionId219 request.DBClusterId = d.Id()220 request.DBNodeClass = d.Get("db_node_class").(string)221 request.DBNodeStorage = strconv.Itoa(d.Get("db_node_storage").(int))222 request.DBNodeGroupCount = strconv.Itoa(d.Get("db_node_count").(int))223 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {224 return adbClient.ModifyDBCluster(request)225 })226 if err != nil {227 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)228 }229 addDebug(request.GetActionName(), raw, request.RpcRequest, request)230 // wait cluster status change from ClassChanging to Running231 stateConf := BuildStateConf([]string{"ClassChanging"}, []string{"Running"}, d.Timeout(schema.TimeoutUpdate), 30*time.Minute, adbService.AdbClusterStateRefreshFunc(d.Id(), []string{}))232 if _, err := stateConf.WaitForState(); err != nil {233 return WrapErrorf(err, IdMsg, d.Id())234 }235 d.SetPartial("db_node_class")236 d.SetPartial("db_node_count")237 d.SetPartial("db_node_storage")238 }239 d.Partial(false)240 return resourceAlicloudAdbClusterRead(d, meta)241}242func resourceAlicloudAdbClusterRead(d *schema.ResourceData, meta interface{}) error {243 client := meta.(*connectivity.AliyunClient)244 adbService := AdbService{client}245 clusterAttribute, err := adbService.DescribeAdbClusterAttribute(d.Id())246 if err != nil {247 if NotFoundError(err) {248 d.SetId("")249 return nil250 }251 return WrapError(err)252 }253 cluster, err := adbService.DescribeAdbCluster(d.Id())254 if err != nil {255 if NotFoundError(err) {256 d.SetId("")257 return nil258 }259 return WrapError(err)260 }261 ips, err := adbService.DescribeDBSecurityIps(d.Id())262 if err != nil {263 return WrapError(err)264 }265 d.Set("security_ips", ips)266 d.Set("vswitch_id", clusterAttribute.VSwitchId)267 d.Set("pay_type", getChargeType(clusterAttribute.PayType))268 d.Set("id", clusterAttribute.DBClusterId)269 d.Set("description", clusterAttribute.DBClusterDescription)270 d.Set("db_version", clusterAttribute.DBVersion)271 d.Set("maintain_time", clusterAttribute.MaintainTime)272 d.Set("zone_id", clusterAttribute.ZoneId)273 d.Set("connection_string", clusterAttribute.ConnectionString)274 d.Set("db_node_class", cluster.DBNodeClass)275 d.Set("db_node_count", cluster.DBNodeCount)276 d.Set("db_node_storage", cluster.DBNodeStorage)277 d.Set("db_cluster_category", cluster.Category)278 d.Set("db_cluster_version", cluster.DBVersion)279 tags, err := adbService.DescribeTags(d.Id(), "cluster")280 if err != nil {281 return WrapError(err)282 }283 d.Set("tags", adbService.tagsToMap(tags))284 if clusterAttribute.PayType == string(Prepaid) {285 clusterAutoRenew, err := adbService.DescribeAdbAutoRenewAttribute(d.Id())286 if err != nil {287 if NotFoundError(err) {288 d.SetId("")289 return nil290 }291 return WrapError(err)292 }293 renewPeriod := 1294 if clusterAutoRenew != nil {295 renewPeriod = clusterAutoRenew.Duration296 }297 if clusterAutoRenew != nil && clusterAutoRenew.PeriodUnit == string(Year) {298 renewPeriod = renewPeriod * 12299 }300 d.Set("auto_renew_period", renewPeriod)301 period, err := computePeriodByUnit(clusterAttribute.CreationTime, clusterAttribute.ExpireTime, d.Get("period").(int), "Month")302 if err != nil {303 return WrapError(err)304 }305 d.Set("period", period)306 d.Set("renewal_status", clusterAutoRenew.RenewalStatus)307 }308 return nil309}310func resourceAlicloudAdbClusterDelete(d *schema.ResourceData, meta interface{}) error {311 client := meta.(*connectivity.AliyunClient)312 adbService := AdbService{client}313 cluster, err := adbService.DescribeAdbClusterAttribute(d.Id())314 if err != nil {315 if NotFoundError(err) {316 return nil317 }318 return WrapError(err)319 }320 // Pre paid cluster can not be release.321 if PayType(cluster.PayType) == Prepaid {322 return nil323 }324 request := adb.CreateDeleteDBClusterRequest()325 request.RegionId = client.RegionId326 request.DBClusterId = d.Id()327 err = resource.Retry(5*time.Minute, func() *resource.RetryError {328 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {329 return adbClient.DeleteDBCluster(request)330 })331 if err != nil {332 if IsExpectedErrors(err, []string{"OperationDenied.InvalidDBClusterStatus", "OperationDenied.InvalidAdbClusterStatus"}) {333 return resource.RetryableError(err)334 }335 return resource.NonRetryableError(err)336 }337 addDebug(request.GetActionName(), raw, request.RpcRequest, request)338 return nil339 })340 if err != nil {341 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)342 }343 stateConf := BuildStateConf([]string{"Creating", "Running", "Deleting"}, []string{}, d.Timeout(schema.TimeoutDelete), 1*time.Minute, adbService.AdbClusterStateRefreshFunc(d.Id(), []string{}))344 if _, err = stateConf.WaitForState(); err != nil {345 return WrapErrorf(err, IdMsg, d.Id())346 }347 return nil348}349func buildAdbCreateRequest(d *schema.ResourceData, meta interface{}) (*adb.CreateDBClusterRequest, error) {350 client := meta.(*connectivity.AliyunClient)351 vpcService := VpcService{client}352 request := adb.CreateCreateDBClusterRequest()353 request.RegionId = string(client.Region)354 request.DBClusterVersion = Trim(d.Get("db_cluster_version").(string))355 request.DBClusterCategory = Trim(d.Get("db_cluster_category").(string))356 request.DBClusterClass = d.Get("db_node_class").(string)357 request.DBNodeGroupCount = strconv.Itoa(d.Get("db_node_count").(int))358 request.DBNodeStorage = strconv.Itoa(d.Get("db_node_storage").(int))359 request.DBClusterDescription = d.Get("description").(string)360 request.ClientToken = buildClientToken(request.GetActionName())361 if zone, ok := d.GetOk("zone_id"); ok && Trim(zone.(string)) != "" {362 request.ZoneId = Trim(zone.(string))363 }364 vswitchId := Trim(d.Get("vswitch_id").(string))365 if vswitchId != "" {366 request.VSwitchId = vswitchId...
resource_alicloud_adb_account.go
Source:resource_alicloud_adb_account.go
...10 "github.com/hashicorp/terraform-plugin-sdk/helper/validation"11)12func resourceAlicloudAdbAccount() *schema.Resource {13 return &schema.Resource{14 Create: resourceAlicloudAdbAccountCreate,15 Read: resourceAlicloudAdbAccountRead,16 Update: resourceAlicloudAdbAccountUpdate,17 Delete: resourceAlicloudAdbAccountDelete,18 Importer: &schema.ResourceImporter{19 State: schema.ImportStatePassthrough,20 },21 Schema: map[string]*schema.Schema{22 "db_cluster_id": {23 Type: schema.TypeString,24 ForceNew: true,25 Required: true,26 },27 "account_name": {28 Type: schema.TypeString,29 ForceNew: true,30 Required: true,31 },32 "account_password": {33 Type: schema.TypeString,34 Optional: true,35 Sensitive: true,36 },37 "kms_encrypted_password": {38 Type: schema.TypeString,39 Optional: true,40 DiffSuppressFunc: kmsDiffSuppressFunc,41 },42 "kms_encryption_context": {43 Type: schema.TypeMap,44 Optional: true,45 DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {46 return d.Get("kms_encrypted_password").(string) == ""47 },48 Elem: schema.TypeString,49 },50 "account_type": {51 Type: schema.TypeString,52 Optional: true,53 ValidateFunc: validation.StringInSlice([]string{string("Super")}, false),54 Default: "Super",55 ForceNew: true,56 Removed: "Field 'account_type' has been removed from provider version 1.81.0.",57 },58 "account_description": {59 Type: schema.TypeString,60 Optional: true,61 },62 },63 }64}65func resourceAlicloudAdbAccountCreate(d *schema.ResourceData, meta interface{}) error {66 client := meta.(*connectivity.AliyunClient)67 adbService := AdbService{client}68 request := adb.CreateCreateAccountRequest()69 request.RegionId = client.RegionId70 request.DBClusterId = d.Get("db_cluster_id").(string)71 request.AccountName = d.Get("account_name").(string)72 password := d.Get("account_password").(string)73 kmsPassword := d.Get("kms_encrypted_password").(string)74 if password == "" && kmsPassword == "" {75 return WrapError(Error("One of the 'password' and 'kms_encrypted_password' should be set."))76 }77 if password != "" {78 request.AccountPassword = password79 } else {80 kmsService := KmsService{client}81 decryptResp, err := kmsService.Decrypt(kmsPassword, d.Get("kms_encryption_context").(map[string]interface{}))82 if err != nil {83 return WrapError(err)84 }85 request.AccountPassword = decryptResp.Plaintext86 }87 // Description will not be set when account type is normal and it is a API bug88 if v, ok := d.GetOk("account_description"); ok && v.(string) != "" {89 request.AccountDescription = v.(string)90 }91 err := resource.Retry(5*time.Minute, func() *resource.RetryError {92 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {93 return adbClient.CreateAccount(request)94 })95 if err != nil {96 if IsExpectedErrors(err, OperationDeniedDBStatus) {97 time.Sleep(5 * time.Second)98 return resource.RetryableError(err)99 }100 return resource.NonRetryableError(err)101 }102 addDebug(request.GetActionName(), raw, request.RpcRequest, request)103 return nil104 })105 if err != nil {106 return WrapErrorf(err, DefaultErrorMsg, "alicloud_adb_account", request.GetActionName(), AlibabaCloudSdkGoERROR)107 }108 d.SetId(fmt.Sprintf("%s%s%s", request.DBClusterId, COLON_SEPARATED, request.AccountName))109 if err := adbService.WaitForAdbAccount(d.Id(), Available, DefaultTimeoutMedium); err != nil {110 return WrapError(err)111 }112 return resourceAlicloudAdbAccountRead(d, meta)113}114func resourceAlicloudAdbAccountRead(d *schema.ResourceData, meta interface{}) error {115 client := meta.(*connectivity.AliyunClient)116 adbService := AdbService{client}117 object, err := adbService.DescribeAdbAccount(d.Id())118 if err != nil {119 if NotFoundError(err) {120 d.SetId("")121 return nil122 }123 return WrapError(err)124 }125 parts, err := ParseResourceId(d.Id(), 2)126 if err != nil {127 return WrapError(err)128 }129 d.Set("db_cluster_id", parts[0])130 d.Set("account_name", object.AccountName)131 d.Set("account_description", object.AccountDescription)132 return nil133}134func resourceAlicloudAdbAccountUpdate(d *schema.ResourceData, meta interface{}) error {135 client := meta.(*connectivity.AliyunClient)136 adbService := AdbService{client}137 d.Partial(true)138 parts := strings.Split(d.Id(), COLON_SEPARATED)139 instanceId := parts[0]140 accountName := parts[1]141 if d.HasChange("account_description") {142 if err := adbService.WaitForAdbAccount(d.Id(), Available, DefaultTimeoutMedium); err != nil {143 return WrapError(err)144 }145 request := adb.CreateModifyAccountDescriptionRequest()146 request.RegionId = client.RegionId147 request.DBClusterId = instanceId148 request.AccountName = accountName149 request.AccountDescription = d.Get("account_description").(string)150 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {151 return adbClient.ModifyAccountDescription(request)152 })153 if err != nil {154 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)155 }156 addDebug(request.GetActionName(), raw, request.RpcRequest, request)157 d.SetPartial("account_description")158 }159 if d.HasChange("account_password") || d.HasChange("kms_encrypted_password") {160 if err := adbService.WaitForAdbAccount(d.Id(), Available, DefaultTimeoutMedium); err != nil {161 return WrapError(err)162 }163 request := adb.CreateResetAccountPasswordRequest()164 request.RegionId = client.RegionId165 request.DBClusterId = instanceId166 request.AccountName = accountName167 password := d.Get("account_password").(string)168 kmsPassword := d.Get("kms_encrypted_password").(string)169 if password == "" && kmsPassword == "" {170 return WrapError(Error("One of the 'password' and 'kms_encrypted_password' should be set."))171 }172 if password != "" {173 request.AccountPassword = password174 } else {175 kmsService := KmsService{meta.(*connectivity.AliyunClient)}176 decryptResp, err := kmsService.Decrypt(kmsPassword, d.Get("kms_encryption_context").(map[string]interface{}))177 if err != nil {178 return WrapError(err)179 }180 request.AccountPassword = decryptResp.Plaintext181 }182 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {183 return adbClient.ResetAccountPassword(request)184 })185 if err != nil {186 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)187 }188 addDebug(request.GetActionName(), raw, request.RpcRequest, request)189 d.SetPartial("account_password")190 }191 d.Partial(false)192 return resourceAlicloudAdbAccountRead(d, meta)193}194func resourceAlicloudAdbAccountDelete(d *schema.ResourceData, meta interface{}) error {195 client := meta.(*connectivity.AliyunClient)196 adbService := AdbService{client}197 parts, err := ParseResourceId(d.Id(), 2)198 if err != nil {199 return WrapError(err)200 }201 request := adb.CreateDeleteAccountRequest()202 request.RegionId = client.RegionId203 request.DBClusterId = parts[0]204 request.AccountName = parts[1]205 raw, err := client.WithAdbClient(func(adbClient *adb.Client) (interface{}, error) {206 return adbClient.DeleteAccount(request)207 })208 if err != nil {209 if IsExpectedErrors(err, []string{"InvalidAccountName.NotFound"}) {210 return nil211 }212 return WrapErrorf(err, DefaultErrorMsg, d.Id(), request.GetActionName(), AlibabaCloudSdkGoERROR)213 }214 addDebug(request.GetActionName(), raw, request.RpcRequest, request)215 return adbService.WaitForAdbAccount(d.Id(), Deleted, DefaultTimeoutMedium)...
Create
Using AI Code Generation
1import (2func main() {3 err := ui.Main(func() {4 name := ui.NewEntry()5 button := ui.NewButton("Create")6 box := ui.NewVerticalBox()7 box.Append(ui.NewLabel("Enter the name of the database"), false)8 box.Append(name, false)9 box.Append(button, false)10 window := ui.NewWindow("Create", 200, 100, false)11 window.SetMargined(true)12 window.SetChild(box)13 button.OnClicked(func(*ui.Button) {14 adb := new(adb)15 adb.Create(name.Text())16 ui.MsgBox(window, "Success", "Database created successfully")17 window.Destroy()18 })19 window.OnClosing(func(*ui.Window) bool {20 ui.Quit()21 })22 window.Show()23 })24 if err != nil {25 panic(err)26 }27}28import (29func main() {30 err := ui.Main(func() {31 name := ui.NewEntry()32 button := ui.NewButton("Insert")33 box := ui.NewVerticalBox()34 box.Append(ui.NewLabel("Enter the name of the database"), false)35 box.Append(name, false)36 box.Append(button, false)37 window := ui.NewWindow("Insert", 200, 100, false)38 window.SetMargined(true)39 window.SetChild(box)40 button.OnClicked(func(*ui.Button) {41 adb := new(adb)42 adb.Insert(name.Text())43 ui.MsgBox(window, "Success", "Inserted successfully")44 window.Destroy()45 })46 window.OnClosing(func(*ui.Window) bool {47 ui.Quit()48 })49 window.Show()50 })51 if err != nil {52 panic(err)53 }54}55import (56func main() {57 err := ui.Main(func() {
Create
Using AI Code Generation
1import (2func main() {3 db, err := sql.Open("adodb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\MyName\\Desktop\\Go\\test.mdb")4 if err != nil {5 log.Fatal(err)6 }7 stmt, err := db.Prepare("CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)")8 if err != nil {9 log.Fatal(err)10 }11 _, err = stmt.Exec()12 stmt, err = db.Prepare("INSERT INTO test (name) VALUES ('a')")13 if err != nil {14 log.Fatal(err)15 }16 _, err = stmt.Exec()17 rows, err := db.Query("SELECT * FROM test")18 if err != nil {19 log.Fatal(err)20 }21 defer rows.Close()22 for rows.Next() {23 err = rows.Scan(&id, &name)24 if err != nil {25 log.Fatal(err)26 }27 fmt.Println(id, name)28 }29 err = rows.Err()30 if err != nil {31 log.Fatal(err)32 }33}
Create
Using AI Code Generation
1import "fmt"2import "github.com/udhos/goadb"3func main() {4 adb := goadb.New()5 devices := adb.Devices()6 if len(devices) == 0 {7 fmt.Println("no device")8 }9 fmt.Println("device: ", device)10 err := device.Create("/data/local/tmp/test.txt")11 if err != nil {12 fmt.Println("create error: ", err)13 }14 fmt.Println("create ok")15}
Create
Using AI Code Generation
1import (2func main() {3 adb, err := beedb.NewAdaptor("sqlite3", "test.db")4 if err != nil {5 panic(err)6 }7 err = adb.Create("test")8 if err != nil {9 panic(err)10 }11 fmt.Println("database created")12}13import (14type User struct {15}16func main() {17 adb, err := beedb.NewAdaptor("sqlite3", "test.db")18 if err != nil {19 panic(err)20 }21 err = adb.Create("test")22 if err != nil {23 panic(err)24 }25 u := User{1, "astaxie"}26 adb.Insert(&u)27 fmt.Println("data inserted")28}29import (30type User struct {31}32func main() {33 adb, err := beedb.NewAdaptor("sqlite3", "test.db")34 if err != nil {35 panic(err)36 }37 err = adb.Create("test")38 if err != nil {39 panic(err)40 }41 u := User{1, "astaxie"}42 adb.Insert(&u)43 adb.Find(&user, 1)44 fmt.Println(user)45}46{1 astaxie}
Create
Using AI Code Generation
1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6func main() {7 fmt.Println("Hello, playground")8}9import (10func main() {11 fmt.Println("Hello, playground")12}13import (14func main() {15 fmt.Println("Hello, playground")16}17import (18func main() {19 fmt.Println("Hello, playground")20}21import (22func main() {23 fmt.Println("Hello, playground")24}25import (26func main() {27 fmt.Println("Hello, playground")28}29import (30func main() {31 fmt.Println("Hello, playground")32}33import (34func main() {35 fmt.Println("Hello, playground")36}37import (38func main() {39 fmt.Println("Hello, playground")40}41import (42func main() {43 fmt.Println("Hello, playground")44}45import (46func main() {47 fmt.Println("
Create
Using AI Code Generation
1import (2func main() {3 adb, err := adb.New()4 if err != nil {5 panic(err)6 }7 defer adb.Close()8 err = adb.Create("test")9 if err != nil {10 panic(err)11 }12 fmt.Println("Device created")13}14import (15func main() {16 adb, err := adb.New()17 if err != nil {18 panic(err)19 }20 defer adb.Close()21 err = adb.Delete("test")22 if err != nil {23 panic(err)24 }25 fmt.Println("Device deleted")26}27import (28func main() {29 adb, err := adb.New()30 if err != nil {31 panic(err)32 }33 defer adb.Close()34 devices, err := adb.GetDevices()35 if err != nil {36 panic(err)37 }38 fmt.Println("Devices: ", devices)39}40import (41func main() {42 adb, err := adb.New()43 if err != nil {44 panic(err)45 }46 defer adb.Close()47 devices, err := adb.GetDevicesWithStatus()48 if err != nil {49 panic(err)50 }51 fmt.Println("Devices: ", devices)52}53import (54func main() {55 adb, err := adb.New()56 if err != nil {57 panic(err)58 }59 defer adb.Close()60 status, err := adb.GetDeviceStatus("test")61 if err != nil {62 panic(err)63 }
Create
Using AI Code Generation
1func main() {2 adb := new(adb)3 adb.Create()4 adb.StartServer()5}6func main() {7 adb := new(adb)8 adb.Create()9 adb.StartServer()10 adb.KillServer()11}12func main() {13 adb := new(adb)14 adb.Create()15 adb.StartServer()16 adb.KillServer()17 adb.GetDevices()18}19func main() {20 adb := new(adb)21 adb.Create()22 adb.StartServer()23 adb.KillServer()24 adb.GetDevices()25 adb.GetProperties()26}27func main() {28 adb := new(adb)
Create
Using AI Code Generation
1import (2func main() {3 adb := adb.New()4 device := adb.Create("device name")5 if device != nil {6 fmt.Println(device.Name)7 } else {8 fmt.Println("device not found")9 }10}11import (12func main() {13 adb := adb.New()14 device := adb.Connect("device name")15 if device != nil {16 fmt.Println(device.Name)17 } else {18 fmt.Println("device not found")19 }20}21import (22func main() {23 adb := adb.New()24 device := adb.Connect("device name")25 if device != nil {26 fmt.Println(device.Name)27 } else {28 fmt.Println("device not found")29 }30 adb.Disconnect("device name")31}32import (33func main() {34 adb := adb.New()35 device := adb.Connect("device name")36 if device != nil {37 fmt.Println(device.Name)38 } else {39 fmt.Println("device not found")40 }41 adb.DisconnectAll()42}43import (44func main() {45 adb := adb.New()46 device := adb.Connect("device name")47 if device != nil {48 fmt.Println(device.Name)
Create
Using AI Code Generation
1import (2func main() {3 adb := &ADB{4 DesiredCapabilities: DesiredCapabilities{5 },6 }7 adb.Create()8 adb.Click("com.example.android.contactmanager:id/addContactButton")9 adb.SendKeys("com.example.android.contactmanager:id/contactNameEditText", "Rajesh")10 adb.Click("com.example.android.contactmanager:id/contactPhoneEditText")11 adb.SendKeys("com.example.android.contactmanager:id/contactPhoneEditText", "1234567890")12 adb.Click("com.example.android.contactmanager:id/contactEmailEditText")13 adb.SendKeys("com.example.android.contactmanager:id/contactEmailEditText", "
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!