Skip to content

Commit 504ebbf

Browse files
Merge pull request #450 from HubSpot/feature/codegenCmsAuditLogsAndDomains
Codegen: CMS Audit Logs and Domains
2 parents a625709 + fd1cc9b commit 504ebbf

25 files changed

Lines changed: 414 additions & 255 deletions

codegen/Cms/AuditLogs/Api/AuditLogsApi.php

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -83,13 +83,13 @@ class AuditLogsApi
8383
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
8484
*/
8585
public function __construct(
86-
ClientInterface $client = null,
87-
Configuration $config = null,
88-
HeaderSelector $selector = null,
89-
$hostIndex = 0
86+
?ClientInterface $client = null,
87+
?Configuration $config = null,
88+
?HeaderSelector $selector = null,
89+
int $hostIndex = 0
9090
) {
9191
$this->client = $client ?: new Client();
92-
$this->config = $config ?: new Configuration();
92+
$this->config = $config ?: Configuration::getDefaultConfiguration();
9393
$this->headerSelector = $selector ?: new HeaderSelector();
9494
$this->hostIndex = $hostIndex;
9595
}
@@ -127,14 +127,14 @@ public function getConfig()
127127
*
128128
* Query audit logs
129129
*
130-
* @param string[] $user_id Comma separated list of user ids to filter by. (optional)
131-
* @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
132-
* @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
133-
* @param string[] $object_id Comma separated list of object ids to filter by. (optional)
134-
* @param string $after Timestamp after which audit logs will be returned (optional)
135-
* @param string $before Timestamp before which audit logs will be returned (optional)
136-
* @param int $limit The number of logs to return. (optional)
137-
* @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
130+
* @param string[]|null $user_id Comma separated list of user ids to filter by. (optional)
131+
* @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
132+
* @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
133+
* @param string[]|null $object_id Comma separated list of object ids to filter by. (optional)
134+
* @param string|null $after Timestamp after which audit logs will be returned (optional)
135+
* @param string|null $before Timestamp before which audit logs will be returned (optional)
136+
* @param int|null $limit The number of logs to return. (optional)
137+
* @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
138138
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation
139139
*
140140
* @throws \HubSpot\Client\Cms\AuditLogs\ApiException on non-2xx response or if the response body is not in the expected format
@@ -152,14 +152,14 @@ public function getPage($user_id = null, $event_type = null, $object_type = null
152152
*
153153
* Query audit logs
154154
*
155-
* @param string[] $user_id Comma separated list of user ids to filter by. (optional)
156-
* @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
157-
* @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
158-
* @param string[] $object_id Comma separated list of object ids to filter by. (optional)
159-
* @param string $after Timestamp after which audit logs will be returned (optional)
160-
* @param string $before Timestamp before which audit logs will be returned (optional)
161-
* @param int $limit The number of logs to return. (optional)
162-
* @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
155+
* @param string[]|null $user_id Comma separated list of user ids to filter by. (optional)
156+
* @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
157+
* @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
158+
* @param string[]|null $object_id Comma separated list of object ids to filter by. (optional)
159+
* @param string|null $after Timestamp after which audit logs will be returned (optional)
160+
* @param string|null $before Timestamp before which audit logs will be returned (optional)
161+
* @param int|null $limit The number of logs to return. (optional)
162+
* @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
163163
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation
164164
*
165165
* @throws \HubSpot\Client\Cms\AuditLogs\ApiException on non-2xx response or if the response body is not in the expected format
@@ -192,18 +192,6 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
192192

193193
$statusCode = $response->getStatusCode();
194194

195-
if ($statusCode < 200 || $statusCode > 299) {
196-
throw new ApiException(
197-
sprintf(
198-
'[%d] Error connecting to the API (%s)',
199-
$statusCode,
200-
(string) $request->getUri()
201-
),
202-
$statusCode,
203-
$response->getHeaders(),
204-
(string) $response->getBody()
205-
);
206-
}
207195

208196
switch($statusCode) {
209197
case 200:
@@ -262,6 +250,19 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
262250
];
263251
}
264252

