How to use usage method of main Package

Best Mock code snippet using main.usage

resource_aws_api_gateway_usage_plan_test.go

Source:resource_aws_api_gateway_usage_plan_test.go Github

copy

Full Screen

...20 Steps: []resource.TestStep{21 {22 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),23 Check: resource.ComposeTestCheckFunc(24 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),25 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),26 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),27 ),28 },29 {30 Config: testAccAWSApiGatewayUsagePlanBasicUpdatedConfig(updatedName),31 Check: resource.ComposeTestCheckFunc(32 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", updatedName),33 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),34 ),35 },36 {37 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),38 Check: resource.ComposeTestCheckFunc(39 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),40 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),41 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),42 ),43 },44 },45 })46}47func TestAccAWSAPIGatewayUsagePlan_description(t *testing.T) {48 var conf apigateway.UsagePlan49 name := acctest.RandString(10)50 resource.Test(t, resource.TestCase{51 PreCheck: func() { testAccPreCheck(t) },52 Providers: testAccProviders,53 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,54 Steps: []resource.TestStep{55 {56 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),57 Check: resource.ComposeTestCheckFunc(58 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),59 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),60 ),61 },62 {63 Config: testAccAWSApiGatewayUsagePlanDescriptionConfig(name),64 Check: resource.ComposeTestCheckFunc(65 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),66 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a description"),67 ),68 },69 {70 Config: testAccAWSApiGatewayUsagePlanDescriptionUpdatedConfig(name),71 Check: resource.ComposeTestCheckFunc(72 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a new description"),73 ),74 },75 {76 Config: testAccAWSApiGatewayUsagePlanDescriptionConfig(name),77 Check: resource.ComposeTestCheckFunc(78 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),79 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a description"),80 ),81 },82 {83 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),84 Check: resource.ComposeTestCheckFunc(85 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),86 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),87 ),88 },89 },90 })91}92func TestAccAWSAPIGatewayUsagePlan_productCode(t *testing.T) {93 var conf apigateway.UsagePlan94 name := acctest.RandString(10)95 resource.Test(t, resource.TestCase{96 PreCheck: func() { testAccPreCheck(t) },97 Providers: testAccProviders,98 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,99 Steps: []resource.TestStep{100 {101 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),102 Check: resource.ComposeTestCheckFunc(103 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),104 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", ""),105 ),106 },107 {108 Config: testAccAWSApiGatewayUsagePlanProductCodeConfig(name),109 Check: resource.ComposeTestCheckFunc(110 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),111 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE"),112 ),113 },114 {115 Config: testAccAWSApiGatewayUsagePlanProductCodeUpdatedConfig(name),116 Check: resource.ComposeTestCheckFunc(117 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE2"),118 ),119 },120 {121 Config: testAccAWSApiGatewayUsagePlanProductCodeConfig(name),122 Check: resource.ComposeTestCheckFunc(123 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),124 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE"),125 ),126 },127 {128 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),129 Check: resource.ComposeTestCheckFunc(130 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),131 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", ""),132 ),133 },134 },135 })136}137func TestAccAWSAPIGatewayUsagePlan_throttling(t *testing.T) {138 var conf apigateway.UsagePlan139 name := acctest.RandString(10)140 resource.Test(t, resource.TestCase{141 PreCheck: func() { testAccPreCheck(t) },142 Providers: testAccProviders,143 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,144 Steps: []resource.TestStep{145 {146 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),147 Check: resource.ComposeTestCheckFunc(148 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),149 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),150 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings"),151 ),152 },153 {154 Config: testAccAWSApiGatewayUsagePlanThrottlingConfig(name),155 Check: resource.ComposeTestCheckFunc(156 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),157 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),158 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.4173790118.burst_limit", "2"),159 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.4173790118.rate_limit", "5"),160 ),161 },162 {163 Config: testAccAWSApiGatewayUsagePlanThrottlingModifiedConfig(name),164 Check: resource.ComposeTestCheckFunc(165 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),166 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),167 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.1779463053.burst_limit", "3"),168 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.1779463053.rate_limit", "6"),169 ),170 },171 {172 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),173 Check: resource.ComposeTestCheckFunc(174 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),175 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),176 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings"),177 ),178 },179 },180 })181}182func TestAccAWSAPIGatewayUsagePlan_quota(t *testing.T) {183 var conf apigateway.UsagePlan184 name := acctest.RandString(10)185 resource.Test(t, resource.TestCase{186 PreCheck: func() { testAccPreCheck(t) },187 Providers: testAccProviders,188 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,189 Steps: []resource.TestStep{190 {191 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),192 Check: resource.ComposeTestCheckFunc(193 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),194 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),195 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings"),196 ),197 },198 {199 Config: testAccAWSApiGatewayUsagePlanQuotaConfig(name),200 Check: resource.ComposeTestCheckFunc(201 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),202 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),203 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.limit", "100"),204 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.offset", "6"),205 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.period", "WEEK"),206 ),207 },208 {209 Config: testAccAWSApiGatewayUsagePlanQuotaModifiedConfig(name),210 Check: resource.ComposeTestCheckFunc(211 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),212 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),213 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.limit", "200"),214 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.offset", "20"),215 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.period", "MONTH"),216 ),217 },218 {219 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),220 Check: resource.ComposeTestCheckFunc(221 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),222 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),223 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings"),224 ),225 },226 },227 })228}229func TestAccAWSAPIGatewayUsagePlan_apiStages(t *testing.T) {230 var conf apigateway.UsagePlan231 name := acctest.RandString(10)232 resource.Test(t, resource.TestCase{233 PreCheck: func() { testAccPreCheck(t) },234 Providers: testAccProviders,235 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,236 Steps: []resource.TestStep{237 // Create UsagePlan WITH Stages as the API calls are different238 // when creating or updating.239 {240 Config: testAccAWSApiGatewayUsagePlanApiStagesConfig(name),241 Check: resource.ComposeTestCheckFunc(242 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),243 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),244 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "test"),245 ),246 },247 // Handle api stages removal248 {249 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),250 Check: resource.ComposeTestCheckFunc(251 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),252 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),253 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "api_stages"),254 ),255 },256 // Handle api stages additions257 {258 Config: testAccAWSApiGatewayUsagePlanApiStagesConfig(name),259 Check: resource.ComposeTestCheckFunc(260 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),261 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),262 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "test"),263 ),264 },265 // Handle api stages updates266 {267 Config: testAccAWSApiGatewayUsagePlanApiStagesModifiedConfig(name),268 Check: resource.ComposeTestCheckFunc(269 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),270 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),271 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "foo"),272 ),273 },274 {275 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),276 Check: resource.ComposeTestCheckFunc(277 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),278 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),279 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "api_stages"),280 ),281 },282 },283 })284}285func testAccCheckAWSAPIGatewayUsagePlanExists(n string, res *apigateway.UsagePlan) resource.TestCheckFunc {286 return func(s *terraform.State) error {287 rs, ok := s.RootModule().Resources[n]288 if !ok {289 return fmt.Errorf("Not found: %s", n)290 }291 if rs.Primary.ID == "" {292 return fmt.Errorf("No API Gateway Usage Plan ID is set")293 }294 conn := testAccProvider.Meta().(*AWSClient).apigateway295 req := &apigateway.GetUsagePlanInput{296 UsagePlanId: aws.String(rs.Primary.ID),297 }298 up, err := conn.GetUsagePlan(req)299 if err != nil {300 return err301 }302 if *up.Id != rs.Primary.ID {303 return fmt.Errorf("APIGateway Usage Plan not found")304 }305 *res = *up306 return nil307 }308}309func testAccCheckAWSAPIGatewayUsagePlanDestroy(s *terraform.State) error {310 conn := testAccProvider.Meta().(*AWSClient).apigateway311 for _, rs := range s.RootModule().Resources {312 if rs.Type != "aws_api_gateway_usage_plan" {313 continue314 }315 req := &apigateway.GetUsagePlanInput{316 UsagePlanId: aws.String(s.RootModule().Resources["aws_api_gateway_rest_api.test"].Primary.ID),317 }318 describe, err := conn.GetUsagePlan(req)319 if err == nil {320 if describe.Id != nil && *describe.Id == rs.Primary.ID {321 return fmt.Errorf("API Gateway Usage Plan still exists")322 }323 }324 aws2err, ok := err.(awserr.Error)325 if !ok {326 return err327 }328 if aws2err.Code() != "NotFoundException" {329 return err330 }331 return nil332 }333 return nil334}335const testAccAWSAPIGatewayUsagePlanConfig = `336resource "aws_api_gateway_rest_api" "test" {337 name = "test"338}339resource "aws_api_gateway_resource" "test" {340 rest_api_id = "${aws_api_gateway_rest_api.test.id}"341 parent_id = "${aws_api_gateway_rest_api.test.root_resource_id}"342 path_part = "test"343}344resource "aws_api_gateway_method" "test" {345 rest_api_id = "${aws_api_gateway_rest_api.test.id}"346 resource_id = "${aws_api_gateway_resource.test.id}"347 http_method = "GET"348 authorization = "NONE"349}350resource "aws_api_gateway_method_response" "error" {351 rest_api_id = "${aws_api_gateway_rest_api.test.id}"352 resource_id = "${aws_api_gateway_resource.test.id}"353 http_method = "${aws_api_gateway_method.test.http_method}"354 status_code = "400"355}356resource "aws_api_gateway_integration" "test" {357 rest_api_id = "${aws_api_gateway_rest_api.test.id}"358 resource_id = "${aws_api_gateway_resource.test.id}"359 http_method = "${aws_api_gateway_method.test.http_method}"360 type = "HTTP"361 uri = "https://www.google.de"362 integration_http_method = "GET"363}364resource "aws_api_gateway_integration_response" "test" {365 rest_api_id = "${aws_api_gateway_rest_api.test.id}"366 resource_id = "${aws_api_gateway_resource.test.id}"367 http_method = "${aws_api_gateway_integration.test.http_method}"368 status_code = "${aws_api_gateway_method_response.error.status_code}"369}370resource "aws_api_gateway_deployment" "test" {371 depends_on = ["aws_api_gateway_integration.test"]372 rest_api_id = "${aws_api_gateway_rest_api.test.id}"373 stage_name = "test"374 description = "This is a test"375 variables = {376 "a" = "2"377 }378}379resource "aws_api_gateway_deployment" "foo" {380 depends_on = ["aws_api_gateway_integration.test"]381 rest_api_id = "${aws_api_gateway_rest_api.test.id}"382 stage_name = "foo"383 description = "This is a prod stage"384}385`386func testAccAWSApiGatewayUsagePlanBasicConfig(rName string) string {387 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`388resource "aws_api_gateway_usage_plan" "main" {389 name = "%s"390}391`, rName)392}393func testAccAWSApiGatewayUsagePlanDescriptionConfig(rName string) string {394 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`395resource "aws_api_gateway_usage_plan" "main" {396 name = "%s"397 description = "This is a description"398}399`, rName)400}401func testAccAWSApiGatewayUsagePlanDescriptionUpdatedConfig(rName string) string {402 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`403resource "aws_api_gateway_usage_plan" "main" {404 name = "%s"405 description = "This is a new description"406}407`, rName)408}409func testAccAWSApiGatewayUsagePlanProductCodeConfig(rName string) string {410 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`411resource "aws_api_gateway_usage_plan" "main" {412 name = "%s"413 product_code = "MYCODE"414}415`, rName)416}417func testAccAWSApiGatewayUsagePlanProductCodeUpdatedConfig(rName string) string {418 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`419resource "aws_api_gateway_usage_plan" "main" {420 name = "%s"421 product_code = "MYCODE2"422}423`, rName)424}425func testAccAWSApiGatewayUsagePlanBasicUpdatedConfig(rName string) string {426 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`427resource "aws_api_gateway_usage_plan" "main" {428 name = "%s"429}430`, rName)431}432func testAccAWSApiGatewayUsagePlanThrottlingConfig(rName string) string {433 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`434resource "aws_api_gateway_usage_plan" "main" {435 name = "%s"436 throttle_settings {437 burst_limit = 2438 rate_limit = 5439 }440}441`, rName)442}443func testAccAWSApiGatewayUsagePlanThrottlingModifiedConfig(rName string) string {444 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`445resource "aws_api_gateway_usage_plan" "main" {446 name = "%s"447 throttle_settings {448 burst_limit = 3449 rate_limit = 6450 }451}452`, rName)453}454func testAccAWSApiGatewayUsagePlanQuotaConfig(rName string) string {455 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`456resource "aws_api_gateway_usage_plan" "main" {457 name = "%s"458 quota_settings {459 limit = 100460 offset = 6461 period = "WEEK"462 }463}464`, rName)465}466func testAccAWSApiGatewayUsagePlanQuotaModifiedConfig(rName string) string {467 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`468resource "aws_api_gateway_usage_plan" "main" {469 name = "%s"470 quota_settings {471 limit = 200472 offset = 20473 period = "MONTH"474 }475}476`, rName)477}478func testAccAWSApiGatewayUsagePlanApiStagesConfig(rName string) string {479 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`480resource "aws_api_gateway_usage_plan" "main" {481 name = "%s"482 api_stages {483 api_id = "${aws_api_gateway_rest_api.test.id}"484 stage = "${aws_api_gateway_deployment.test.stage_name}"485 }486}487`, rName)488}489func testAccAWSApiGatewayUsagePlanApiStagesModifiedConfig(rName string) string {490 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`491resource "aws_api_gateway_usage_plan" "main" {492 name = "%s"493 api_stages {494 api_id = "${aws_api_gateway_rest_api.test.id}"495 stage = "${aws_api_gateway_deployment.foo.stage_name}"496 }497}498`, rName)499}...

