Skip to content

Commit

Permalink
Getting changes from Main into v2 (#14)
Browse files Browse the repository at this point in the history
* SYN-3197: Custom Properties

* adds custom properties to integration tests.

* add new CLA workflow

* update readme and contributing docs

* docs change

---------

Co-authored-by: Brian Gustafson <[email protected]>
Co-authored-by: greatestusername-splunk <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2023
1 parent 47d07ac commit 32dd831
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 122 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
permissions:
actions: write
contents: write
pull-requests: write
statuses: write
jobs:
CLAAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: contributor-assistant/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
# This token is required only if you have configured to store the signatures in a remote repository/organization
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: 'signatures/version1/cla.json'
path-to-document: 'https://github.com/splunk/cla-agreement/blob/main/CLA.md' # e.g. a CLA or a DCO document
# branch should not be protected
branch: 'main'
allowlist: dependabot[bot]
remote-organization-name: splunk
remote-repository-name: cla-agreement
CodeOfConduct:
runs-on: ubuntu-latest
steps:
- name: "COC Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the Code of Conduct and I hereby accept the Terms') || github.event_name == 'pull_request_target'
uses: cla-assistant/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: "signatures/version1/coc.json"
path-to-document: "https://github.com/splunk/cla-agreement/blob/main/CODE_OF_CONDUCT.md" # e.g. a COC or a DCO document
branch: "main"
allowlist: dependabot[bot]
remote-organization-name: splunk
remote-repository-name: cla-agreement
custom-pr-sign-comment: "I have read the Code of Conduct and I hereby accept the Terms"
create-file-commit-message: "For example: Creating file for storing COC Signatures"
signed-commit-message: "$contributorName has signed the COC in #$pullRequestNo"
custom-notsigned-prcomment: "All contributors have NOT signed the COC Document"
custom-allsigned-prcomment: "****CLA Assistant Lite bot**** All contributors have signed the COC ✍️ ✅"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@

.DS_Store
.vscode/settings.json

# Jetbrains IDEs
.idea
19 changes: 7 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you are reporting a bug or issues, please include:

- Operating system name and version.
- Any details about your local setup that might be helpful
in troubleshooting (E.G. Python version if using a python script, Terraform version if you're using a Terraform script.).
in troubleshooting
- Detailed steps to reproduce the bug.

### Fix Bugs
Expand All @@ -23,17 +23,16 @@ a "bug" ticket type is open to whoever wants to implement it.

### Implement Features

If you have a great set of dashboards, detectors, API scripts for sending metrics, or any other content
you believe will be of use to others, please contribute it!

Or check the Issues for this repo on GitHub. Anything tagged with "enhancement"
Please file an issue or check the issues for this repo on GitHub. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.

Once issues are posted and triaged please include their issue number in any PRs related to that work

### Write Documentation

Submissions and `README.md` files could always use more documentation. Documentation can always use an update or tweak in the official docs, in docstrings of scripts, comments in configs, or anywhere a bit of clarity may be useful..

### Submit Feedback
### Submit Issues / Feedback

If you are proposing a feature:

Expand All @@ -47,9 +46,5 @@ If you are proposing a feature:

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include a `README.md` for any new submission.
2. If the pull request adds functionality, the `README.md` docs for that component or submission should be updated.
Put your new functionality into a function with a docstring, and add
the feature to the list in README.md.
3. Terraform submissions should work with the most current version of the included Terraform Provider.
4. Python submissions should work for Python3
1. The pull request should include documentation and example changes for any new functionality.
2. If the pull request adds functionality, the tests should be updated.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntheticsclient
A Splunk Synthetics (Formerly Rigor) client for golang.
A Splunk Synthetics for Splunk Observability (Formerly Rigor) client for golang.

## Installation
`go get https://github.com/splunk/syntheticsclient.git`
Expand Down Expand Up @@ -52,4 +52,23 @@ func main() {
API Docs are [available here](https://dev.splunk.com/observability/reference)

## Additional Information
This client is largely a copypasta mutation of the [go-victor](https://github.com/victorops/go-victorops) client for Splunk On-Call (formerly known as VictorOps).
This client is largely a copypasta mutation of the [go-victor](https://github.com/victorops/go-victorops) client for Splunk On-Call (formerly known as VictorOps).

## Contributions
Contributions are welcome and encouraged!

Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details on contributing to this repository.

Before your contribution can be accepted, you will be asked to sign our
[Splunk Contributor License Agreement (CLA)](https://github.com/splunk/cla-agreement/blob/main/CLA.md).

To agree to the CLA and COC please comment these in **separate individual messages** on your PR:

CLA:
```
I have read the CLA Document and I hereby sign the CLA
```

Code of Conduct:
```
I have read the Code of Conduct and I hereby accept the Terms
184 changes: 99 additions & 85 deletions syntheticsclientv2/common_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ type Validations struct {
}

type Tests []struct {
Active bool `json:"active"`
Createdat time.Time `json:"createdAt"`
Frequency int `json:"frequency"`
ID int `json:"id"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Schedulingstrategy string `json:"schedulingStrategy"`
Type string `json:"type"`
Updatedat time.Time `json:"updatedAt"`
Active bool `json:"active"`
Createdat time.Time `json:"createdAt"`
Frequency int `json:"frequency"`
ID int `json:"id"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Schedulingstrategy string `json:"schedulingStrategy"`
Type string `json:"type"`
Updatedat time.Time `json:"updatedAt"`
Customproperties []CustomProperties `json:"customProperties"`
}

type GetChecksV2Options struct {
Expand Down Expand Up @@ -237,86 +238,91 @@ type ChecksV2Response struct {

type PortCheckV2Response struct {
Test struct {
ID int `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LocationIds []string `json:"locationIds"`
Type string `json:"type"`
Protocol string `json:"protocol"`
Host string `json:"host"`
Port int `json:"port"`
ID int `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LocationIds []string `json:"locationIds"`
Type string `json:"type"`
Protocol string `json:"protocol"`
Host string `json:"host"`
Port int `json:"port"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

type PortCheckV2Input struct {
Test struct {
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
Port int `json:"port"`
Protocol string `json:"protocol"`
Host string `json:"host"`
LocationIds []string `json:"locationIds"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
Port int `json:"port"`
Protocol string `json:"protocol"`
Host string `json:"host"`
LocationIds []string `json:"locationIds"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

type HttpCheckV2Response struct {
Test struct {
ID int `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
LocationIds []string `json:"locationIds"`
Type string `json:"type"`
URL string `json:"url"`
RequestMethod string `json:"requestMethod"`
Body string `json:"body,omitempty"`
Authentication *Authentication `json:"authentication"`
UserAgent *string `json:"userAgent"`
Verifycertificates bool `json:"verifyCertificates"`
HttpHeaders []HttpHeaders `json:"headers"`
Validations []Validations `json:"validations"`
ID int `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
LocationIds []string `json:"locationIds"`
Type string `json:"type"`
URL string `json:"url"`
RequestMethod string `json:"requestMethod"`
Body string `json:"body,omitempty"`
Authentication *Authentication `json:"authentication"`
UserAgent *string `json:"userAgent"`
Verifycertificates bool `json:"verifyCertificates"`
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
Validations []Validations `json:"validations"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

type HttpCheckV2Input struct {
Test struct {
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
LocationIds []string `json:"locationIds"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
RequestMethod string `json:"requestMethod"`
Body string `json:"body,omitempty"`
Authentication *Authentication `json:"authentication"`
UserAgent *string `json:"userAgent"`
Verifycertificates bool `json:"verifyCertificates"`
HttpHeaders []HttpHeaders `json:"headers"`
Validations []Validations `json:"validations"`
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
LocationIds []string `json:"locationIds"`
Frequency int `json:"frequency"`
SchedulingStrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
RequestMethod string `json:"requestMethod"`
Body string `json:"body,omitempty"`
Authentication *Authentication `json:"authentication"`
UserAgent *string `json:"userAgent"`
Verifycertificates bool `json:"verifyCertificates"`
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
Validations []Validations `json:"validations"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

type ApiCheckV2Input struct {
Test struct {
Active bool `json:"active"`
Deviceid int `json:"deviceId"`
Frequency int `json:"frequency"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Requests []Requests `json:"requests"`
Schedulingstrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
Deviceid int `json:"deviceId"`
Frequency int `json:"frequency"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Requests []Requests `json:"requests"`
Schedulingstrategy string `json:"schedulingStrategy"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

Expand All @@ -325,14 +331,15 @@ type ApiCheckV2Response struct {
Active bool `json:"active"`
Createdat time.Time `json:"createdAt"`
Device `json:"device,omitempty"`
Frequency int `json:"frequency,omitempty"`
ID int `json:"id,omitempty"`
Locationids []string `json:"locationIds,omitempty"`
Name string `json:"name,omitempty"`
Requests []Requests `json:"requests,omitempty"`
Schedulingstrategy string `json:"schedulingStrategy,omitempty"`
Type string `json:"type,omitempty"`
Updatedat time.Time `json:"updatedAt,omitempty"`
Frequency int `json:"frequency,omitempty"`
ID int `json:"id,omitempty"`
Locationids []string `json:"locationIds,omitempty"`
Name string `json:"name,omitempty"`
Requests []Requests `json:"requests,omitempty"`
Schedulingstrategy string `json:"schedulingStrategy,omitempty"`
Type string `json:"type,omitempty"`
Updatedat time.Time `json:"updatedAt,omitempty"`
Customproperties []CustomProperties `json:"customProperties"`
}
}

Expand All @@ -348,6 +355,7 @@ type BrowserCheckV2Input struct {
Schedulingstrategy string `json:"schedulingStrategy"`
Active bool `json:"active"`
Advancedsettings `json:"advancedSettings,omitempty"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

Expand All @@ -357,13 +365,19 @@ type BrowserCheckV2Response struct {
Advancedsettings `json:"advancedSettings"`
Createdat time.Time `json:"createdAt"`
Device `json:"device"`
Frequency int `json:"frequency"`
ID int `json:"id"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Schedulingstrategy string `json:"schedulingStrategy"`
Transactions []Transactions `json:"transactions"`
Type string `json:"type"`
Updatedat time.Time `json:"updatedAt"`
Frequency int `json:"frequency"`
ID int `json:"id"`
Locationids []string `json:"locationIds"`
Name string `json:"name"`
Schedulingstrategy string `json:"schedulingStrategy"`
Transactions []Transactions `json:"transactions"`
Type string `json:"type"`
Updatedat time.Time `json:"updatedAt"`
Customproperties []CustomProperties `json:"customProperties"`
} `json:"test"`
}

type CustomProperties struct {
Key string `json:"key"`
Value string `json:"value"`
}
5 changes: 4 additions & 1 deletion syntheticsclientv2/create_apicheckv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

var (
createApiV2Body = `{"test":{"active":true,"device_id":1,"frequency":5,"location_ids":["aws-us-east-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}`
createApiV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"device_id":1,"frequency":5,"location_ids":["aws-us-east-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}`
inputData = ApiCheckV2Input{}
)

Expand Down Expand Up @@ -79,4 +79,7 @@ func TestCreateApiCheckV2(t *testing.T) {
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Schedulingstrategy, inputData.Test.Schedulingstrategy)
}

if !reflect.DeepEqual(resp.Test.Customproperties, inputData.Test.Customproperties) {
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputData.Test.Customproperties)
}
}
Loading

0 comments on commit 32dd831

Please sign in to comment.