Skip to content

Commit d1b85dd

Browse files
feat(api): manual updates
1 parent a0e24a2 commit d1b85dd

271 files changed

Lines changed: 22082 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 25
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-d04e3c285c2f57723b288ee69b1d78b7bb928aae403203b2cdd524dd195e55b2.yml
1+
configured_endpoints: 36
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-8667763c416101820f5086c97d542bf13bb3bb12b57f5f604da671d9dcea0599.yml
33
openapi_spec_hash: e33db883d584bc8573897391f3edb105
4-
config_hash: c7b0cdaba3b9797b77efd89e1754d803
4+
config_hash: 7ec4851ee8d93177947e95df5ae897b5

src/Client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use ContextDev\Services\AIService;
1111
use ContextDev\Services\BrandService;
1212
use ContextDev\Services\IndustryService;
13+
use ContextDev\Services\MonitorsService;
1314
use ContextDev\Services\UtilityService;
1415
use ContextDev\Services\WebService;
1516
use Http\Discovery\Psr17FactoryDiscovery;
@@ -48,6 +49,11 @@ class Client extends BaseClient
4849
*/
4950
public UtilityService $utility;
5051

52+
/**
53+
* @api
54+
*/
55+
public MonitorsService $monitors;
56+
5157
/**
5258
* @param RequestOpts|null $requestOptions
5359
*/
@@ -111,6 +117,7 @@ public function __construct(
111117
$this->brand = new BrandService($this);
112118
$this->industry = new IndustryService($this);
113119
$this->utility = new UtilityService($this);
120+
$this->monitors = new MonitorsService($this);
114121
}
115122

