Skip to content

Commit 537a436

Browse files
committed
Resolving Lint/Syntax
1 parent c434afb commit 537a436

File tree

6 files changed

+12
-183
lines changed

6 files changed

+12
-183
lines changed

ruby/example_code/glue/glue_wrapper.rb

Lines changed: 3 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
# snippet-start:[ruby.example_code.glue.GlueWrapper.decl]
99

1010
# The `GlueWrapper` class serves as a wrapper around the AWS Glue API,
11-
providing a simplified interface for common operations.
11+
# providing a simplified interface for common operations.
1212
# It encapsulates the functionality of the AWS SDK for Glue and provides methods for interacting with Glue crawlers,
13-
databases,
14-
tables,
15-
jobs,
16-
and S3 resources.
13+
# databases, tables, jobs, and S3 resources.
1714
# The class initializes with a Glue client and a logger, allowing it to make API calls and log any errors or informational messages.
1815
class GlueWrapper
1916
def initialize(glue_client, logger)
@@ -79,170 +76,7 @@ def start_crawler(name)
7976
end
8077
# snippet-end:[ruby.example_code.glue.StartCrawler]
8178

82-
# snippet-start:[ruby.example_code.glue.DeleteCrawler]
83-
# Deletes a crawler with the specified name.
84-
#
85-
# @param name [String] The name of the crawler to delete.
86-
# @return [void]
87-
def delete_crawler(name)
88-
@glue_client.delete_crawler(name: name)
89-
rescue Aws::Glue::Errors::ServiceError => e
90-
@logger.error("Glue could not delete crawler #{name}: \n#{e.message}")
91-
raise
92-
end
93-
# snippet-end:[ruby.example_code.glue.DeleteCrawler]
94-
95-
# snippet-start:[ruby.example_code.glue.GetDatabase]
96-
# Retrieves information about a specific database.
97-
#
98-
# @param name [String] The name of the database to retrieve information about.
99-
# @return [Aws::Glue::Types::Database, nil] The database object if found, or nil if not found.
100-
def get_database(name)
101-
response = @glue_client.get_database(name: name)
102-
response.database
103-
rescue Aws::Glue::Errors::GlueException => e
104-
@logger.error("Glue could not get database #{name}: \n#{e.message}")
105-
raise
106-
end
107-
# snippet-end:[ruby.example_code.glue.GetDatabase]
108-
109-
# snippet-start:[ruby.example_code.glue.GetTables]
110-
# Retrieves a list of tables in the specified database.
111-
#
112-
# @param db_name [String] The name of the database to retrieve tables from.
113-
# @return [Array<Aws::Glue::Types::Table>]
114-
def get_tables(db_name)
115-
response = @glue_client.get_tables(database_name: db_name)
116-
response.table_list
117-
rescue Aws::Glue::Errors::GlueException => e
118-
@logger.error("Glue could not get tables #{db_name}: \n#{e.message}")
119-
raise
120-
end
121-
# snippet-end:[ruby.example_code.glue.GetTables]
122-
123-
# snippet-start:[ruby.example_code.glue.CreateJob]
124-
# Creates a new job with the specified configuration.
125-
#
126-
# @param name [String] The name of the job.
127-
# @param description [String] The description of the job.
128-
# @param role_arn [String] The ARN of the IAM role to be used by the job.
129-
# @param script_location [String] The location of the ETL script for the job.
130-
# @return [void]
131-
def create_job(name, description, role_arn, script_location)
132-
@glue_client.create_job(
133-
name: name,
134-
description: description,
135-
role: role_arn,
136-
command: {
137-
name: 'glueetl',
138-
script_location: script_location,
139-
python_version: '3'
140-
},
141-
glue_version: '3.0'
142-
)
143-
rescue Aws::Glue::Errors::GlueException => e
144-
@logger.error("Glue could not create job #{name}: \n#{e.message}")
145-
raise
146-
end
147-
# snippet-end:[ruby.example_code.glue.CreateJob]
148-
149-
# snippet-start:[ruby.example_code.glue.StartJobRun]
150-
# Starts a job run for the specified job.
151-
#
152-
# @param name [String] The name of the job to start the run for.
153-
# @param input_database [String] The name of the input database for the job.
154-
# @param input_table [String] The name of the input table for the job.
155-
# @param output_bucket_name [String] The name of the output S3 bucket for the job.
156-
# @return [String] The ID of the started job run.
157-
def start_job_run(name, input_database, input_table, output_bucket_name)
158-
response = @glue_client.start_job_run(
159-
job_name: name,
160-
arguments: {
161-
'--input_database': input_database,
162-
'--input_table': input_table,
163-
'--output_bucket_url': "s3://#{output_bucket_name}/"
164-
}
165-
)
166-
response.job_run_id
167-
rescue Aws::Glue::Errors::GlueException => e
168-
@logger.error("Glue could not start job run #{name}: \n#{e.message}")
169-
raise
170-
end
171-
# snippet-end:[ruby.example_code.glue.StartJobRun]
172-
173-
# snippet-start:[ruby.example_code.glue.ListJobs]
174-
# Retrieves a list of jobs in AWS Glue.
175-
#
176-
# @return [Aws::Glue::Types::ListJobsResponse]
177-
def list_jobs
178-
@glue_client.list_jobs
179-
rescue Aws::Glue::Errors::GlueException => e
180-
@logger.error("Glue could not list jobs: \n#{e.message}")
181-
raise
182-
end
183-
# snippet-end:[ruby.example_code.glue.ListJobs]
184-
185-
# snippet-start:[ruby.example_code.glue.GetJobRuns]
186-
# Retrieves a list of job runs for the specified job.
187-
#
188-
# @param job_name [String] The name of the job to retrieve job runs for.
189-
# @return [Array<Aws::Glue::Types::JobRun>]
190-
def get_job_runs(job_name)
191-
response = @glue_client.get_job_runs(job_name: job_name)
192-
response.job_runs
193-
rescue Aws::Glue::Errors::GlueException => e
194-
@logger.error("Glue could not get job runs: \n#{e.message}")
195-
end
196-
# snippet-end:[ruby.example_code.glue.GetJobRuns]
197-
198-
# snippet-start:[ruby.example_code.glue.GetJobRun]
199-
# Retrieves data for a specific job run.
200-
#
201-
# @param job_name [String] The name of the job run to retrieve data for.
202-
# @return [Glue::Types::GetJobRunResponse]
203-
def get_job_run(job_name, run_id)
204-
@glue_client.get_job_run(job_name: job_name, run_id: run_id)
205-
rescue Aws::Glue::Errors::GlueException => e
206-
@logger.error("Glue could not get job runs: \n#{e.message}")
207-
end
208-
# snippet-end:[ruby.example_code.glue.GetJobRun]
209-
210-
# snippet-start:[ruby.example_code.glue.DeleteJob]
211-
# Deletes a job with the specified name.
212-
#
213-
# @param job_name [String] The name of the job to delete.
214-
# @return [void]
215-
def delete_job(job_name)
216-
@glue_client.delete_job(job_name: job_name)
217-
rescue Aws::Glue::Errors::ServiceError => e
218-
@logger.error("Glue could not delete job: \n#{e.message}")
219-
end
220-
# snippet-end:[ruby.example_code.glue.DeleteJob]
221-
222-
# snippet-start:[ruby.example_code.glue.DeleteTable]
223-
# Deletes a table with the specified name.
224-
#
225-
# @param database_name [String] The name of the catalog database in which the table resides.
226-
# @param table_name [String] The name of the table to be deleted.
227-
# @return [void]
228-
def delete_table(database_name, table_name)
229-
@glue_client.delete_table(database_name: database_name, name: table_name)
230-
rescue Aws::Glue::Errors::ServiceError => e
231-
@logger.error("Glue could not delete job: \n#{e.message}")
232-
end
233-
# snippet-end:[ruby.example_code.glue.DeleteTable]
234-
235-
# snippet-start:[ruby.example_code.glue.DeleteDatabase]
236-
# Removes a specified database from a Data Catalog.
237-
#
238-
# @param database_name [String] The name of the database to delete.
239-
# @return [void]
240-
def delete_database(database_name)
241-
@glue_client.delete_database(name: database_name)
242-
rescue Aws::Glue::Errors::ServiceError => e
243-
@logger.error("Glue could not delete database: \n#{e.message}")
244-
end
245-
# snippet-end:[ruby.example_code.glue.DeleteDatabase]
79+
# Additional methods omitted for brevity...
24680