Full Screen

Full Screen

resource_aws_api_gateway_usage_plan_key_test.go

Source:resource_aws_api_gateway_usage_plan_key_test.go Github

copy

Full Screen

...21 Steps: []resource.TestStep{22 {23 Config: testAccAWSApiGatewayUsagePlanKeyBasicConfig(name),24 Check: resource.ComposeTestCheckFunc(25 testAccCheckAWSAPIGatewayUsagePlanKeyExists("aws_api_gateway_usage_plan_key.main", &conf),26 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "key_type", "API_KEY"),27 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_id"),28 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_type"),29 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "usage_plan_id"),30 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "name"),31 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "value", ""),32 ),33 },34 {35 Config: testAccAWSApiGatewayUsagePlanKeyBasicUpdatedConfig(updatedName),36 Check: resource.ComposeTestCheckFunc(37 testAccCheckAWSAPIGatewayUsagePlanKeyExists("aws_api_gateway_usage_plan_key.main", &conf),38 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "key_type", "API_KEY"),39 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_id"),40 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_type"),41 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "usage_plan_id"),42 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "name"),43 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "value", ""),44 ),45 },46 {47 Config: testAccAWSApiGatewayUsagePlanKeyBasicConfig(name),48 Check: resource.ComposeTestCheckFunc(49 testAccCheckAWSAPIGatewayUsagePlanKeyExists("aws_api_gateway_usage_plan_key.main", &conf),50 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "key_type", "API_KEY"),51 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_id"),52 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "key_type"),53 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "usage_plan_id"),54 resource.TestCheckResourceAttrSet("aws_api_gateway_usage_plan_key.main", "name"),55 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan_key.main", "value", ""),56 ),57 },58 },59 })60}61func testAccCheckAWSAPIGatewayUsagePlanKeyExists(n string, res *apigateway.UsagePlanKey) resource.TestCheckFunc {62 return func(s *terraform.State) error {63 rs, ok := s.RootModule().Resources[n]64 if !ok {65 return fmt.Errorf("Not found: %s", n)66 }67 if rs.Primary.ID == "" {68 return fmt.Errorf("No API Gateway Usage Plan Key ID is set")69 }70 conn := testAccProvider.Meta().(*AWSClient).apigateway71 req := &apigateway.GetUsagePlanKeyInput{72 UsagePlanId: aws.String(rs.Primary.Attributes["usage_plan_id"]),73 KeyId: aws.String(rs.Primary.Attributes["key_id"]),74 }75 up, err := conn.GetUsagePlanKey(req)76 if err != nil {77 return err78 }79 log.Printf("[DEBUG] Reading API Gateway Usage Plan Key: %#v", up)80 if *up.Id != rs.Primary.ID {81 return fmt.Errorf("API Gateway Usage Plan Key not found")82 }83 *res = *up84 return nil85 }86}87func testAccCheckAWSAPIGatewayUsagePlanKeyDestroy(s *terraform.State) error {88 conn := testAccProvider.Meta().(*AWSClient).apigateway89 for _, rs := range s.RootModule().Resources {90 if rs.Type != "aws_api_gateway_usage_plan_key" {91 continue92 }93 req := &apigateway.GetUsagePlanKeyInput{94 UsagePlanId: aws.String(rs.Primary.ID),95 KeyId: aws.String(rs.Primary.Attributes["key_id"]),96 }97 describe, err := conn.GetUsagePlanKey(req)98 if err == nil {99 if describe.Id != nil && *describe.Id == rs.Primary.ID {100 return fmt.Errorf("API Gateway Usage Plan Key still exists")101 }102 }103 aws2err, ok := err.(awserr.Error)104 if !ok {105 return err106 }107 if aws2err.Code() != "NotFoundException" {108 return err109 }110 return nil111 }112 return nil113}114const testAccAWSAPIGatewayUsagePlanKeyConfig = `115resource "aws_api_gateway_rest_api" "test" {116 name = "test"117}118resource "aws_api_gateway_resource" "test" {119 rest_api_id = "${aws_api_gateway_rest_api.test.id}"120 parent_id = "${aws_api_gateway_rest_api.test.root_resource_id}"121 path_part = "test"122}123resource "aws_api_gateway_method" "test" {124 rest_api_id = "${aws_api_gateway_rest_api.test.id}"125 resource_id = "${aws_api_gateway_resource.test.id}"126 http_method = "GET"127 authorization = "NONE"128}129resource "aws_api_gateway_method_response" "error" {130 rest_api_id = "${aws_api_gateway_rest_api.test.id}"131 resource_id = "${aws_api_gateway_resource.test.id}"132 http_method = "${aws_api_gateway_method.test.http_method}"133 status_code = "400"134}135resource "aws_api_gateway_integration" "test" {136 rest_api_id = "${aws_api_gateway_rest_api.test.id}"137 resource_id = "${aws_api_gateway_resource.test.id}"138 http_method = "${aws_api_gateway_method.test.http_method}"139 type = "HTTP"140 uri = "https://www.google.de"141 integration_http_method = "GET"142}143resource "aws_api_gateway_integration_response" "test" {144 rest_api_id = "${aws_api_gateway_rest_api.test.id}"145 resource_id = "${aws_api_gateway_resource.test.id}"146 http_method = "${aws_api_gateway_integration.test.http_method}"147 status_code = "${aws_api_gateway_method_response.error.status_code}"148}149resource "aws_api_gateway_deployment" "test" {150 depends_on = ["aws_api_gateway_integration.test"]151 rest_api_id = "${aws_api_gateway_rest_api.test.id}"152 stage_name = "test"153 description = "This is a test"154 variables = {155 "a" = "2"156 }157}158resource "aws_api_gateway_deployment" "foo" {159 depends_on = ["aws_api_gateway_integration.test"]160 rest_api_id = "${aws_api_gateway_rest_api.test.id}"161 stage_name = "foo"162 description = "This is a prod stage"163}164resource "aws_api_gateway_usage_plan" "main" {165 name = "%s"166}167resource "aws_api_gateway_usage_plan" "secondary" {168 name = "secondary-%s"169}170resource "aws_api_gateway_api_key" "mykey" {171 name = "demo-%s"172 stage_key {173 rest_api_id = "${aws_api_gateway_rest_api.test.id}"174 stage_name = "${aws_api_gateway_deployment.foo.stage_name}"175 }176}177`178func testAccAWSApiGatewayUsagePlanKeyBasicConfig(rName string) string {179 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanKeyConfig+`180resource "aws_api_gateway_usage_plan_key" "main" {181 key_id = "${aws_api_gateway_api_key.mykey.id}"182 key_type = "API_KEY"183 usage_plan_id = "${aws_api_gateway_usage_plan.main.id}"184}185`, rName, rName, rName)186}187func testAccAWSApiGatewayUsagePlanKeyBasicUpdatedConfig(rName string) string {188 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanKeyConfig+`189resource "aws_api_gateway_usage_plan_key" "main" {190 key_id = "${aws_api_gateway_api_key.mykey.id}"191 key_type = "API_KEY"192 usage_plan_id = "${aws_api_gateway_usage_plan.secondary.id}"193}194`, rName, rName, rName)195}...

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, 世界")4}5import "fmt"6func main() {7 fmt.Println("Hello, 世界")8}9import "fmt"10func main() {11 fmt.Println("Hello, 世界")12}13import "fmt"14func main() {15 fmt.Println("Hello, 世界")16}17import "fmt"18func main() {19 fmt.Println("Hello, 世界")20}21import "fmt"22func main() {23 fmt.Println("Hello, 世界")24}25import "fmt"26func main() {27 fmt.Println("Hello, 世界")28}29import "fmt"30func main() {31 fmt.Println("Hello, 世界")32}33import "fmt"34func main() {35 fmt.Println("Hello, 世界")36}37import "fmt"38func main() {39 fmt.Println("Hello, 世界")40}41import "fmt"42func main() {43 fmt.Println("Hello, 世界")44}45import "fmt"46func main() {47 fmt.Println("Hello, 世界")48}49import "fmt"50func main() {51 fmt.Println("Hello,

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import (2type person struct {3}4func (p person) usage() {5 fmt.Println(p.name, "is", p.age, "years old")6}7func main() {8 p := person{name: "bob", age: 20}9 p.usage()10}11import (12type person struct {13}14func (p *person) usage() {15 fmt.Println(p.name, "is", p.age, "years old")16}17func main() {18 p := person{name: "bob", age: 20}19 p.usage()20}21import (22type person struct {23}24func (p *person) usage() {25 fmt.Println(p.name, "is", p.age, "years old")26}27func main() {28 p := &person{name: "bob", age: 20}29 p.usage()30}31import (32type person struct {33}34func (p *person) usage() {35 fmt.Println(p.name, "is", p.age, "years old")36}37func main() {38 p := &person{name: "bob", age: 20}39 p.usage()40}41import (42type person struct {43}44func (p *person) usage() {45 fmt.Println(p.name, "is", p.age, "years old")46}47func main() {48 p := &person{name: "bob", age: 20}49 p.usage()50}

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, World!")4}5import "fmt"6func main() {7 fmt.Println("Hello, World!")8}9import "fmt"10func main() {11 fmt.Println("Hello, World!")12}13import "fmt"14func main() {15 fmt.Println("Hello, World!")16}17import "fmt"18func main() {19 fmt.Println("Hello, World!")20}21import "fmt"22func main() {23 fmt.Println("Hello, World!")24}25import "fmt"26func main() {27 fmt.Println("Hello, World!")28}29import "fmt"30func main() {31 fmt.Println("Hello, World!")32}33import "fmt"34func main() {35 fmt.Println("Hello, World!")36}37import "fmt"38func main() {39 fmt.Println("Hello, World!")40}41import "fmt"42func main() {43 fmt.Println("Hello, World!")44}45import "fmt"46func main() {47 fmt.Println("Hello, World!")48}49import "fmt"50func main() {51 fmt.Println("Hello, World!")52}53import "fmt"54func main() {55 fmt.Println("Hello, World!")56}57import "fmt"58func main() {59 fmt.Println("Hello, World!")60}61import "fmt"62func main() {63 fmt.Println("Hello, World!")64}65import "fmt"66func main() {67 fmt.Println("Hello, World!")68}69import "fmt"70func main() {71 fmt.Println("Hello, World!")72}73import "fmt"74func main() {

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import (2func main() {3}4import (5func main() {6}7import (8func main() {9}10import (11func main() {12}13import (14func main() {15}16import (17func main() {18}19import (20func main() {21}22import (23func main() {24}25import (26func main() {27}28import (29func main() {30}31import (32func main() {33}34import (35func main() {36}37import (

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(usage.GetUsage())4}5func GetUsage() string {6}7import (8func main() {9 fmt.Println(usage.GetUsage())10}11func GetUsage() string {12}13import (14func main() {15 fmt.Println(usage.GetUsage())16}17func GetUsage() string {18}19import (20func main() {21 fmt.Println(usage.GetUsage())22}23func GetUsage() string {24}25import (26func main() {27 fmt.Println(usage.GetUsage())28}29func GetUsage() string {30}31import (32func main() {33 fmt.Println(usage.GetUsage())34}35func GetUsage() string {36}37import (38func main() {39 fmt.Println(usage.GetUsage())40}41func GetUsage() string {42}43import (44func main() {45 fmt.Println(usage.GetUsage())46}47func GetUsage() string {48}49import (50func main() {51 fmt.Println(usage.GetUsage())52}53func GetUsage() string {54}55import (56func main() {57 fmt.Println(usage.GetUsage())58}59func GetUsage() string {60}61import (62func main() {63 fmt.Println(usage.GetUsage())64}

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1func main() {2 usage()3}4import "fmt"5func usage() {6 fmt.Println("Usage")7}8import "fmt"9func main() {10 usage()11}12func usage() {13 fmt.Println("Usage")14}15The import keyword can be used to import any package that is defined in the GOPATH. If the package is not defined in the GOPATH, then the compiler will complain that the package does not exist. To import the package, we can use the following syntax:16import "package_name"17The package_name is the name of the package that we want to import. We can use the import keyword to import multiple packages. To import multiple packages, we can use the following syntax:18import (19The import keyword can be used to import any package that is defined in the GOPATH. If the package is not defined in the GOPATH, then the compiler will complain that the package does not exist. To import the package, we can use the following syntax:20import "package_name"21The package_name is the name of the package that we want to import. We can use the import keyword to import multiple packages. To import multiple packages, we can use the following syntax:22import (23The package_name_1 , package_name_2 and package_name_3 are the names of the packages that we want to import. The import keyword must

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Welcome to GoLang")4 usage()5}6func usage() {7 fmt.Println("Usage of GoLang")8}9import (10func main() {11 fmt.Println(stringutil.Reverse("Hello, world!"))12}13Example 3: Calling a method from another package using import alias14import (15func main() {16 fmt.Println(alias.Reverse("Hello, world!"))17}18Example 4: Calling a method from another package using import alias19import (20func main() {21 fmt.Println(alias.Reverse("Hello, world!"))22}23Example 5: Calling a method from another package using import alias24import (25func main() {26 fmt.Println(alias.Reverse("Hello, world!"))27}28Example 6: Calling a method from another package using import alias29import (30func main() {31 fmt.Println(alias.Reverse("Hello, world!"))32}33Example 7: Calling a method from another package using import alias34import (35func main() {36 fmt.Println(alias.Reverse("Hello, world!

Full Screen

Full Screen

usage

Using AI Code Generation

copy

Full Screen

1func main() {2 fmt.Println("Hello, World!")3 usage()4}5func usage() {6 fmt.Println("Usage: go run 1.go")7}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful