Class: BulkImports::CreateService
- Inherits:
-
Object
- Object
- BulkImports::CreateService
- Defined in:
- app/services/bulk_imports/create_service.rb
Constant Summary collapse
- ENTITY_TYPES_MAPPING =
{ 'group_entity' => 'groups', 'project_entity' => 'projects' }.freeze
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, params, credentials) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(current_user, params, credentials) ⇒ CreateService
Returns a new instance of CreateService.
38 39 40 41 42 |
# File 'app/services/bulk_imports/create_service.rb', line 38 def initialize(current_user, params, credentials) @current_user = current_user @params = params @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
36 37 38 |
# File 'app/services/bulk_imports/create_service.rb', line 36 def credentials @credentials end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
36 37 38 |
# File 'app/services/bulk_imports/create_service.rb', line 36 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
36 37 38 |
# File 'app/services/bulk_imports/create_service.rb', line 36 def params @params end |
Instance Method Details
#execute ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/services/bulk_imports/create_service.rb', line 44 def execute validate! bulk_import = create_bulk_import Gitlab::Tracking.event( self.class.name, 'create', label: 'bulk_import_group', extra: { source_equals_destination: source_equals_destination? } ) BulkImportWorker.perform_async(bulk_import.id) ServiceResponse.success(payload: bulk_import) rescue ActiveRecord::RecordInvalid, BulkImports::Error, BulkImports::NetworkError => e ServiceResponse.error( message: e., http_status: :unprocessable_entity ) end |