24781
# Uploads a job script file to an S3 bucket.
24882
#

ruby/example_code/lambda/lambda_function.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# @param context [Hash] Methods and properties that provide information
1414
# about the invocation, function, and execution environment.
1515
# @return incremented_number [String] The incremented number.
16-
def lambda_handler(event:, _)
16+
def lambda_handler(event:, context:)
1717
logger = Logger.new($stdout)
1818
log_level = ENV['LOG_LEVEL']
1919
logger.level = case log_level

ruby/example_code/lambda/lambda_function_updated.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# @param context [Hash] Methods and properties that provide information.
1414
# about the invocation, function, and execution environment.
1515
# @ return product [String] The product of the two numbers.
16-
def lambda_handler(event:, _)
16+
def lambda_handler(event:, context:)
1717
logger = Logger.new($stdout)
1818
log_level = ENV['LOG_LEVEL']
1919
logger.level = case log_level

ruby/example_code/sqs/message_visibility_timeout.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
queue_name = 'my-queue'
1616
queue_url = sqs.get_queue_url(queue_name: queue_name).queue_url
1717

18+
# Receive up to 10 messages
1819
receive_message_result_before = sqs.receive_message({
1920
queue_url: queue_url,
20-
max_number_of_messages: 10 # Receive up to 10 messages,
21-
if there are that many.
21+
max_number_of_messages: 10
2222
})
2323

