Method: Umbreo::Models::Blueprint#create!

Defined in:
lib/umbreo/models/blueprint.rb

#create!(attributes = {}) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/umbreo/models/blueprint.rb', line 112

def create!(attributes = {})
	@create_name        = attributes[:name]
	@create_description = attributes[:description]
	@create_os          = attributes[:os]
	@create_system      = attributes[:system]
	@create_profiles    = attributes[:profiles]

	create_validation!

	if valid?
		Helpers::ErrorException.rescue do
			data = Typhoeus.post(
            "#{@endpoint}/api/v1/blueprints",
            body: {
              authenticate_token:   @api_key,
              email:                @email,
              user_role: {           
                name:               @create_name,
                description:        @create_description,
                os:                 @create_os,
                umbreo_profile_ids: @create_profiles
              }
            }
          )

			@data = JSON.parse data.response_body

			if @data["success"]
				Helpers::AlertMessage.show_success_message(@data['message'])
			else
				Helpers::AlertMessage.show_error_message(@data['message'])
			end
		end
	else
		Helpers::AlertMessage.show_error_message(error)
	end
end