Class: HubSpotSDK::Resources::Cms::SourceCode

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/cms/source_code.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SourceCode

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SourceCode.

Parameters:



236
237
238
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 236

def initialize(client:)
  @client = client
end

Instance Method Details

#create(path, environment:, file: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::AssetFileMetadata

Deprecated.

Creates a file at the specified path in the specified environment. Accepts multipart/form-data content type. Throws an error if a file already exists at the specified path.

Parameters:

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 26

def create(path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeCreateParams.dump_request(params)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["cms/source-code/2026-03/%1$s/content/%2$s", environment, path],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: HubSpotSDK::Cms::AssetFileMetadata,
    options: options
  )
end

#delete(path, environment:, request_options: {}) ⇒ nil

Deletes the file at the specified path in the specified environment.

Parameters:

Returns:

  • (nil)

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 53

def delete(path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeDeleteParams.dump_request(params)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["cms/source-code/2026-03/%1$s/content/%2$s", environment, path],
    model: NilClass,
    options: options
  )
end

#extract_async(path:, request_options: {}) ⇒ HubSpotSDK::Models::TaskLocator

Extract a zip file in the developer file system. Extraction status can be checked with the ‘/extract/async/tasks/taskId/status` endpoint below.

Parameters:

  • path (String)

    The file system location where the zip file is to be extracted.

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 79

def extract_async(params)
  parsed, options = HubSpotSDK::Cms::SourceCodeExtractAsyncParams.dump_request(params)
  @client.request(
    method: :post,
    path: "cms/source-code/2026-03/extract/async",
    body: parsed,
    model: HubSpotSDK::TaskLocator,
    options: options
  )
end

#get(path, environment:, request_options: {}) ⇒ StringIO

Downloads the byte contents of the file at the specified path in the specified environment.

Parameters:

Returns:

  • (StringIO)

See Also:



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 102

def get(path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeGetParams.dump_request(params)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["cms/source-code/2026-03/%1$s/content/%2$s", environment, path],
    headers: {"accept" => "*/*"},
    model: StringIO,
    options: options
  )
end

#get_extraction_status(task_id, request_options: {}) ⇒ HubSpotSDK::Models::ActionResponse

Get the status of an extraction by the ‘taskId` returned from the initial `extract/async` request.

Parameters:

Returns:

See Also:



128
129
130
131
132
133
134
135
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 128

def get_extraction_status(task_id, params = {})
  @client.request(
    method: :get,
    path: ["cms/source-code/2026-03/extract/async/tasks/%1$s/status", task_id],
    model: HubSpotSDK::ActionResponse,
    options: params[:request_options]
  )
end

#get_metadata(path, environment:, properties: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::AssetFileMetadata

Gets the metadata object for the file at the specified path in the specified environment.

Parameters:

  • path (String)

    Path param

  • environment (String)

    Path param

  • properties (String)

    Query param

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 153

def (path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeGetMetadataParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["cms/source-code/2026-03/%1$s/metadata/%2$s", environment, path],
    query: query,
    model: HubSpotSDK::Cms::AssetFileMetadata,
    options: options
  )
end

#upsert(path, environment:, file: nil, request_options: {}) ⇒ HubSpotSDK::Models::Cms::AssetFileMetadata

Upserts a file at the specified path in the specified environment. Accepts multipart/form-data content type.

Parameters:

Returns:

See Also:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 185

def upsert(path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeUpsertParams.dump_request(params)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["cms/source-code/2026-03/%1$s/content/%2$s", environment, path],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: HubSpotSDK::Cms::AssetFileMetadata,
    options: options
  )
end

#validate(path, environment:, file: nil, request_options: {}) ⇒ StringIO

Validates the file contents passed to the endpoint given a specified path and environment. Accepts multipart/form-data content type.

Parameters:

Returns:

  • (StringIO)

See Also:



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/hubspot_sdk/resources/cms/source_code.rb', line 217

def validate(path, params)
  parsed, options = HubSpotSDK::Cms::SourceCodeValidateParams.dump_request(params)
  environment =
    parsed.delete(:environment) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["cms/source-code/2026-03/%1$s/validate/%2$s", environment, path],
    headers: {"content-type" => "multipart/form-data", "accept" => "*/*"},
    body: parsed,
    model: StringIO,
    options: options
  )
end