253+
if ($statusCode < 200 || $statusCode > 299) {
254+
throw new ApiException(
255+
sprintf(
256+
'[%d] Error connecting to the API (%s)',
257+
$statusCode,
258+
(string) $request->getUri()
259+
),
260+
$statusCode,
261+
$response->getHeaders(),
262+
(string) $response->getBody()
263+
);
264+
}
265+
265266
$returnType = '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog';
266267
if ($returnType === '\SplFileObject') {
267268
$content = $response->getBody(); //stream goes to serializer
@@ -318,14 +319,14 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
318319
*
319320
* Query audit logs
320321
*
321-
* @param string[] $user_id Comma separated list of user ids to filter by. (optional)
322-
* @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
323-
* @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
324-
* @param string[] $object_id Comma separated list of object ids to filter by. (optional)
325-
* @param string $after Timestamp after which audit logs will be returned (optional)
326-
* @param string $before Timestamp before which audit logs will be returned (optional)
327-
* @param int $limit The number of logs to return. (optional)
328-
* @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
322+
* @param string[]|null $user_id Comma separated list of user ids to filter by. (optional)
323+
* @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
324+
* @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
325+
* @param string[]|null $object_id Comma separated list of object ids to filter by. (optional)
326+
* @param string|null $after Timestamp after which audit logs will be returned (optional)
327+
* @param string|null $before Timestamp before which audit logs will be returned (optional)
328+
* @param int|null $limit The number of logs to return. (optional)
329+
* @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
329330
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation
330331
*
331332
* @throws \InvalidArgumentException
@@ -346,14 +347,14 @@ function ($response) {
346347
*
347348
* Query audit logs
348349
*
349-
* @param string[] $user_id Comma separated list of user ids to filter by. (optional)
350-
* @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
351-
* @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
352-
* @param string[] $object_id Comma separated list of object ids to filter by. (optional)
353-
* @param string $after Timestamp after which audit logs will be returned (optional)
354-
* @param string $before Timestamp before which audit logs will be returned (optional)
355-
* @param int $limit The number of logs to return. (optional)
356-
* @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
350+
* @param string[]|null $user_id Comma separated list of user ids to filter by. (optional)
351+
* @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
352+
* @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
353+
* @param string[]|null $object_id Comma separated list of object ids to filter by. (optional)
354+
* @param string|null $after Timestamp after which audit logs will be returned (optional)
355+
* @param string|null $before Timestamp before which audit logs will be returned (optional)
356+
* @param int|null $limit The number of logs to return. (optional)
357+
* @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
357358
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation
358359
*
359360
* @throws \InvalidArgumentException
@@ -403,14 +404,14 @@ function ($exception) {
403404
/**
404405
* Create request for operation 'getPage'
405406
*
406-
* @param string[] $user_id Comma separated list of user ids to filter by. (optional)
407-
* @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
408-
* @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
409-
* @param string[] $object_id Comma separated list of object ids to filter by. (optional)
410-
* @param string $after Timestamp after which audit logs will be returned (optional)
411-
* @param string $before Timestamp before which audit logs will be returned (optional)
412-
* @param int $limit The number of logs to return. (optional)
413-
* @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
407+
* @param string[]|null $user_id Comma separated list of user ids to filter by. (optional)
408+
* @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional)
409+
* @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional)
410+
* @param string[]|null $object_id Comma separated list of object ids to filter by. (optional)
411+
* @param string|null $after Timestamp after which audit logs will be returned (optional)
412+
* @param string|null $before Timestamp before which audit logs will be returned (optional)
413+
* @param int|null $limit The number of logs to return. (optional)
414+
* @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional)
414415
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation
415416
*
416417
* @throws \InvalidArgumentException

codegen/Cms/AuditLogs/ApiException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -49,7 +49,7 @@ class ApiException extends Exception
4949
/**
5050
* The HTTP header of the server response.
5151
*
52-
* @var string[]|null
52+
* @var string[][]|null
5353
*/
5454
protected $responseHeaders;
5555

@@ -65,7 +65,7 @@ class ApiException extends Exception
6565
*
6666
* @param string $message Error message
6767
* @param int $code HTTP status code
68-
* @param string[]|null $responseHeaders HTTP response header
68+
* @param string[][]|null $responseHeaders HTTP response header
6969
* @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string
7070
*/
7171
public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null)
@@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re
7878
/**
7979
* Gets the HTTP response header
8080
*
81-
* @return string[]|null HTTP response header
81+
* @return string[][]|null HTTP response header
8282
*/
8383
public function getResponseHeaders()
8484
{

codegen/Cms/AuditLogs/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -486,7 +486,7 @@ public function getHostSettings()
486486
* @param array|null $variables hash of variable and the corresponding value (optional)
487487
* @return string URL based on host settings
488488
*/
489-
public static function getHostString(array $hostSettings, $hostIndex, array $variables = null)
489+
public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null)
490490
{
491491
if (null === $variables) {
492492
$variables = [];

codegen/Cms/AuditLogs/HeaderSelector.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string
8585
}
8686

8787
# If none of the available Accept headers is of type "json", then just use all them
88-
$headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept);
88+
$headersWithJson = $this->selectJsonMimeList($accept);
8989
if (count($headersWithJson) === 0) {
9090
return implode(',', $accept);
9191
}
@@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string
9595
return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson);
9696
}
9797

