-
Notifications
You must be signed in to change notification settings - Fork 74
Google cloud storage added in source #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google cloud storage added in source #650
Conversation
…o feature/new-source-google-cloud-storage
…o feature/new-source-google-cloud-storage
Co-authored-by: codiumai-pr-agent-pro[bot] <151058649+codiumai-pr-agent-pro[bot]@users.noreply.github.com> Co-authored-by: sangkum <sangit.kumar@squared.ai>
… client implemented
…h the sources list - 400 error resolved
@developerJai could you please split the PR for Google Cloud Storage into separate ones for source and destination? |
storage = Google::Cloud::Storage.new( | ||
project_id: project_id, | ||
credentials: { | ||
type: "service_account", | ||
project_id: project_id, | ||
private_key: formatted_key, | ||
client_email: client_email | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@developerJai please move this to a separate method and call it to avoid duplication.
# Validate required parameters | ||
missing_params = [] | ||
missing_params << "project_id" if project_id.nil? || project_id.strip.empty? | ||
missing_params << "client_email" if client_email.nil? || client_email.strip.empty? | ||
missing_params << "private_key" if private_key.nil? || private_key.strip.empty? | ||
missing_params << "bucket" if bucket.nil? || bucket.strip.empty? | ||
|
||
if missing_params.any? | ||
return ConnectionStatus.new( | ||
status: ConnectionStatusType["failed"], | ||
message: "Missing required parameters: #{missing_params.join(', ')}" | ||
).to_multiwoven_message | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@developerJai the empty validation is not required, as the JSON schema already validates these fields.
end | ||
|
||
begin | ||
require 'google/cloud/storage' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@developerJai this import not required
bucket_obj = storage.bucket(bucket) | ||
|
||
# Prepare the path prefix | ||
prefix = path.start_with?("/") ? path[1..-1] : path | ||
|
||
# List files in the bucket with the given prefix | ||
files = bucket_obj.files(prefix: prefix) | ||
|
||
# Filter files by file type | ||
files = files.select { |file| file.name.end_with?(".#{file_type}") } | ||
|
||
if files.empty? | ||
return Catalog.new( | ||
streams: [] | ||
).to_multiwoven_message | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@developerJai please move the file validation inside the check_connection method. The discover method should only handle returning the catalog.
…nd successfully created a model
Google Cloud Storage source integration implemented