116123
/** @return array<string,string> */
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\Monitors;
6+
7+
use ContextDev\Core\Attributes\Optional;
8+
use ContextDev\Core\Attributes\Required;
9+
use ContextDev\Core\Concerns\SdkModel;
10+
use ContextDev\Core\Concerns\SdkParams;
11+
use ContextDev\Core\Contracts\BaseModel;
12+
use ContextDev\Monitors\MonitorCreateParams\ChangeDetection;
13+
use ContextDev\Monitors\MonitorCreateParams\Schedule;
14+
use ContextDev\Monitors\MonitorCreateParams\Target;
15+
use ContextDev\Monitors\MonitorCreateParams\Webhook;
16+
17+
/**
18+
* Creates a monitor. The request body is a union of the supported target/change detection combinations. The monitor runs immediately after creation to create its initial baseline.
19+
*
20+
* @see ContextDev\Services\MonitorsService::create()
21+
*
22+
* @phpstan-import-type ChangeDetectionShape from \ContextDev\Monitors\MonitorCreateParams\ChangeDetection
23+
* @phpstan-import-type ScheduleShape from \ContextDev\Monitors\MonitorCreateParams\Schedule
24+
* @phpstan-import-type TargetShape from \ContextDev\Monitors\MonitorCreateParams\Target
25+
* @phpstan-import-type WebhookShape from \ContextDev\Monitors\MonitorCreateParams\Webhook
26+
*
27+
* @phpstan-type MonitorCreateParamsShape = array{
28+
* changeDetection: ChangeDetection|ChangeDetectionShape,
29+
* name: string,
30+
* schedule: Schedule|ScheduleShape,
31+
* target: Target|TargetShape,
32+
* tags?: list<string>|null,
33+
* webhook?: null|Webhook|WebhookShape,
34+
* }
35+
*/
36+
final class MonitorCreateParams implements BaseModel
37+
{
38+
/** @use SdkModel<MonitorCreateParamsShape> */
39+
use SdkModel;
40+
use SdkParams;
41+
42+
/**
43+
* Detect meaning-level changes that match a natural language query.
44+
*/
45+
#[Required('change_detection')]
46+
public ChangeDetection $changeDetection;
47+
48+
#[Required]
49+
public string $name;
50+
51+
/**
52+
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
53+
*/
54+
#[Required]
55+
public Schedule $schedule;
56+
57+
#[Required]
58+
public Target $target;
59+
60+
/**
61+
* User-defined tags for grouping and filtering monitors and their changes.
62+
*
63+
* @var list<string>|null $tags
64+
*/
65+
#[Optional(list: 'string')]
66+
public ?array $tags;
67+
68+
#[Optional(nullable: true)]
69+
public ?Webhook $webhook;
70+
71+
/**
72+
* `new MonitorCreateParams()` is missing required properties by the API.
73+
*
74+
* To enforce required parameters use
75+
* ```
76+
* MonitorCreateParams::with(
77+
* changeDetection: ..., name: ..., schedule: ..., target: ...
78+
* )
79+
* ```
80+
*
81+
* Otherwise ensure the following setters are called
82+
*
83+
* ```
84+
* (new MonitorCreateParams)
85+
* ->withChangeDetection(...)
86+
* ->withName(...)
87+
* ->withSchedule(...)
88+
* ->withTarget(...)
89+
* ```
90+
*/
91+
public function __construct()
92+
{
93+
$this->initialize();
94+
}
95+
96+
/**
97+
* Construct an instance from the required parameters.
98+
*
99+
* You must use named parameters to construct any parameters with a default value.
100+
*
101+
* @param ChangeDetection|ChangeDetectionShape $changeDetection
102+
* @param Schedule|ScheduleShape $schedule
103+
* @param Target|TargetShape $target
104+
* @param list<string>|null $tags
105+
* @param Webhook|WebhookShape|null $webhook
106+
*/
107+
public static function with(
108+
ChangeDetection|array $changeDetection,
109+
string $name,
110+
Schedule|array $schedule,
111+
Target|array $target,
112+
?array $tags = null,
113+
Webhook|array|null $webhook = null,
114+
): self {
115+
$self = new self;
116+
117+
$self['changeDetection'] = $changeDetection;
118+
$self['name'] = $name;
119+
$self['schedule'] = $schedule;
120+
$self['target'] = $target;
121+
122+
null !== $tags && $self['tags'] = $tags;
123+
null !== $webhook && $self['webhook'] = $webhook;
124+
125+
return $self;
126+
}
127+
128+
/**
129+
* Detect meaning-level changes that match a natural language query.
130+
*
131+
* @param ChangeDetection|ChangeDetectionShape $changeDetection
132+
*/
133+
public function withChangeDetection(
134+
ChangeDetection|array $changeDetection
135+
): self {
136+
$self = clone $this;
137+
$self['changeDetection'] = $changeDetection;
138+
139+
return $self;
140+
}
141+
142+
public function withName(string $name): self
143+
{
144+
$self = clone $this;
145+
$self['name'] = $name;
146+
147+
return $self;
148+
}
149+
150+
/**
151+
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
152+
*
153+
* @param Schedule|ScheduleShape $schedule
154+
*/
155+
public function withSchedule(Schedule|array $schedule): self
156+
{
157+
$self = clone $this;
158+
$self['schedule'] = $schedule;
159+
160+
return $self;
161+
}
162+
163+
/**
164+
* @param Target|TargetShape $target
165+
*/
166+
public function withTarget(Target|array $target): self
167+
{
168+
$self = clone $this;
169+
$self['target'] = $target;
170+
171+
return $self;
172+
}
173+
174+
/**
175+
* User-defined tags for grouping and filtering monitors and their changes.
176+
*
177+
* @param list<string> $tags
178+
*/
179+
public function withTags(array $tags): self
180+
{
181+
$self = clone $this;
182+
$self['tags'] = $tags;
183+
184+
return $self;
185+
}
186+
187+
/**
188+
* @param Webhook|WebhookShape|null $webhook
189+
*/
190+
public function withWebhook(Webhook|array|null $webhook): self
191+
{
192+
$self = clone $this;
193+
$self['webhook'] = $webhook;
194+
195+
return $self;
196+
}
197+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\Monitors\MonitorCreateParams;
6+
7+
use ContextDev\Core\Attributes\Optional;
8+
use ContextDev\Core\Attributes\Required;
9+
use ContextDev\Core\Concerns\SdkModel;
10+
use ContextDev\Core\Contracts\BaseModel;
11+
use ContextDev\Monitors\MonitorCreateParams\ChangeDetection\Type;
12+
13+
/**
14+
* Detect meaning-level changes that match a natural language query.
15+
*
16+
* @phpstan-type ChangeDetectionShape = array{
17+
* query: string, type: Type|value-of<Type>, confidenceThreshold?: float|null
18+
* }
19+
*/
20+
final class ChangeDetection implements BaseModel
21+
{
22+
/** @use SdkModel<ChangeDetectionShape> */
23+
use SdkModel;
24+
25+
#[Required]
26+
public string $query;
27+
28+
/** @var value-of<Type> $type */
29+
#[Required(enum: Type::class)]
30+
public string $type;
31+
32+
#[Optional('confidence_threshold')]
33+
public ?float $confidenceThreshold;
34+
35+
/**
36+
* `new ChangeDetection()` is missing required properties by the API.
37+
*
38+
* To enforce required parameters use
39+
* ```
40+
* ChangeDetection::with(query: ..., type: ...)
41+
* ```
42+
*
43+
* Otherwise ensure the following setters are called
44+
*
45+
* ```
46+
* (new ChangeDetection)->withQuery(...)->withType(...)
47+
* ```
48+
*/
49+
public function __construct()
50+
{
51+
$this->initialize();
52+
}
53+
54+
/**
55+
* Construct an instance from the required parameters.
56+
*
57+
* You must use named parameters to construct any parameters with a default value.
58+
*
59+
* @param Type|value-of<Type> $type
60+
*/
61+
public static function with(
62+
string $query,
63+
Type|string $type,
64+
?float $confidenceThreshold = null
65+
): self {
66+
$self = new self;
67+
68+
$self['query'] = $query;
69+
$self['type'] = $type;
70+
71+
null !== $confidenceThreshold && $self['confidenceThreshold'] = $confidenceThreshold;
72+
73+
return $self;
74+
}
75+
76+
public function withQuery(string $query): self
77+
{
78+
$self = clone $this;
79+
$self['query'] = $query;
80+
81+
return $self;
82+
}
83+
84+
/**
85+
* @param Type|value-of<Type> $type
86+
*/
87+
public function withType(Type|string $type): self
88+
{
89+
$self = clone $this;
90+
$self['type'] = $type;
91+
92+
return $self;
93+
}
94+
95+
public function withConfidenceThreshold(float $confidenceThreshold): self
96+
{
97+
$self = clone $this;
98+
$self['confidenceThreshold'] = $confidenceThreshold;
99+
100+
return $self;
101+
}
102+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\Monitors\MonitorCreateParams\ChangeDetection;
6+
7+
enum Type: string
8+
{
9+
case SEMANTIC = 'semantic';
10+
}

0 commit comments

Comments
 (0)