98+
/**
99+
* Detects whether a string contains a valid JSON mime type
100+
*
101+
* @param string $searchString
102+
* @return bool
103+
*/
104+
public function isJsonMime(string $searchString): bool
105+
{
106+
return preg_match('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~', $searchString) === 1;
107+
}
108+
109+
/**
110+
* Select all items from a list containing a JSON mime type
111+
*
112+
* @param array $mimeList
113+
* @return array
114+
*/
115+
private function selectJsonMimeList(array $mimeList): array {
116+
$jsonMimeList = [];
117+
foreach ($mimeList as $mime) {
118+
if($this->isJsonMime($mime)) {
119+
$jsonMimeList[] = $mime;
120+
}
121+
}
122+
return $jsonMimeList;
123+
}
124+
125+
98126
/**
99127
* Create an Accept header string from the given "Accept" headers array, recalculating all weights
100128
*

codegen/Cms/AuditLogs/Model/CollectionResponsePublicAuditLog.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -246,10 +246,10 @@ public function getModelName()
246246
/**
247247
* Constructor
248248
*
249-
* @param mixed[] $data Associated array of property values
249+
* @param mixed[]|null $data Associated array of property values
250250
* initializing the model
251251
*/
252-
public function __construct(array $data = null)
252+
public function __construct(?array $data = null)
253253
{
254254
$this->setIfExists('paging', $data ?? [], null);
255255
$this->setIfExists('results', $data ?? [], null);

codegen/Cms/AuditLogs/Model/Error.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -275,10 +275,10 @@ public function getModelName()
275275
/**
276276
* Constructor
277277
*
278-
* @param mixed[] $data Associated array of property values
278+
* @param mixed[]|null $data Associated array of property values
279279
* initializing the model
280280
*/
281-
public function __construct(array $data = null)
281+
public function __construct(?array $data = null)
282282
{
283283
$this->setIfExists('sub_category', $data ?? [], null);
284284
$this->setIfExists('context', $data ?? [], null);

codegen/Cms/AuditLogs/Model/ErrorDetail.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -263,10 +263,10 @@ public function getModelName()
263263
/**
264264
* Constructor
265265
*
266-
* @param mixed[] $data Associated array of property values
266+
* @param mixed[]|null $data Associated array of property values
267267
* initializing the model
268268
*/
269-
public function __construct(array $data = null)
269+
public function __construct(?array $data = null)
270270
{
271271
$this->setIfExists('sub_category', $data ?? [], null);
272272
$this->setIfExists('code', $data ?? [], null);

codegen/Cms/AuditLogs/Model/ModelInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**

codegen/Cms/AuditLogs/Model/NextPage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -245,10 +245,10 @@ public function getModelName()
245245
/**
246246
* Constructor
247247
*
248-
* @param mixed[] $data Associated array of property values
248+
* @param mixed[]|null $data Associated array of property values
249249
* initializing the model
250250
*/
251-
public function __construct(array $data = null)
251+
public function __construct(?array $data = null)
252252
{
253253
$this->setIfExists('link', $data ?? [], null);
254254
$this->setIfExists('after', $data ?? [], null);

0 commit comments

Comments
 (0)