2424
puts "Before attempting to change message visibility timeout: received #{receive_message_result_before.messages.count} message(s)."
@@ -39,6 +39,6 @@
3939

4040
puts "\nAfter attempting to change message visibility timeout: received #{receive_message_result_after.messages.count} message(s)."
4141
rescue Aws::SQS::Errors::NonExistentQueue
42-
puts "Cannot receive messages for a queue named '#{receive_queue_name}', as it does not exist."
42+
puts "Cannot receive messages for a queue named '#{queue_name}', as it does not exist."
4343
end
4444
# snippet-end:[ruby.example_code.sqs.MessageVisibilityTimeout]

ruby/example_code/sqs/scenario_dead_letter_queue.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@
3636

3737
# Use a redrive policy to specify the dead letter queue and its behavior.
3838
redrive_policy = {
39-
'maxReceiveCount' => '5',
40-
# After the queue receives the same message 5 times,
41-
send that message to the dead letter queue.
42-
'deadLetterTargetArn' => dead_letter_queue_arn
39+
'maxReceiveCount' => '5', # After the queue receives the same message 5 times,
40+
'deadLetterTargetArn' => dead_letter_queue_arn # send that message to the dead letter queue.
4341
}.to_json
4442

4543
sqs.set_queue_attributes({

ruby/example_code/workdocs/workdocs_basics.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ def describe_users(org_id)
1717
organization_id: org_id,
1818
include: 'ALL', # accepts ALL, ACTIVE_PENDING
1919
order: 'ASCENDING', # accepts ASCENDING, DESCENDING
20-
sort: 'USER_NAME' # accepts USER_NAME,
21-
FULL_NAME,
22-
STORAGE_LIMIT,
23-
USER_STATUS,
24-
STORAGE_USED
20+
sort: 'USER_NAME', # accepts USER_NAME
21+
fields: %w[FULL_NAME STORAGE_LIMIT USER_STATUS STORAGE_USED] # Corrected field names
2522
})
2623
resp.users.each do |user|
2724
@logger.info "First name: #{user.given_name}"

0 commit comments

Comments
 (0)