Skip to content

Commit 2a9680f

Browse files
committed
v2: add DevicePostureResource.GetIntegration
Allows getting a single device posture integration by id. Updates tailscale/corp#21624 Signed-off-by: Percy Wegmann <[email protected]>
1 parent 931083b commit 2a9680f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

v2/device_posture.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,14 @@ func (pr *DevicePostureResource) DeleteIntegration(ctx context.Context, id strin
9797

9898
return pr.do(req, nil)
9999
}
100+
101+
// GetIntegration gets the PostureIntegration identified by id.
102+
func (pr *DevicePostureResource) GetIntegration(ctx context.Context, id string) (*PostureIntegration, error) {
103+
req, err := pr.buildRequest(ctx, http.MethodGet, pr.buildURL("posture", "integrations", id))
104+
if err != nil {
105+
return nil, err
106+
}
107+
108+
var resp PostureIntegration
109+
return &resp, pr.do(req, &resp)
110+
}

v2/device_posture_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ func TestClient_DevicePosture_DeleteIntegration(t *testing.T) {
9292
assert.Equal(t, "/api/v2/posture/integrations/1", server.Path)
9393
}
9494

95+
func TestClient_DevicePosture_GetIntegration(t *testing.T) {
96+
t.Parallel()
97+
98+
client, server := NewTestHarness(t)
99+
server.ResponseCode = http.StatusOK
100+
101+
resp := &tsclient.PostureIntegration{
102+
ID: "1",
103+
Provider: tsclient.PostureIntegrationProviderIntune,
104+
CloudID: "cloudid1",
105+
ClientID: "clientid1",
106+
TenantID: "tenantid1",
107+
}
108+
server.ResponseBody = resp
109+
110+
actualResp, err := client.DevicePosture().GetIntegration(context.Background(), "1")
111+
assert.NoError(t, err)
112+
assert.Equal(t, http.MethodGet, server.Method)
113+
assert.Equal(t, "/api/v2/posture/integrations/1", server.Path)
114+
assert.Equal(t, resp, actualResp)
115+
}
116+
95117
func TestClient_DevicePosture_ListIntegrations(t *testing.T) {
96118
t.Parallel()
97119

0 commit comments

Comments
 (0)