├── .gitattributes ├── .github └── workflows │ ├── generator.yml │ └── go.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .secrets.baseline ├── LICENSE ├── Makefile ├── README.md ├── config └── config.go ├── datatypes ├── abuse.go ├── account.go ├── auxiliary.go ├── billing.go ├── bms.go ├── brand.go ├── business.go ├── catalyst.go ├── compliance.go ├── configuration.go ├── container.go ├── device.go ├── dns.go ├── email.go ├── entity.go ├── event.go ├── exception.go ├── flexiblecredit.go ├── hardware.go ├── layout.go ├── legal.go ├── locale.go ├── location.go ├── marketplace.go ├── mcafee.go ├── metric.go ├── monitoring.go ├── network.go ├── notification.go ├── policy.go ├── product.go ├── provisioning.go ├── resource.go ├── sales.go ├── scale.go ├── search.go ├── security.go ├── service.go ├── softlayer.go ├── softlayer_test.go ├── software.go ├── sprint.go ├── survey.go ├── tag.go ├── ticket.go ├── trellix.go ├── user.go ├── utility.go ├── vendor.go ├── verify.go ├── virtual.go └── workload.go ├── examples ├── cmd │ ├── iam_demo.go │ ├── root.go │ ├── server_list.go │ ├── virtual_iter.go │ ├── vlan_detail.go │ ├── vlan_list.go │ ├── vlan_name.go │ └── vlan_order.go ├── examples.go ├── go.mod ├── go.sum ├── helpers.go ├── main.go └── testPlaceQuote.go ├── filter ├── filters.go └── filters_test.go ├── generator ├── generate.go ├── generate_test.go ├── loadmeta.go ├── loadmeta_test.go ├── specialcase_test.go ├── templates.go └── types.go ├── go.mod ├── go.sum ├── helpers ├── hardware │ ├── hardware.go │ └── hardware_test.go ├── location │ └── location.go ├── network │ └── network.go ├── order │ └── order.go ├── product │ └── product.go └── virtual │ ├── virtual.go │ └── virtual_test.go ├── services ├── account.go ├── account_test.go ├── auxiliary.go ├── auxiliary_test.go ├── billing.go ├── billing_test.go ├── brand.go ├── brand_test.go ├── business.go ├── business_test.go ├── catalyst.go ├── catalyst_test.go ├── compliance.go ├── compliance_test.go ├── configuration.go ├── configuration_test.go ├── dns.go ├── dns_test.go ├── email.go ├── email_test.go ├── event.go ├── event_test.go ├── exception.go ├── flexiblecredit.go ├── flexiblecredit_test.go ├── hardware.go ├── hardware_test.go ├── layout.go ├── layout_test.go ├── locale.go ├── locale_test.go ├── location.go ├── location_test.go ├── marketplace.go ├── marketplace_test.go ├── metric.go ├── metric_test.go ├── monitoring.go ├── monitoring_test.go ├── network.go ├── network_test.go ├── notification.go ├── notification_test.go ├── product.go ├── product_test.go ├── provisioning.go ├── provisioning_test.go ├── resource.go ├── resource_test.go ├── sales.go ├── sales_test.go ├── search.go ├── search_test.go ├── security.go ├── security_test.go ├── services_test.go ├── software.go ├── software_test.go ├── survey.go ├── survey_test.go ├── tag.go ├── tag_test.go ├── ticket.go ├── ticket_test.go ├── user.go ├── user_test.go ├── utility.go ├── utility_test.go ├── verify.go ├── verify_test.go ├── virtual.go └── virtual_test.go ├── session ├── iamupdater.go ├── rest.go ├── rest_test.go ├── session.go ├── session_test.go ├── sessionfakes │ ├── fake_iamupdater.go │ ├── fake_slsession.go │ └── fake_transport_handler.go ├── xmlrpc.go └── xmlrpc_test.go ├── sl ├── errors.go ├── errors_test.go ├── helpers.go ├── helpers_test.go ├── options.go ├── options_test.go ├── sl_test.go ├── version.go └── version_test.go ├── sldnSample.json └── tools ├── main.go ├── tools.go └── version.go /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/workflows/generator.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Generator 3 | 4 | on: 5 | schedule: 6 | # Run Monday/Wednesday 5pm 7 | - cron: '0 0 1 * *' 8 | #- cron: '*/15 * * * *' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@master 15 | - name: Generate SoftLayer classes 16 | run: | 17 | make generate 18 | make fmt 19 | - name: Commit files 20 | run: | 21 | git config --local user.email "action@github.com" 22 | git config --local user.name "GitHub Action" 23 | git commit -m "Updated generated classes on `date`" -a 24 | - name: Push changes 25 | uses: ad-m/github-push-action@master 26 | with: 27 | github_token: ${{ secrets.GITHUB_TOKEN }} 28 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | test: 11 | strategy: 12 | matrix: 13 | go-version: [1.21.x] 14 | platform: [ubuntu-latest] 15 | runs-on: ${{ matrix.platform }} 16 | steps: 17 | - name: Install Go 18 | if: success() 19 | uses: actions/setup-go@v1 20 | with: 21 | go-version: ${{ matrix.go-version }} 22 | - name: Checkout code 23 | uses: actions/checkout@v1 24 | - name: Run tests 25 | run: make test 26 | detectsecrets: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v4 30 | - name: Set up Python 31 | uses: actions/setup-python/@v4 32 | with: 33 | python-version: 3.11 34 | - name: Install Detect Secrets 35 | run: | 36 | python -m pip install --upgrade pip 37 | pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets" 38 | - name: Detect Secrets 39 | run: | 40 | detect-secrets scan --update .secrets.baseline --exclude-files *go.sum* 41 | detect-secrets audit .secrets.baseline --report --fail-on-unaudited --omit-instructions 42 | coverage: 43 | runs-on: ubuntu-latest 44 | steps: 45 | - name: Install Go 46 | if: success() 47 | uses: actions/setup-go@v1 48 | with: 49 | go-version: 1.21.x 50 | - name: Checkout code 51 | uses: actions/checkout@v1 52 | - name: Calc coverage 53 | run: | 54 | export PATH=$PATH:$(go env GOPATH)/bin 55 | go get -v -t -d ./... 56 | go test -v `go list ./... | grep -v '/vendor/'` -covermode=count -coverprofile=coverage.out 57 | # Required because the coverage.out file on github actions has a path that breaks gcov2lcov 58 | sed -i "s/$(pwd|sed 's/\//\\\//g')/./g" coverage.out 59 | - name: Convert coverage to lcov 60 | uses: jandelgado/gcov2lcov-action@v1.0.8 61 | with: 62 | infile: coverage.out 63 | outfile: coverage.lcov 64 | - name: Coveralls 65 | uses: coverallsapp/github-action@master 66 | with: 67 | github-token: ${{ secrets.github_token }} 68 | path-to-lcov: coverage.lcov 69 | 70 | build: 71 | name: Build 72 | runs-on: ubuntu-latest 73 | steps: 74 | 75 | - name: Set up Go 1.21 76 | uses: actions/setup-go@v1 77 | with: 78 | go-version: 1.21 79 | id: go 80 | 81 | - name: Check out code into the Go module directory 82 | uses: actions/checkout@v2 83 | 84 | - name: Get dependencies 85 | run: | 86 | go get -v -t -d ./... 87 | if [ -f Gopkg.toml ]; then 88 | curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh 89 | dep ensure 90 | fi 91 | 92 | - name: Build 93 | run: make build 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | tmp 10 | out 11 | .idea 12 | 13 | # Project files 14 | *.iml 15 | 16 | # Output from make coverage 17 | coverage.out 18 | 19 | # Architecture specific extensions/prefixes 20 | *.[568vq] 21 | [568vq].out 22 | 23 | *.cgo1.go 24 | *.cgo2.c 25 | _cgo_defun.c 26 | _cgo_gotypes.go 27 | _cgo_export.* 28 | 29 | _testmain.go 30 | 31 | *.exe 32 | *.test 33 | *.prof 34 | *.DS_STORE 35 | 36 | # Git vendor things 37 | vendor/ 38 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # This is an example configuration to enable detect-secrets in the pre-commit hook. 2 | # Add this file to the root folder of your repository. 3 | # 4 | # Read pre-commit hook framework https://pre-commit.com/ for more details about the structure of config yaml file and how git pre-commit would invoke each hook. 5 | # 6 | # This line indicates we will use the hook from ibm/detect-secrets to run scan during committing phase. 7 | repos: 8 | - repo: https://github.com/ibm/detect-secrets 9 | # If you desire to use a specific version of detect-secrets, you can replace `master` with other git revisions such as branch, tag or commit sha. 10 | # You are encouraged to use static refs such as tags, instead of branch name 11 | # 12 | # Running "pre-commit autoupdate" automatically updates rev to latest tag 13 | rev: 0.13.1+ibm.62.dss 14 | hooks: 15 | - id: detect-secrets # pragma: whitelist secret 16 | # Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options. 17 | # You may also run `pre-commit run detect-secrets` to preview the scan result. 18 | # when "--baseline" without "--use-all-plugins", pre-commit scan with just plugins in baseline file 19 | # when "--baseline" with "--use-all-plugins", pre-commit scan with all available plugins 20 | # add "--fail-on-unaudited" to fail pre-commit for unaudited potential secrets 21 | args: [--baseline, .secrets.baseline, --use-all-plugins] 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | TOOLS=go run ./tools 3 | VETARGS?=-all 4 | COVERPROFILE=coverage.out 5 | 6 | PACKAGE_LIST := $$(go list ./... | grep -v '/vendor/') 7 | 8 | .PHONY: all alpha build deps fmt fmtcheck generate release test coverage version vet 9 | 10 | all: build 11 | 12 | alpha: 13 | @$(TOOLS) version --bump patch --prerelease alpha 14 | git add sl/version.go 15 | git commit -m "Bump version" 16 | git push 17 | 18 | build: fmtcheck vet deps 19 | go build ./... 20 | 21 | deps: 22 | go mod vendor 23 | 24 | fmt: 25 | gofmt -w `find . -name '*.go' | grep -v vendor` 26 | 27 | fmtcheck: 28 | @fmt_list=$$(gofmt -e -l `find . -name '*.go' | grep -v vendor`) && \ 29 | [ -z $${fmt_list} ] || \ 30 | (echo "gofmt needs to be run on the following files:" \ 31 | && echo "$${fmt_list}" && \ 32 | echo "You can run 'make fmt' to format code" && false) 33 | 34 | generate: 35 | go run ./tools generate 36 | 37 | release: build 38 | @NEW_VERSION=$$($(TOOLS) version --bump patch) && \ 39 | git add sl/version.go && \ 40 | git commit -m "Cut release $${NEW_VERSION}" && \ 41 | git tag $${NEW_VERSION} && \ 42 | git push && \ 43 | git push origin $${NEW_VERSION} 44 | 45 | test: fmtcheck vet deps 46 | go test $(PACKAGE_LIST) -timeout=30s 47 | 48 | coverage: 49 | @echo "Running unit tests. Cover profile saved to $(COVERPROFILE) ...\n" 50 | go test $(PACKAGE_LIST) -timeout=30s -coverprofile=$(COVERPROFILE) 51 | @echo "\nBuilding function coverage report...\n" 52 | go tool cover -func=$(COVERPROFILE) 53 | 54 | version: 55 | @$(TOOLS) version 56 | 57 | # vet runs the Go source code static analysis tool `vet` to find 58 | # any common errors. 59 | vet: 60 | @go vet $(VETARGS) $$(go list ./... | grep -v datatypes) ; if [ $$? -eq 1 ]; then \ 61 | echo ""; \ 62 | echo "Vet found suspicious constructs. Please check the reported constructs"; \ 63 | echo "and fix them if necessary before submitting the code for review."; \ 64 | exit 1; \ 65 | fi 66 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | /** 2 | * // This file is borrowed from https://github.com/vaughan0/go-ini/blob/master/ini.go 3 | * // which is distributed under the MIT license (https://github.com/vaughan0/go-ini/blob/master/LICENSE). 4 | * 5 | * Copyright (c) 2013 Vaughan Newton 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 8 | * associated documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the 11 | * following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial 14 | * portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 17 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | // Package config provides functions for parsing INI configuration files. 24 | package config 25 | 26 | import ( 27 | "bufio" 28 | "fmt" 29 | "io" 30 | "os" 31 | "regexp" 32 | "strings" 33 | ) 34 | 35 | var ( 36 | sectionRegex = regexp.MustCompile(`^\[(.*)\]$`) 37 | assignRegex = regexp.MustCompile(`^([^=]+)=(.*)$`) 38 | ) 39 | 40 | // ErrSyntax is returned when there is a syntax error in an INI file. 41 | type ErrSyntax struct { 42 | Line int 43 | Source string // The contents of the erroneous line, without leading or trailing whitespace 44 | } 45 | 46 | func (e ErrSyntax) Error() string { 47 | return fmt.Sprintf("invalid INI syntax on line %d: %s", e.Line, e.Source) 48 | } 49 | 50 | // A File represents a parsed INI file. 51 | type File map[string]Section 52 | 53 | // A Section represents a single section of an INI file. 54 | type Section map[string]string 55 | 56 | // Returns a named Section. A Section will be created if one does not already exist for the given name. 57 | func (f File) Section(name string) Section { 58 | section := f[name] 59 | if section == nil { 60 | section = make(Section) 61 | f[name] = section 62 | } 63 | return section 64 | } 65 | 66 | // Looks up a value for a key in a section and returns that value, along with a boolean result similar to a map lookup. 67 | func (f File) Get(section, key string) (value string, ok bool) { 68 | if s := f[section]; s != nil { 69 | value, ok = s[key] 70 | } 71 | return 72 | } 73 | 74 | // Loads INI data from a reader and stores the data in the File. 75 | func (f File) Load(in io.Reader) error { 76 | bufin, ok := in.(*bufio.Reader) 77 | if !ok { 78 | bufin = bufio.NewReader(in) 79 | } 80 | return parseFile(bufin, f) 81 | } 82 | 83 | // Loads INI data from a named file and stores the data in the File. 84 | func (f File) LoadFile(file string) (err error) { 85 | in, err := os.Open(file) 86 | if err != nil { 87 | return 88 | } 89 | defer in.Close() 90 | return f.Load(in) 91 | } 92 | 93 | func parseFile(in *bufio.Reader, file File) (err error) { 94 | section := "" 95 | lineNum := 0 96 | for done := false; !done; { 97 | var line string 98 | if line, err = in.ReadString('\n'); err != nil { 99 | if err == io.EOF { 100 | done = true 101 | } else { 102 | return 103 | } 104 | } 105 | lineNum++ 106 | line = strings.TrimSpace(line) 107 | if len(line) == 0 { 108 | // Skip blank lines 109 | continue 110 | } 111 | if line[0] == ';' || line[0] == '#' { 112 | // Skip comments 113 | continue 114 | } 115 | 116 | if groups := assignRegex.FindStringSubmatch(line); groups != nil { 117 | key, val := groups[1], groups[2] 118 | key, val = strings.TrimSpace(key), strings.TrimSpace(val) 119 | file.Section(section)[key] = val 120 | } else if groups := sectionRegex.FindStringSubmatch(line); groups != nil { 121 | name := strings.TrimSpace(groups[1]) 122 | section = name 123 | // Create the section if it does not exist 124 | file.Section(section) 125 | } else { 126 | return ErrSyntax{Line: lineNum, Source: line} 127 | } 128 | 129 | } 130 | return nil 131 | } 132 | 133 | // Loads and returns a File from a reader. 134 | func Load(in io.Reader) (File, error) { 135 | file := make(File) 136 | err := file.Load(in) 137 | return file, err 138 | } 139 | 140 | // Loads and returns an INI File from a file on disk. 141 | func LoadFile(filename string) (File, error) { 142 | file := make(File) 143 | err := file.LoadFile(filename) 144 | return file, err 145 | } 146 | -------------------------------------------------------------------------------- /datatypes/abuse.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Abuse_Lockdown_Resource struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"` 22 | 23 | // no documentation yet 24 | InvoiceItem *Billing_Invoice_Item `json:"invoiceItem,omitempty" xmlrpc:"invoiceItem,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /datatypes/auxiliary.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Auxiliary_Network_Status struct { 18 | Entity 19 | } 20 | 21 | // A SoftLayer_Auxiliary_Notification_Emergency data object represents a notification event being broadcast to the SoftLayer customer base. It is used to provide information regarding outages or current known issues. 22 | type Auxiliary_Notification_Emergency struct { 23 | Entity 24 | 25 | // The date this event was created. 26 | CreateDate *Time `json:"createDate,omitempty" xmlrpc:"createDate,omitempty"` 27 | 28 | // The device (if any) effected by this event. 29 | Device *string `json:"device,omitempty" xmlrpc:"device,omitempty"` 30 | 31 | // The duration of this event. 32 | Duration *string `json:"duration,omitempty" xmlrpc:"duration,omitempty"` 33 | 34 | // The device (if any) effected by this event. 35 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 36 | 37 | // The location effected by this event. 38 | Location *string `json:"location,omitempty" xmlrpc:"location,omitempty"` 39 | 40 | // A message describing this event. 41 | Message *string `json:"message,omitempty" xmlrpc:"message,omitempty"` 42 | 43 | // The last date this event was modified. 44 | ModifyDate *Time `json:"modifyDate,omitempty" xmlrpc:"modifyDate,omitempty"` 45 | 46 | // The service(s) (if any) effected by this event. 47 | ServicesAffected *string `json:"servicesAffected,omitempty" xmlrpc:"servicesAffected,omitempty"` 48 | 49 | // The signature of the SoftLayer employee department associated with this notification. 50 | Signature *Auxiliary_Notification_Emergency_Signature `json:"signature,omitempty" xmlrpc:"signature,omitempty"` 51 | 52 | // The date this event will start. 53 | StartDate *Time `json:"startDate,omitempty" xmlrpc:"startDate,omitempty"` 54 | 55 | // The status of this notification. 56 | Status *Auxiliary_Notification_Emergency_Status `json:"status,omitempty" xmlrpc:"status,omitempty"` 57 | 58 | // Current status record for this event. 59 | StatusId *int `json:"statusId,omitempty" xmlrpc:"statusId,omitempty"` 60 | } 61 | 62 | // Every SoftLayer_Auxiliary_Notification_Emergency has a signatureId that references a SoftLayer_Auxiliary_Notification_Emergency_Signature data type. The signature is the user or group responsible for the current event. 63 | type Auxiliary_Notification_Emergency_Signature struct { 64 | Entity 65 | 66 | // The name or signature for the current Emergency Notification. 67 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 68 | } 69 | 70 | // Every SoftLayer_Auxiliary_Notification_Emergency has a statusId that references a SoftLayer_Auxiliary_Notification_Emergency_Status data type. The status is used to determine the current state of the event. 71 | type Auxiliary_Notification_Emergency_Status struct { 72 | Entity 73 | 74 | // A name describing the status of the current Emergency Notification. 75 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 76 | } 77 | 78 | // The SoftLayer_Auxiliary_Shipping_Courier data type contains general information relating the different (major) couriers that SoftLayer may use for shipping. 79 | type Auxiliary_Shipping_Courier struct { 80 | Entity 81 | 82 | // The unique id of the shipping courier. 83 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 84 | 85 | // The unique keyname of the shipping courier. 86 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 87 | 88 | // The name of the shipping courier. 89 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 90 | 91 | // The url to shipping courier's website. 92 | Url *string `json:"url,omitempty" xmlrpc:"url,omitempty"` 93 | } 94 | 95 | // no documentation yet 96 | type Auxiliary_Shipping_Courier_Type struct { 97 | Entity 98 | 99 | // no documentation yet 100 | Courier []Auxiliary_Shipping_Courier `json:"courier,omitempty" xmlrpc:"courier,omitempty"` 101 | 102 | // A count of 103 | CourierCount *uint `json:"courierCount,omitempty" xmlrpc:"courierCount,omitempty"` 104 | 105 | // no documentation yet 106 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 107 | 108 | // no documentation yet 109 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 110 | 111 | // no documentation yet 112 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 113 | 114 | // no documentation yet 115 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 116 | } 117 | -------------------------------------------------------------------------------- /datatypes/bms.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type BMS_Container_Country struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Code *string `json:"code,omitempty" xmlrpc:"code,omitempty"` 22 | 23 | // no documentation yet 24 | Id *string `json:"id,omitempty" xmlrpc:"id,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /datatypes/business.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // Contains business partner channel information 17 | type Business_Partner_Channel struct { 18 | Entity 19 | 20 | // Business partner channel description 21 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 22 | 23 | // Business partner channel name 24 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 25 | } 26 | 27 | // Contains business partner segment information 28 | type Business_Partner_Segment struct { 29 | Entity 30 | 31 | // Business partner segment description 32 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 33 | 34 | // Business partner segment name 35 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 36 | } 37 | -------------------------------------------------------------------------------- /datatypes/compliance.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Compliance_Report_Type struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 22 | 23 | // no documentation yet 24 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 25 | 26 | // no documentation yet 27 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /datatypes/device.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // SoftLayer_Device_Status is used to indicate the current status of a device 17 | type Device_Status struct { 18 | Entity 19 | 20 | // The device status's associated unique ID. 21 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 22 | 23 | // The device status's unique string identifier. 24 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 25 | 26 | // The name of the status. 27 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /datatypes/email.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Email_Subscription struct { 18 | Entity 19 | 20 | // Brief description of the purpose of the email. 21 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 22 | 23 | // no documentation yet 24 | Enabled *bool `json:"enabled,omitempty" xmlrpc:"enabled,omitempty"` 25 | 26 | // no documentation yet 27 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 28 | 29 | // Email template name. 30 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 31 | } 32 | 33 | // no documentation yet 34 | type Email_Subscription_Group struct { 35 | Entity 36 | 37 | // no documentation yet 38 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 39 | 40 | // Email subscription group name. 41 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 42 | 43 | // A count of all email subscriptions associated with this group. 44 | SubscriptionCount *uint `json:"subscriptionCount,omitempty" xmlrpc:"subscriptionCount,omitempty"` 45 | 46 | // All email subscriptions associated with this group. 47 | Subscriptions []Email_Subscription `json:"subscriptions,omitempty" xmlrpc:"subscriptions,omitempty"` 48 | } 49 | 50 | // no documentation yet 51 | type Email_Subscription_Suppression_User struct { 52 | Entity 53 | 54 | // no documentation yet 55 | Subscription *Email_Subscription `json:"subscription,omitempty" xmlrpc:"subscription,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /datatypes/entity.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Entity struct { 18 | } 19 | -------------------------------------------------------------------------------- /datatypes/event.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // The SoftLayer_Event_Log data type contains an event detail occurred upon various SoftLayer resources. 17 | type Event_Log struct { 18 | Entity 19 | 20 | // Account id with which the event is associated 21 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 22 | 23 | // Event creation date in millisecond precision 24 | EventCreateDate *Time `json:"eventCreateDate,omitempty" xmlrpc:"eventCreateDate,omitempty"` 25 | 26 | // Event name such as "reboot", "cancel", "update host" and so on. 27 | EventName *string `json:"eventName,omitempty" xmlrpc:"eventName,omitempty"` 28 | 29 | // The remote IP Address that made the request 30 | IpAddress *string `json:"ipAddress,omitempty" xmlrpc:"ipAddress,omitempty"` 31 | 32 | // Label or description of the event object 33 | Label *string `json:"label,omitempty" xmlrpc:"label,omitempty"` 34 | 35 | // Meta data for an event in JSON string 36 | MetaData *string `json:"metaData,omitempty" xmlrpc:"metaData,omitempty"` 37 | 38 | // Event object id 39 | ObjectId *int `json:"objectId,omitempty" xmlrpc:"objectId,omitempty"` 40 | 41 | // Event object name such as "server", "dns" and so on. 42 | ObjectName *string `json:"objectName,omitempty" xmlrpc:"objectName,omitempty"` 43 | 44 | // OpenIdConnectUserName of the customer who initiated the event 45 | OpenIdConnectUserName *string `json:"openIdConnectUserName,omitempty" xmlrpc:"openIdConnectUserName,omitempty"` 46 | 47 | // A resource object that is associated with the event 48 | Resource interface{} `json:"resource,omitempty" xmlrpc:"resource,omitempty"` 49 | 50 | // A unique trace id. Multiple event can be grouped by a trace id. 51 | TraceId *string `json:"traceId,omitempty" xmlrpc:"traceId,omitempty"` 52 | 53 | // no documentation yet 54 | User *User_Customer `json:"user,omitempty" xmlrpc:"user,omitempty"` 55 | 56 | // Id of customer who initiated the event 57 | UserId *int `json:"userId,omitempty" xmlrpc:"userId,omitempty"` 58 | 59 | // Type of user that triggered the event. User type can be CUSTOMER, EMPLOYEE or SYSTEM. 60 | UserType *string `json:"userType,omitempty" xmlrpc:"userType,omitempty"` 61 | 62 | // Customer username who initiated the event 63 | Username *string `json:"username,omitempty" xmlrpc:"username,omitempty"` 64 | } 65 | -------------------------------------------------------------------------------- /datatypes/exception.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // Throw this exception if there are validation errors. The types are specified in SoftLayer_Brand_Creation_Input including: KEY_NAME, PREFIX, NAME, LONG_NAME, SUPPORT_POLICY, POLICY_ACKNOWLEDGEMENT_FLAG, etc. 17 | type Exception_Brand_Creation struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Message *string `json:"message,omitempty" xmlrpc:"message,omitempty"` 22 | 23 | // no documentation yet 24 | Type *string `json:"type,omitempty" xmlrpc:"type,omitempty"` 25 | } 26 | 27 | // This exception is thrown if the component locator client cannot find or communicate with the component locator service. 28 | type Exception_Hardware_Component_Locator_ComponentLocatorException struct { 29 | Entity 30 | } 31 | 32 | // This exception is thrown if the argument is of incorrect type. 33 | type Exception_Hardware_Component_Locator_InvalidGenericComponentArgument struct { 34 | Entity 35 | } 36 | -------------------------------------------------------------------------------- /datatypes/flexiblecredit.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type FlexibleCredit_Affiliate struct { 18 | Entity 19 | 20 | // Flexible Credit Program the affiliate belongs to. 21 | FlexibleCreditProgram *FlexibleCredit_Program `json:"flexibleCreditProgram,omitempty" xmlrpc:"flexibleCreditProgram,omitempty"` 22 | 23 | // Primary ID for the affiliate 24 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 25 | 26 | // Name of this affiliate 27 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 28 | } 29 | 30 | // no documentation yet 31 | type FlexibleCredit_Company_Type struct { 32 | Entity 33 | 34 | // Description of the company type 35 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 36 | 37 | // Primary ID for the company type 38 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 39 | } 40 | 41 | // no documentation yet 42 | type FlexibleCredit_Enrollment struct { 43 | Entity 44 | 45 | // Account the enrollment belongs to 46 | Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"` 47 | 48 | // Account ID associated with this enrollment 49 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 50 | 51 | // Affiliate associated with the account enrollment 52 | Affiliate *FlexibleCredit_Affiliate `json:"affiliate,omitempty" xmlrpc:"affiliate,omitempty"` 53 | 54 | // ID of the corresponding Flexible Credit Program Affiliate 55 | AffiliateId *int `json:"affiliateId,omitempty" xmlrpc:"affiliateId,omitempty"` 56 | 57 | // Indicates signing of Flexible Credit agreement (independent from MSA) 58 | AgreementCompleteFlag *int `json:"agreementCompleteFlag,omitempty" xmlrpc:"agreementCompleteFlag,omitempty"` 59 | 60 | // How much lifetime credit from this enrollment is available for use by the customer, refreshed every 5 minutes. 61 | ApproximateAvailableLifetimeCredit *Float64 `json:"approximateAvailableLifetimeCredit,omitempty" xmlrpc:"approximateAvailableLifetimeCredit,omitempty"` 62 | 63 | // Brief description of the company 64 | CompanyDescription *string `json:"companyDescription,omitempty" xmlrpc:"companyDescription,omitempty"` 65 | 66 | // Category which best describes the company 67 | CompanyType *FlexibleCredit_Company_Type `json:"companyType,omitempty" xmlrpc:"companyType,omitempty"` 68 | 69 | // ID of the Flexible Credit Program Company classification for this enrollment 70 | CompanyTypeId *int `json:"companyTypeId,omitempty" xmlrpc:"companyTypeId,omitempty"` 71 | 72 | // Date when participation in the Flexible Credit program began 73 | EnrollmentDate *Time `json:"enrollmentDate,omitempty" xmlrpc:"enrollmentDate,omitempty"` 74 | 75 | // Discount program the enrollment belongs to 76 | FlexibleCreditProgram *FlexibleCredit_Program `json:"flexibleCreditProgram,omitempty" xmlrpc:"flexibleCreditProgram,omitempty"` 77 | 78 | // Date Flexible Credit Program benefits end. 79 | GraduationDate *Time `json:"graduationDate,omitempty" xmlrpc:"graduationDate,omitempty"` 80 | 81 | // Flag indicating whether an enrollment is active (true) or inactive (false) 82 | IsActiveFlag *bool `json:"isActiveFlag,omitempty" xmlrpc:"isActiveFlag,omitempty"` 83 | 84 | // Amount of monthly credit (USD) given to the account 85 | MonthlyCreditAmount *Float64 `json:"monthlyCreditAmount,omitempty" xmlrpc:"monthlyCreditAmount,omitempty"` 86 | 87 | // Employee overseeing the enrollment 88 | Representative *User_Employee `json:"representative,omitempty" xmlrpc:"representative,omitempty"` 89 | 90 | // ID of the employee representing this account. 91 | RepresentativeEmployeeId *int `json:"representativeEmployeeId,omitempty" xmlrpc:"representativeEmployeeId,omitempty"` 92 | } 93 | 94 | // no documentation yet 95 | type FlexibleCredit_Program struct { 96 | Entity 97 | 98 | // Primary ID of the Flexible Credit Program 99 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 100 | 101 | // Unique name for the Flexible Credit Program 102 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 103 | 104 | // Name of the Flexible Credit Program. 105 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 106 | 107 | // no documentation yet 108 | PlatformPromotionCode *string `json:"platformPromotionCode,omitempty" xmlrpc:"platformPromotionCode,omitempty"` 109 | } 110 | -------------------------------------------------------------------------------- /datatypes/legal.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Legal_RegulatedWorkload struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"` 22 | 23 | // no documentation yet 24 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 25 | 26 | // no documentation yet 27 | EnabledFlag *bool `json:"enabledFlag,omitempty" xmlrpc:"enabledFlag,omitempty"` 28 | 29 | // no documentation yet 30 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 31 | 32 | // no documentation yet 33 | Type *Legal_RegulatedWorkload_Type `json:"type,omitempty" xmlrpc:"type,omitempty"` 34 | 35 | // no documentation yet 36 | WorkloadTypeId *int `json:"workloadTypeId,omitempty" xmlrpc:"workloadTypeId,omitempty"` 37 | } 38 | 39 | // no documentation yet 40 | type Legal_RegulatedWorkload_Type struct { 41 | Entity 42 | 43 | // no documentation yet 44 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 45 | 46 | // no documentation yet 47 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 48 | 49 | // no documentation yet 50 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 51 | } 52 | -------------------------------------------------------------------------------- /datatypes/locale.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Locale struct { 18 | Entity 19 | 20 | // no documentation yet 21 | FriendlyName *string `json:"friendlyName,omitempty" xmlrpc:"friendlyName,omitempty"` 22 | 23 | // Internal identification number of a locale 24 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 25 | 26 | // no documentation yet 27 | LanguageTag *string `json:"languageTag,omitempty" xmlrpc:"languageTag,omitempty"` 28 | 29 | // Locale name 30 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 31 | } 32 | 33 | // no documentation yet 34 | type Locale_Country struct { 35 | Entity 36 | 37 | // Binary flag denoting if this country is part of the European Union 38 | IsEuropeanUnionFlag *int `json:"isEuropeanUnionFlag,omitempty" xmlrpc:"isEuropeanUnionFlag,omitempty"` 39 | 40 | // no documentation yet 41 | IsoCodeAlphaThree *string `json:"isoCodeAlphaThree,omitempty" xmlrpc:"isoCodeAlphaThree,omitempty"` 42 | 43 | // no documentation yet 44 | LongName *string `json:"longName,omitempty" xmlrpc:"longName,omitempty"` 45 | 46 | // no documentation yet 47 | PostalCodeFormat *string `json:"postalCodeFormat,omitempty" xmlrpc:"postalCodeFormat,omitempty"` 48 | 49 | // no documentation yet 50 | PostalCodeRequiredFlag *int `json:"postalCodeRequiredFlag,omitempty" xmlrpc:"postalCodeRequiredFlag,omitempty"` 51 | 52 | // no documentation yet 53 | ShortName *string `json:"shortName,omitempty" xmlrpc:"shortName,omitempty"` 54 | 55 | // A count of states that belong to this country. 56 | StateCount *uint `json:"stateCount,omitempty" xmlrpc:"stateCount,omitempty"` 57 | 58 | // States that belong to this country. 59 | States []Locale_StateProvince `json:"states,omitempty" xmlrpc:"states,omitempty"` 60 | 61 | // no documentation yet 62 | VatIdRegex *string `json:"vatIdRegex,omitempty" xmlrpc:"vatIdRegex,omitempty"` 63 | 64 | // no documentation yet 65 | VatIdRequiredFlag *bool `json:"vatIdRequiredFlag,omitempty" xmlrpc:"vatIdRequiredFlag,omitempty"` 66 | } 67 | 68 | // This object represents a state or province for a country. 69 | type Locale_StateProvince struct { 70 | Entity 71 | 72 | // no documentation yet 73 | LongName *string `json:"longName,omitempty" xmlrpc:"longName,omitempty"` 74 | 75 | // no documentation yet 76 | ShortName *string `json:"shortName,omitempty" xmlrpc:"shortName,omitempty"` 77 | } 78 | 79 | // Each User is assigned a timezone allowing for a precise local timestamp. 80 | type Locale_Timezone struct { 81 | Entity 82 | 83 | // A timezone's identifying number. 84 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 85 | 86 | // A timezone's long name. For example, "(GMT-06:00) America/Dallas - CST". 87 | LongName *string `json:"longName,omitempty" xmlrpc:"longName,omitempty"` 88 | 89 | // A timezone's name. For example, "America/Dallas". 90 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 91 | 92 | // A timezone's offset based on the GMT standard. For example, Central Standard Time's offset is "-0600" from GMT=0000. 93 | Offset *string `json:"offset,omitempty" xmlrpc:"offset,omitempty"` 94 | 95 | // A timezone's common abbreviation. For example, Central Standard Time's abbreviation is "CST". 96 | ShortName *string `json:"shortName,omitempty" xmlrpc:"shortName,omitempty"` 97 | } 98 | -------------------------------------------------------------------------------- /datatypes/monitoring.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // DEPRECATED. The SoftLayer_Monitoring_Robot data type contains general information relating to a monitoring robot. 17 | type Monitoring_Robot struct { 18 | Entity 19 | 20 | // DEPRECATED. Internal identifier of a SoftLayer account that this robot belongs to 21 | // Deprecated: This function has been marked as deprecated. 22 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 23 | 24 | // DEPRECATED. Internal identifier of a monitoring robot 25 | // Deprecated: This function has been marked as deprecated. 26 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 27 | 28 | // DEPRECATED. Robot name 29 | // Deprecated: This function has been marked as deprecated. 30 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 31 | 32 | // DEPRECATED. Internal identifier of a monitoring robot status 33 | // Deprecated: This function has been marked as deprecated. 34 | StatusId *int `json:"statusId,omitempty" xmlrpc:"statusId,omitempty"` 35 | } 36 | 37 | // DEPRECATED. Your monitoring robot will be in "Active" status under normal circumstances. If you perform an OS reload, your robot will be in "Reclaim" status until it's reloaded on your server or virtual server. 38 | // 39 | // Advanced monitoring system requires "Nimsoft Monitoring (Advanced)" service running and TCP ports 48000 - 48020 to be open on your server or virtual server. Monitoring agents cannot be managed nor can the usage data be updated if these ports are closed. Your monitoring robot will be in "Limited Connectivity" status if our monitoring management system cannot communicate with your system. 40 | // 41 | // See [[SoftLayer_Monitoring_Robot::resetStatus|resetStatus]] service for more details. 42 | type Monitoring_Robot_Status struct { 43 | Entity 44 | 45 | // DEPRECATED. Monitoring robot status description 46 | // Deprecated: This function has been marked as deprecated. 47 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 48 | 49 | // DEPRECATED. Internal identifier of a monitoring robot status 50 | // Deprecated: This function has been marked as deprecated. 51 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 52 | 53 | // DEPRECATED. Monitoring robot status name 54 | // Deprecated: This function has been marked as deprecated. 55 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /datatypes/policy.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // The SoftLayer_Billing_Oder_Quote data type records acceptance of policy documents for a quote. 17 | type Policy_Document_Acceptance_Quote struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Resource *Billing_Order_Quote `json:"resource,omitempty" xmlrpc:"resource,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /datatypes/sales.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // The presale event data types indicate the information regarding an individual presale event. The ”'locationId”' will indicate the datacenter associated with the presale event. The ”'itemId”' will indicate the product item associated with a particular presale event - however these are more rare. The ”'startDate”' and ”'endDate”' will provide information regarding when the presale event is available for use. At the end of the presale event, the server or services purchased will be available once approved and provisioned. 17 | type Sales_Presale_Event struct { 18 | Entity 19 | 20 | // A flag to indicate that the presale event is currently active. A presale event is active if the current time is between the start and end dates. 21 | ActiveFlag *bool `json:"activeFlag,omitempty" xmlrpc:"activeFlag,omitempty"` 22 | 23 | // Description of the presale event. 24 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 25 | 26 | // End date of the presale event. Orders can be approved and provisioned after this date. 27 | EndDate *Time `json:"endDate,omitempty" xmlrpc:"endDate,omitempty"` 28 | 29 | // A flag to indicate that the presale event is expired. A presale event is expired if the current time is after the end date. 30 | ExpiredFlag *bool `json:"expiredFlag,omitempty" xmlrpc:"expiredFlag,omitempty"` 31 | 32 | // Presale event unique identifier. 33 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 34 | 35 | // The [[SoftLayer_Product_Item]] associated with the presale event. 36 | Item *Product_Item `json:"item,omitempty" xmlrpc:"item,omitempty"` 37 | 38 | // [[SoftLayer_Product_Item]] id associated with the presale event. 39 | ItemId *int `json:"itemId,omitempty" xmlrpc:"itemId,omitempty"` 40 | 41 | // The [[SoftLayer_Location]] associated with the presale event. 42 | Location *Location `json:"location,omitempty" xmlrpc:"location,omitempty"` 43 | 44 | // [[SoftLayer_Location]] id for the presale event. 45 | LocationId *int `json:"locationId,omitempty" xmlrpc:"locationId,omitempty"` 46 | 47 | // A count of the orders ([[SoftLayer_Billing_Order]]) associated with this presale event that were created for the customer's account. 48 | OrderCount *uint `json:"orderCount,omitempty" xmlrpc:"orderCount,omitempty"` 49 | 50 | // The orders ([[SoftLayer_Billing_Order]]) associated with this presale event that were created for the customer's account. 51 | Orders []Billing_Order `json:"orders,omitempty" xmlrpc:"orders,omitempty"` 52 | 53 | // Start date of the presale event. Orders cannot be approved before this date. 54 | StartDate *Time `json:"startDate,omitempty" xmlrpc:"startDate,omitempty"` 55 | } 56 | -------------------------------------------------------------------------------- /datatypes/scale.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 19 | */ 20 | 21 | package datatypes 22 | 23 | // no documentation yet 24 | type Scale_Asset struct { 25 | Entity 26 | } 27 | 28 | // no documentation yet 29 | type Scale_Asset_Hardware struct { 30 | Scale_Asset 31 | } 32 | 33 | // no documentation yet 34 | type Scale_Asset_Virtual_Guest struct { 35 | Scale_Asset 36 | } 37 | 38 | // no documentation yet 39 | type Scale_Group struct { 40 | Entity 41 | 42 | // The identifier of the account assigned to this group. 43 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 44 | } 45 | 46 | // no documentation yet 47 | type Scale_LoadBalancer struct { 48 | Entity 49 | 50 | // The identifier for the health check of this load balancer configuration 51 | HealthCheckId *int `json:"healthCheckId,omitempty" xmlrpc:"healthCheckId,omitempty"` 52 | } 53 | 54 | // no documentation yet 55 | type Scale_Member struct { 56 | Entity 57 | } 58 | 59 | // no documentation yet 60 | type Scale_Member_Virtual_Guest struct { 61 | Scale_Member 62 | } 63 | 64 | // no documentation yet 65 | type Scale_Network_Vlan struct { 66 | Entity 67 | 68 | // The identifier for the VLAN to scale with. 69 | NetworkVlanId *int `json:"networkVlanId,omitempty" xmlrpc:"networkVlanId,omitempty"` 70 | } 71 | -------------------------------------------------------------------------------- /datatypes/search.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Search struct { 18 | Entity 19 | } 20 | -------------------------------------------------------------------------------- /datatypes/service.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // The SoftLayer_Service_External_Resource is a placeholder that references a service being provided outside of the standard SoftLayer system. 17 | type Service_External_Resource struct { 18 | Entity 19 | 20 | // The customer account that is consuming the service. 21 | Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"` 22 | 23 | // The customer account that is consuming the related service. 24 | AccountId *int `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 25 | 26 | // The unique identifier in the service provider's system. 27 | ExternalIdentifier *string `json:"externalIdentifier,omitempty" xmlrpc:"externalIdentifier,omitempty"` 28 | 29 | // An external resource's unique identifier in the SoftLayer system. 30 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 31 | } 32 | 33 | // no documentation yet 34 | type Service_Provider struct { 35 | Entity 36 | 37 | // no documentation yet 38 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 39 | 40 | // no documentation yet 41 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 42 | 43 | // no documentation yet 44 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 45 | 46 | // no documentation yet 47 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /datatypes/softlayer_test.go: -------------------------------------------------------------------------------- 1 | package datatypes 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestSearchUnmarshal(t *testing.T) { 9 | jsonString := []byte(`{ 10 | "resourceType":"SoftLayer_Virtual_Guest", 11 | "resource": { 12 | "hostname": "test", 13 | "domain": "atest.com", 14 | "id": 1234, 15 | "accountId": 111111 16 | }, 17 | "relevanceScore": "12.3" 18 | 19 | }`) 20 | fmt.Printf("TESTING\n") 21 | var result Container_Search_Result 22 | err := result.UnmarshalJSON(jsonString) 23 | if err != nil { 24 | t.Errorf("There was an error! %v\n", err) 25 | } 26 | if *result.ResourceType != "SoftLayer_Virtual_Guest" { 27 | t.Errorf("Failed to get resource type\n%v != SoftLayer_Virtual_Guest\n", result.ResourceType) 28 | } 29 | fmt.Printf("%+v\n", result.Resource) 30 | 31 | test := result.Resource 32 | if *test.(*Virtual_Guest).Hostname != "test" { 33 | t.Errorf("Failed to get a resource!\n%v != 'test'\n", result.Resource) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /datatypes/sprint.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Sprint_Container_CostRecovery struct { 18 | Entity 19 | 20 | // no documentation yet 21 | AccountId *string `json:"accountId,omitempty" xmlrpc:"accountId,omitempty"` 22 | 23 | // no documentation yet 24 | AccountType *string `json:"accountType,omitempty" xmlrpc:"accountType,omitempty"` 25 | 26 | // no documentation yet 27 | Country *string `json:"country,omitempty" xmlrpc:"country,omitempty"` 28 | 29 | // no documentation yet 30 | DateClosed *string `json:"dateClosed,omitempty" xmlrpc:"dateClosed,omitempty"` 31 | 32 | // no documentation yet 33 | Department *string `json:"department,omitempty" xmlrpc:"department,omitempty"` 34 | 35 | // no documentation yet 36 | Division *string `json:"division,omitempty" xmlrpc:"division,omitempty"` 37 | 38 | // no documentation yet 39 | Status *string `json:"status,omitempty" xmlrpc:"status,omitempty"` 40 | } 41 | -------------------------------------------------------------------------------- /datatypes/trellix.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // The Trellix_Epolicy_Orchestrator_Version51_Agent_Details data type represents a virus scan agent and contains details about its version. 17 | type Trellix_Epolicy_Orchestrator_Version51_Agent_Details struct { 18 | Entity 19 | 20 | // Version number of the anti-virus scan agent. 21 | AgentVersion *string `json:"agentVersion,omitempty" xmlrpc:"agentVersion,omitempty"` 22 | 23 | // The date of the last time the anti-virus agent checked in. 24 | LastUpdate *Time `json:"lastUpdate,omitempty" xmlrpc:"lastUpdate,omitempty"` 25 | } 26 | 27 | // The Trellix_Epolicy_Orchestrator_Version51_Policy_Object data type represents a virus scan agent and contains details about its version. 28 | type Trellix_Epolicy_Orchestrator_Version51_Policy_Object struct { 29 | Entity 30 | 31 | // no documentation yet 32 | Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"` 33 | } 34 | 35 | // The Trellix_Epolicy_Orchestrator_Version51_Product_Properties data type represents the version of the virus data file 36 | type Trellix_Epolicy_Orchestrator_Version51_Product_Properties struct { 37 | Entity 38 | 39 | // no documentation yet 40 | DatVersion *string `json:"datVersion,omitempty" xmlrpc:"datVersion,omitempty"` 41 | } 42 | -------------------------------------------------------------------------------- /datatypes/utility.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Utility_Network struct { 18 | Entity 19 | } 20 | 21 | // no documentation yet 22 | type Utility_ObjectFilter struct { 23 | Entity 24 | } 25 | 26 | // no documentation yet 27 | type Utility_ObjectFilter_Operation struct { 28 | Entity 29 | } 30 | 31 | // no documentation yet 32 | type Utility_ObjectFilter_Operation_Option struct { 33 | Entity 34 | } 35 | -------------------------------------------------------------------------------- /datatypes/vendor.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Vendor_Type struct { 18 | Entity 19 | 20 | // no documentation yet 21 | Description *string `json:"description,omitempty" xmlrpc:"description,omitempty"` 22 | 23 | // no documentation yet 24 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 25 | 26 | // no documentation yet 27 | KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /datatypes/verify.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package datatypes 15 | 16 | // no documentation yet 17 | type Verify_Api_HttpObj struct { 18 | Entity 19 | 20 | // no documentation yet 21 | CreateDate *Time `json:"createDate,omitempty" xmlrpc:"createDate,omitempty"` 22 | 23 | // no documentation yet 24 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 25 | 26 | // no documentation yet 27 | ModifyDate *Time `json:"modifyDate,omitempty" xmlrpc:"modifyDate,omitempty"` 28 | 29 | // no documentation yet 30 | TestString *string `json:"testString,omitempty" xmlrpc:"testString,omitempty"` 31 | } 32 | 33 | // no documentation yet 34 | type Verify_Api_HttpsObj struct { 35 | Entity 36 | 37 | // no documentation yet 38 | CreateDate *Time `json:"createDate,omitempty" xmlrpc:"createDate,omitempty"` 39 | 40 | // no documentation yet 41 | Id *int `json:"id,omitempty" xmlrpc:"id,omitempty"` 42 | 43 | // no documentation yet 44 | ModifyDate *Time `json:"modifyDate,omitempty" xmlrpc:"modifyDate,omitempty"` 45 | 46 | // no documentation yet 47 | TestString *string `json:"testString,omitempty" xmlrpc:"testString,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /examples/cmd/iam_demo.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "github.com/spf13/cobra" 6 | "time" 7 | 8 | "github.com/softlayer/softlayer-go/services" 9 | "github.com/softlayer/softlayer-go/session" 10 | ) 11 | 12 | func init() { 13 | rootCmd.AddCommand(iamDemoCmd) 14 | } 15 | 16 | var iamDemoCmd = &cobra.Command{ 17 | Use: "iam-demo", 18 | Short: "Will make 1 API call per minute and refresh API key when needed.", 19 | RunE: func(cmd *cobra.Command, args []string) error { 20 | return RunIamCmd(cmd, args) 21 | }, 22 | } 23 | 24 | func RunIamCmd(cmd *cobra.Command, args []string) error { 25 | objectMask := "mask[id,companyName]" 26 | 27 | // Sets up the session with authentication headers. 28 | sess := &session.Session{ 29 | Endpoint: session.DefaultEndpoint, 30 | IAMToken: "Bearer TOKEN", 31 | IAMRefreshToken: "REFRESH TOKEN", 32 | Debug: true, 33 | } 34 | 35 | // creates a reference to the service object (SoftLayer_Account) 36 | service := services.GetAccountService(sess) 37 | 38 | // Sets the mask, filter, result limit, and then makes the API call SoftLayer_Account::getHardware() 39 | 40 | for { 41 | account, err := service.Mask(objectMask).GetObject() 42 | if err != nil { 43 | fmt.Printf("======= ERROR ======") 44 | return err 45 | } 46 | fmt.Printf("AccountId: %v, CompanyName: %v\n", *account.Id, *account.CompanyName) 47 | fmt.Printf("Refreshing Token for no reason...\n") 48 | sess.RefreshToken() 49 | fmt.Printf("%s\n", sess.IAMToken) 50 | fmt.Printf("Sleeping for 60s.......\n") 51 | time.Sleep(60 * time.Second) 52 | } 53 | 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /examples/cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | ) 6 | 7 | var ( 8 | rootCmd = &cobra.Command{ 9 | Use: "sl", 10 | Short: "An example CLI application for working with IBM Classic Infrastructure", 11 | Long: `A collection of example commands that can be easily used to better understand how 12 | the SoftLayer API works in golang. Authentication is set with the SL_USERNAME and SL_API_KEY env variables, or the 13 | ~/.softlayer config file.`, 14 | } 15 | ) 16 | 17 | // Execute executes the root command. 18 | func Execute() error { 19 | return rootCmd.Execute() 20 | } 21 | 22 | func init() { 23 | 24 | } 25 | 26 | func initConfig() { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /examples/cmd/server_list.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/softlayer/softlayer-go/filter" 9 | "github.com/softlayer/softlayer-go/services" 10 | "github.com/softlayer/softlayer-go/session" 11 | ) 12 | 13 | func init() { 14 | rootCmd.AddCommand(listServerCmd) 15 | } 16 | 17 | var listServerCmd = &cobra.Command{ 18 | Use: "server-list", 19 | Short: "Lists all servers on the account", 20 | Long: `Lists all servers on the account`, 21 | RunE: func(cmd *cobra.Command, args []string) error { 22 | return Run(cmd, args) 23 | }, 24 | } 25 | 26 | func Run(cmd *cobra.Command, args []string) error { 27 | resultLimit := 5 28 | resultOffset := 0 29 | objectMask := "mask[id,hostname,domain,primaryIpAddress,primaryBackendIpAddress]" 30 | // When using a result Limit to break up your API request, its important to include an orderBy objectFilter 31 | // to enforce an order on the query, as the database might not always return results in the same order between 32 | // queries otherwise 33 | filters := filter.New() 34 | filters = append(filters, filter.Path("hardware.id").OrderBy("ASC")) 35 | objectFilter := filters.Build() 36 | // Sets up the session with authentication headers. 37 | sess := session.New() 38 | // uncomment to output API calls as they are made. 39 | // sess.Debug = true 40 | 41 | // creates a reference to the service object (SoftLayer_Account) 42 | service := services.GetAccountService(sess) 43 | 44 | // Sets the mask, filter, result limit, and then makes the API call SoftLayer_Account::getHardware() 45 | servers, err := service.Mask(objectMask).Filter(objectFilter). 46 | Offset(resultOffset).Limit(resultLimit).GetHardware() 47 | if err != nil { 48 | return err 49 | } 50 | fmt.Printf("Id, Hostname, Domain, IP Address\n") 51 | for { 52 | for _, server := range servers { 53 | ipAddress := "-" 54 | // Servers with a private only connection will not have a primary IP 55 | if server.PrimaryIpAddress != nil { 56 | ipAddress = *server.PrimaryIpAddress 57 | } 58 | fmt.Printf("%v, %v, %v, %v\n", *server.Id, *server.Hostname, *server.Domain, ipAddress) 59 | } 60 | // If we get less than the number of results we asked for, we are at the end of our server list 61 | if len(servers) < resultLimit { 62 | break 63 | } 64 | // Increment the offset to get next set of results 65 | resultOffset = resultOffset + resultLimit 66 | servers, err = service.Mask(objectMask).Filter(objectFilter). 67 | Offset(resultOffset).Limit(resultLimit).GetHardware() 68 | if err != nil { 69 | return err 70 | } 71 | } 72 | 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /examples/cmd/virtual_iter.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/softlayer/softlayer-go/filter" 9 | "github.com/softlayer/softlayer-go/helpers/virtual" 10 | "github.com/softlayer/softlayer-go/session" 11 | "github.com/softlayer/softlayer-go/sl" 12 | ) 13 | 14 | func init() { 15 | rootCmd.AddCommand(listVirtCmd) 16 | } 17 | 18 | var listVirtCmd = &cobra.Command{ 19 | Use: "virt-list", 20 | Short: "Lists all VSI on the account", 21 | Long: `Lists all VSI on the account using an iterative aproach.`, 22 | RunE: func(cmd *cobra.Command, args []string) error { 23 | return RunListVirtCmd(cmd, args) 24 | }, 25 | } 26 | 27 | func RunListVirtCmd(cmd *cobra.Command, args []string) error { 28 | 29 | objectMask := "mask[id,hostname,domain,primaryIpAddress,primaryBackendIpAddress]" 30 | // When using a result Limit to break up your API request, its important to include an orderBy objectFilter 31 | // to enforce an order on the query, as the database might not always return results in the same order between 32 | // queries otherwise 33 | filters := filter.New() 34 | filters = append(filters, filter.Path("virtualGuests.id").OrderBy("ASC")) 35 | objectFilter := filters.Build() 36 | // Sets up the session with authentication headers. 37 | sess := session.New() 38 | // uncomment to output API calls as they are made. 39 | sess.Debug = true 40 | 41 | // Sets the mask, filter, result limit, and then makes the API call SoftLayer_Account::getHardware() 42 | limit := 5 43 | options := sl.Options{ 44 | Mask: objectMask, 45 | Filter: objectFilter, 46 | Limit: &limit, 47 | } 48 | 49 | servers, err := virtual.GetVirtualGuestsIter(sess, &options) 50 | if err != nil { 51 | return err 52 | } 53 | fmt.Printf("Id, Hostname, Domain, IP Address\n") 54 | 55 | for _, server := range servers { 56 | ipAddress := "-" 57 | // Servers with a private only connection will not have a primary IP 58 | if server.PrimaryIpAddress != nil { 59 | ipAddress = *server.PrimaryIpAddress 60 | } 61 | fmt.Printf("%v, %v, %v, %v\n", *server.Id, *server.Hostname, *server.Domain, ipAddress) 62 | } 63 | 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /examples/cmd/vlan_detail.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strconv" 7 | 8 | "github.com/jedib0t/go-pretty/v6/table" 9 | "github.com/spf13/cobra" 10 | 11 | "github.com/softlayer/softlayer-go/services" 12 | "github.com/softlayer/softlayer-go/session" 13 | ) 14 | 15 | func init() { 16 | rootCmd.AddCommand(detailVlanCmd) 17 | } 18 | 19 | var detailVlanCmd = &cobra.Command{ 20 | Use: "vlan-detail [vlanId]", 21 | Short: "Vlan Details", 22 | Long: `Gets a lot of information about a VLAN`, 23 | Args: func(cmd *cobra.Command, args []string) error { 24 | if len(args) < 1 { 25 | return errors.New("a VLAN ID is required") 26 | } 27 | return nil 28 | }, 29 | RunE: func(cmd *cobra.Command, args []string) error { 30 | return VlanDetailCommand(cmd, args) 31 | }, 32 | } 33 | 34 | func VlanDetailCommand(cmd *cobra.Command, args []string) error { 35 | objectMask := `mask[id,name,vlanNumber,primaryRouter[id,hostname,datacenterName,datacenter[name]], 36 | subnets[id,networkIdentifier,note, subnetType]]` 37 | 38 | // Sets up the softlayer-client session and Service 39 | sess := session.New() 40 | // sess.Debug = true 41 | service := services.GetNetworkVlanService(sess) 42 | 43 | // Make sure vlanId is an int 44 | vlanId, err := strconv.Atoi(args[0]) 45 | if err != nil { 46 | return err 47 | } 48 | 49 | // Get the VLAN object from the API https://sldn.softlayer.com/reference/services/SoftLayer_Network_Vlan/getObject/ 50 | vlan, err := service.Mask(objectMask).Id(vlanId).GetObject() 51 | if err != nil { 52 | return err 53 | } 54 | 55 | // https://github.com/jedib0t/go-pretty/tree/main/table 56 | // A fancy table builder so our output can look nice. 57 | t := table.NewWriter() 58 | t.SetOutputMirror(os.Stdout) 59 | t.AppendHeader(table.Row{"Property", "Value"}) 60 | 61 | t.AppendRow([]interface{}{"Id", *vlan.Id}) 62 | t.AppendRow([]interface{}{"Number", *vlan.VlanNumber}) 63 | t.AppendRow([]interface{}{"Name", *vlan.Name}) 64 | t.AppendRow([]interface{}{"Datacenter", *vlan.PrimaryRouter.DatacenterName}) 65 | t.AppendRow([]interface{}{"Primary Router", *vlan.PrimaryRouter.Hostname}) 66 | 67 | if len(vlan.Subnets) > 0 { 68 | subnetTable := table.NewWriter() 69 | subnetTable.AppendHeader(table.Row{"Id", "Network", "Type", "Note"}) 70 | for _, subnet := range vlan.Subnets { 71 | note := "-" 72 | // Subnets do not always have notes, this is required to avoid invalid memory address errors 73 | if subnet.Note != nil { 74 | note = *subnet.Note 75 | } 76 | subnetTable.AppendRow([]interface{}{*subnet.Id, *subnet.NetworkIdentifier, *subnet.SubnetType, note}) 77 | } 78 | // Renders the subnet table to the main table instead of main output 79 | t.AppendRow([]interface{}{"Subnets", subnetTable.Render()}) 80 | } 81 | // Prints out the table 82 | t.Render() 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /examples/cmd/vlan_list.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | 8 | "github.com/softlayer/softlayer-go/filter" 9 | "github.com/softlayer/softlayer-go/services" 10 | "github.com/softlayer/softlayer-go/session" 11 | ) 12 | 13 | func init() { 14 | listVlanCmd.Flags().StringVarP(&Datacenter, "datacenter", "d", "", "List only VLANs from this datacenter") 15 | rootCmd.AddCommand(listVlanCmd) 16 | } 17 | 18 | var Datacenter string 19 | var listVlanCmd = &cobra.Command{ 20 | Use: "vlan-list", 21 | Short: "Lists all vlans on the account", 22 | Long: `Lists all vlans on the account`, 23 | RunE: func(cmd *cobra.Command, args []string) error { 24 | return VlanListCommand(cmd, args) 25 | }, 26 | } 27 | 28 | func VlanListCommand(cmd *cobra.Command, args []string) error { 29 | resultLimit := 50 30 | resultOffset := 0 31 | objectMask := "mask[id,name,vlanNumber,primaryRouter[id,hostname,datacenterName,datacenter[name]]]" 32 | // When using a result Limit to break up your API request, its important to include an orderBy objectFilter 33 | // to enforce an order on the query, as the database might not always return results in the same order between 34 | // queries otherwise 35 | filters := filter.New() 36 | filters = append(filters, filter.Path("networkVlans.id").OrderBy("DESC")) 37 | if Datacenter != "" { 38 | filters = append(filters, filter.Path("networkVlans.primaryRouter.datacenter.name").Eq(Datacenter)) 39 | } 40 | objectFilter := filters.Build() 41 | 42 | // Sets up the session with authentication headers. 43 | sess := session.New() 44 | // uncomment to output API calls as they are made. 45 | // sess.Debug = true 46 | 47 | // creates a reference to the service object (SoftLayer_Account) 48 | service := services.GetAccountService(sess) 49 | 50 | // Sets the mask, filter, result limit, and then makes the API call SoftLayer_Account::getNetworkVlans() 51 | vlans, err := service.Mask(objectMask).Filter(objectFilter). 52 | Offset(resultOffset).Limit(resultLimit).GetNetworkVlans() 53 | if err != nil { 54 | return err 55 | } 56 | fmt.Printf("Id, VLAN, Name, Datacenter\n") 57 | for { 58 | for _, vlan := range vlans { 59 | name := "-" 60 | // The Name property doesn't get returned if the vlan hasn't been named, which will cause a 61 | // 'panic: runtime error: invalid memory address' error if we dont check first. 62 | if vlan.Name != nil { 63 | name = *vlan.Name 64 | } 65 | fmt.Printf("%v, %v, %v, %v\n", *vlan.Id, name, *vlan.VlanNumber, *vlan.PrimaryRouter.Datacenter.Name) 66 | } 67 | // If we get less than the number of results we asked for, we are at the end of our server list 68 | if len(vlans) < resultLimit { 69 | break 70 | } 71 | // Increment the offset to get next set of results 72 | resultOffset = resultOffset + resultLimit 73 | 74 | vlans, err = service.Mask(objectMask).Filter(objectFilter). 75 | Offset(resultOffset).Limit(resultLimit).GetNetworkVlans() 76 | if err != nil { 77 | return err 78 | } 79 | } 80 | 81 | return nil 82 | } 83 | -------------------------------------------------------------------------------- /examples/cmd/vlan_name.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strconv" 7 | 8 | "github.com/spf13/cobra" 9 | 10 | "github.com/softlayer/softlayer-go/datatypes" 11 | "github.com/softlayer/softlayer-go/services" 12 | "github.com/softlayer/softlayer-go/session" 13 | ) 14 | 15 | func init() { 16 | vlanNameCmd.Flags().StringVarP(&VlanName, "name", "n", "", "New VLAN name") 17 | vlanNameCmd.Flags().StringVarP(&VlanNote, "note", "t", "", "Vlan Note") 18 | vlanNameCmd.MarkFlagRequired("name") 19 | rootCmd.AddCommand(vlanNameCmd) 20 | } 21 | 22 | var VlanName string 23 | var VlanNote string 24 | var vlanNameCmd = &cobra.Command{ 25 | Use: "vlan-name [vlanId]", 26 | Short: "Set a VLAN's name and note", 27 | Long: `Set a VLAN's name and note.`, 28 | Args: func(cmd *cobra.Command, args []string) error { 29 | if len(args) < 1 { 30 | return errors.New("a VLAN ID is required") 31 | } 32 | return nil 33 | }, 34 | RunE: func(cmd *cobra.Command, args []string) error { 35 | return VlanNameCommand(cmd, args) 36 | }, 37 | } 38 | 39 | func VlanNameCommand(cmd *cobra.Command, args []string) error { 40 | // Sets up the softlayer-client session and Service 41 | sess := session.New() 42 | // sess.Debug = true 43 | service := services.GetNetworkVlanService(sess) 44 | 45 | // Make sure vlanId is an int 46 | vlanId, err := strconv.Atoi(args[0]) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | // https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan/ 52 | // only Name and Note are editable on a Vlan object. 53 | vlanSkel := datatypes.Network_Vlan{ 54 | Name: &VlanName, 55 | Note: &VlanNote, 56 | } 57 | // https://sldn.softlayer.com/reference/services/SoftLayer_Network_Vlan/editObject/ 58 | _, err = service.Id(vlanId).EditObject(&vlanSkel) 59 | if err != nil { 60 | return err 61 | } 62 | fmt.Printf("Set name of VLan %v to %v with note %v\n", vlanId, VlanName, VlanNote) 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /examples/cmd/vlan_order.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/spf13/cobra" 8 | 9 | "github.com/softlayer/softlayer-go/datatypes" 10 | "github.com/softlayer/softlayer-go/services" 11 | "github.com/softlayer/softlayer-go/session" 12 | "github.com/softlayer/softlayer-go/sl" 13 | ) 14 | 15 | func init() { 16 | orderVlanCmd.Flags().StringVarP(&Location, "datacenter", "d", "", "Datacenter name to order in (like dal13)") 17 | orderVlanCmd.Flags().StringVarP(&Name, "name", "n", "", "Name of this new vlan") 18 | orderVlanCmd.Flags().IntVarP(&RouterId, "routerId", "r", 0, "RouterId if you want this vlan in a specific POD in a datacenter") 19 | rootCmd.AddCommand(orderVlanCmd) 20 | } 21 | 22 | var Location string 23 | var Name string 24 | var RouterId int 25 | 26 | var orderVlanCmd = &cobra.Command{ 27 | Use: "vlan-order", 28 | Short: "Orders a Vlan", 29 | Long: `Orders a vlan with 32 static public IP addresses.`, 30 | RunE: func(cmd *cobra.Command, args []string) error { 31 | return VlanOrderCommand(cmd, args) 32 | }, 33 | } 34 | 35 | func VlanOrderCommand(cmd *cobra.Command, args []string) error { 36 | // Declare the properties like complexType, location, packageId and quantity for the 37 | // vlan you wish to order 38 | quantity := 1 39 | packageId := 0 40 | sendQuoteEmailFlag := true 41 | 42 | // Build a skeleton SoftLayer_Product_Item_Price objects. To get the list of valid 43 | // prices for the package use the SoftLayer_Product_Package:getItems method 44 | itemPrices := []datatypes.Product_Item_Price{ 45 | {Id: sl.Int(2018)}, // Price for the new Public Network Vlan 46 | {Id: sl.Int(1092)}, // Price for 32 Static Public IP Addresses 47 | } 48 | 49 | // Create a session 50 | sess := session.New() 51 | 52 | // Get SoftLayer_Product_Order service 53 | service := services.GetProductOrderService(sess) 54 | 55 | // Build the Container_Product_Order_Network_Vlan containing the order you wish to place. 56 | orderTemplate := datatypes.Container_Product_Order_Network_Vlan{ 57 | Container_Product_Order: datatypes.Container_Product_Order{ 58 | Prices: itemPrices, 59 | PackageId: sl.Int(packageId), 60 | Location: sl.String(Location), 61 | Quantity: sl.Int(quantity), 62 | SendQuoteEmailFlag: sl.Bool(sendQuoteEmailFlag), 63 | }, 64 | Name: sl.String(Name), 65 | } 66 | 67 | if RouterId > 0 { 68 | orderTemplate.RouterId = sl.Int(RouterId) 69 | } 70 | 71 | // Use verifyOrder() method to check for errors. Replace this with placeOrder() when 72 | // you are ready to order. 73 | receipt, err := service.VerifyOrder(&orderTemplate) 74 | if err != nil { 75 | fmt.Printf("Unable to place order:\n - %s\n", err) 76 | return err 77 | } 78 | 79 | // Following helps to print the result in json format. 80 | jsonFormat, jsonErr := json.MarshalIndent(receipt, "", " ") 81 | if jsonErr != nil { 82 | fmt.Println(jsonErr) 83 | return jsonErr 84 | } 85 | 86 | fmt.Println(string(jsonFormat)) 87 | return nil 88 | } 89 | -------------------------------------------------------------------------------- /examples/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/softlayer/softlayer-go/examples 2 | 3 | go 1.21 4 | 5 | replace github.com/softlayer/softlayer-go => ../ 6 | 7 | require ( 8 | github.com/jedib0t/go-pretty/v6 v6.5.4 9 | github.com/softlayer/softlayer-go v1.1.3 10 | github.com/spf13/cobra v1.8.0 11 | ) 12 | 13 | require ( 14 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 15 | github.com/mattn/go-runewidth v0.0.15 // indirect 16 | github.com/rivo/uniseg v0.2.0 // indirect 17 | github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect 18 | github.com/spf13/pflag v1.0.5 // indirect 19 | golang.org/x/net v0.23.0 // indirect 20 | golang.org/x/sys v0.18.0 // indirect 21 | golang.org/x/text v0.14.0 // indirect 22 | ) 23 | -------------------------------------------------------------------------------- /examples/go.sum: -------------------------------------------------------------------------------- 1 | github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= 5 | github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 6 | github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= 7 | github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= 8 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 9 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 10 | github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= 11 | github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= 12 | github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 13 | github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 14 | github.com/jarcoal/httpmock v1.0.5 h1:cHtVEcTxRSX4J0je7mWPfc9BpDpqzXSJ5HbymZmyHck= 15 | github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= 16 | github.com/jedib0t/go-pretty/v6 v6.5.4 h1:gOGo0613MoqUcf0xCj+h/V3sHDaZasfv152G6/5l91s= 17 | github.com/jedib0t/go-pretty/v6 v6.5.4/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg= 18 | github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= 19 | github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 20 | github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= 21 | github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= 22 | github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= 23 | github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= 24 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 25 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 26 | github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= 27 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 28 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 29 | github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e h1:3OgWYFw7jxCZPcvAg+4R8A50GZ+CCkARF10lxu2qDsQ= 30 | github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e/go.mod h1:fKZCUVdirrxrBpwd9wb+lSoVixvpwAu8eHzbQB2tums= 31 | github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= 32 | github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= 33 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 34 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 35 | github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= 36 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 37 | golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= 38 | golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= 39 | golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= 40 | golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 41 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= 42 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 43 | golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= 44 | golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= 45 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 46 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 47 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 48 | -------------------------------------------------------------------------------- /examples/helpers.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/softlayer/softlayer-go/datatypes" 23 | "github.com/softlayer/softlayer-go/helpers/location" 24 | "github.com/softlayer/softlayer-go/helpers/order" 25 | "github.com/softlayer/softlayer-go/services" 26 | "github.com/softlayer/softlayer-go/session" 27 | ) 28 | 29 | func testHelpers() { 30 | sess := session.New() // default endpoint 31 | 32 | sess.Debug = true 33 | 34 | // Demonstrate order status helpers using a simulated product order receipt 35 | 36 | // First, get any valid order item ID 37 | items, err := services.GetAccountService(sess). 38 | Mask("orderItemId"). 39 | GetNextInvoiceTopLevelBillingItems() 40 | 41 | // Create a receipt object to pass to the method 42 | receipt := datatypes.Container_Product_Order_Receipt{ 43 | PlacedOrder: &datatypes.Billing_Order{ 44 | Items: []datatypes.Billing_Order_Item{ 45 | datatypes.Billing_Order_Item{ 46 | Id: items[0].OrderItemId, 47 | }, 48 | }, 49 | }, 50 | } 51 | 52 | complete, _, err := order.CheckBillingOrderStatus(sess, &receipt, []string{"COMPLETE", "PENDING"}) 53 | if err != nil { 54 | fmt.Println(err) 55 | } else { 56 | fmt.Printf("Order in COMPLETE or PENDING status: %t\n", complete) 57 | } 58 | 59 | complete, _, err = order.CheckBillingOrderStatus(sess, &receipt, []string{"PENDING", "CANCELLED"}) 60 | if err != nil { 61 | fmt.Println(err) 62 | } else { 63 | fmt.Printf("Order in CANCELLED or PENDING status: %t\n", complete) 64 | } 65 | 66 | complete, _, err = order.CheckBillingOrderComplete(sess, &receipt) 67 | if err != nil { 68 | fmt.Println(err) 69 | } else { 70 | fmt.Printf("Order is Complete: %t\n", complete) 71 | } 72 | 73 | // Demonstrate GetDataCenterByName 74 | 75 | l, err := location.GetDatacenterByName(sess, "ams01") 76 | fmt.Printf("Found Datacenter: %d\n", *l.Id) 77 | } 78 | -------------------------------------------------------------------------------- /examples/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | // "github.com/spf13/cobra" 5 | "github.com/softlayer/softlayer-go/examples/cmd" 6 | ) 7 | 8 | func main() { 9 | cmd.Execute() 10 | } 11 | -------------------------------------------------------------------------------- /filter/filters_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package filter 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestFilter(t *testing.T) { 24 | var actual, expected string 25 | 26 | expected = `{"virtualGuests":{"hostname":{"operation":"example.com"}}}` 27 | actual = Path("virtualGuests.hostname").Eq("example.com").Build() 28 | if actual != expected { 29 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 30 | } 31 | 32 | expected = `{"datacenter":{"locationName":{"operation":"Dallas"}},"id":{"operation":"134"},"something":{"creationDate":{"operation":"isDate","options":[{"name":"date","value":["01/01/01"]}]}}}` 33 | actual = New( 34 | Path("id").Eq("134"), 35 | Path("datacenter.locationName").Eq("Dallas"), 36 | Path("something.creationDate").Date("01/01/01"), 37 | ).Build() 38 | if actual != expected { 39 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 40 | } 41 | 42 | expected = `{"virtualGuests":{"domain":{"operation":"example.com"},"id":{"operation":"!= 12345"}}}` 43 | actual = Build( 44 | Path("virtualGuests.domain").Eq("example.com"), 45 | Path("virtualGuests.id").NotEq(12345), 46 | ) 47 | if actual != expected { 48 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 49 | } 50 | 51 | filters := New( 52 | Path("virtualGuests.hostname").StartsWith("KM078"), 53 | Path("virtualGuests.id").NotEq(12345), 54 | ) 55 | 56 | filters = append(filters, Path("virtualGuests.domain").Eq("example.com")) 57 | 58 | actual = filters.Build() 59 | expected = `{"virtualGuests":{"domain":{"operation":"example.com"},"hostname":{"operation":"^= KM078"},"id":{"operation":"!= 12345"}}}` 60 | if actual != expected { 61 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 62 | } 63 | } 64 | 65 | func TestFilterOpts(t *testing.T) { 66 | var actual, expected string 67 | 68 | expected = `{"createDate":{"operation":"orderBy","options":[{"name":"sort","value":["DESC"]}]},"name":{"operation":"25GB - Ubuntu / Ubuntu / 18.04-64 Minimal for VSI"}}` 69 | 70 | filters := New(Path("name").Eq("25GB - Ubuntu / Ubuntu / 18.04-64 Minimal for VSI")) 71 | filters = append( 72 | filters, 73 | Path("createDate").Eq("orderBy").Opt("sort", [1]string{"DESC"}), 74 | ) 75 | 76 | actual = filters.Build() 77 | 78 | if actual != expected { 79 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 80 | } 81 | } 82 | 83 | func TestFilterOrderBy(t *testing.T) { 84 | var actual, expected string 85 | 86 | expected = `{"createDate":{"operation":"orderBy","options":[{"name":"sort","value":["DESC"]}]}}` 87 | 88 | filters := Path("createDate").OrderBy("DESC") 89 | actual = filters.Build() 90 | if actual != expected { 91 | t.Errorf("\nExpected: %s\nActual: %s", expected, actual) 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /generator/generate.go: -------------------------------------------------------------------------------- 1 | package generator 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "github.com/spf13/cobra" 7 | "os" 8 | "strings" 9 | ) 10 | 11 | func init() { 12 | generateCmd.Flags().StringVarP( 13 | &varMetadata, 14 | "metadata", "m", 15 | SoftLayerMetadataAPIURL, 16 | "A JSON file or HTTPS url to read metadata from.", 17 | ) 18 | generateCmd.Flags().StringVarP( 19 | &varOutput, 20 | "output", "o", 21 | "./", 22 | "Output directory. A 'services' and 'datatypes' directory will be created here.", 23 | ) 24 | rootCmd.AddCommand(generateCmd) 25 | } 26 | 27 | const SoftLayerMetadataAPIURL = "https://api.softlayer.com/metadata/v3.1" 28 | 29 | var varMetadata string 30 | var varOutput string 31 | var generateCmd = &cobra.Command{ 32 | Use: "generate", 33 | Short: "Generates the service and datatype definitions", 34 | Run: func(cmd *cobra.Command, args []string) { 35 | varMetadata = strings.ToLower(varMetadata) 36 | GenerateAPI(varMetadata, varOutput) 37 | }, 38 | } 39 | 40 | func GenerateAPI(metaPath string, outputDir string) { 41 | fmt.Printf("Getting metadata from %s ...\n", metaPath) 42 | var jsonResp []byte 43 | var err error 44 | if strings.HasPrefix(metaPath, "http") { 45 | jsonResp, err = GetMetaFromURL(metaPath) 46 | errCheck(err, fmt.Sprintf("Error getting metadata from %s", metaPath)) 47 | } else { 48 | jsonResp, err = GetMetaFromFile(metaPath) 49 | errCheck(err, fmt.Sprintf("Error reading file %s", metaPath)) 50 | } 51 | var meta map[string]Type 52 | err = json.Unmarshal(jsonResp, &meta) 53 | errCheck(err, "Error unmarshaling json response") 54 | 55 | // Build an array of Types, sorted by name 56 | // This will ensure consistency in the order that code is later emitted 57 | keys := GetSortedKeys(meta) 58 | 59 | sortedTypes := make([]Type, 0, len(keys)) 60 | sortedServices := make([]Type, 0, len(keys)) 61 | 62 | for _, name := range keys { 63 | t := meta[name] 64 | sortedTypes = append(sortedTypes, t) 65 | AddComplexType(&t) 66 | FixDatatype(&t, meta) 67 | 68 | // Not every datatype is also a service 69 | if !t.NoService { 70 | CreateGetters(&t) 71 | sortedServices = append(sortedServices, t) 72 | } 73 | } 74 | 75 | // Services can be subclasses of other services. Copy methods from each service's 'Base' entity to 76 | // the child service, only if a same-named method does not already exist (i.e., overridden by the 77 | // child service) 78 | for i, service := range sortedServices { 79 | sortedServices[i].Methods = GetBaseMethods(service, meta) 80 | FixReturnType(&sortedServices[i]) 81 | } 82 | 83 | fmt.Printf("Creating Datatypes...\n") 84 | err = WritePackage(outputDir, "datatypes", sortedTypes, datatype) 85 | errCheck(err, "Error creating Datatypes") 86 | 87 | fmt.Printf("Creating Servicess...\n") 88 | err = WritePackage(outputDir, "services", sortedServices, services) 89 | errCheck(err, "Error creating Services") 90 | } 91 | 92 | func errCheck(err error, msg string) { 93 | if err != nil { 94 | fmt.Printf("%s: %s\n", msg, err) 95 | os.Exit(1) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /generator/generate_test.go: -------------------------------------------------------------------------------- 1 | package generator_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | . "github.com/softlayer/softlayer-go/generator" 7 | "os" 8 | "testing" 9 | 10 | "fmt" 11 | ) 12 | 13 | func TestGenerator(t *testing.T) { 14 | RegisterFailHandler(Fail) 15 | RunSpecs(t, "Generator Tests") 16 | } 17 | 18 | var metaPath = "../sldnSample.json" 19 | var _ = Describe("Generate Tests", func() { 20 | var outDir string 21 | 22 | BeforeEach(func() { 23 | var err error 24 | outDir, err = os.MkdirTemp("", "softlayer-go-test*") 25 | Expect(err).NotTo(HaveOccurred()) 26 | err = os.Mkdir(fmt.Sprintf("%s/services", outDir), 0750) 27 | Expect(err).NotTo(HaveOccurred()) 28 | err = os.Mkdir(fmt.Sprintf("%s/datatypes", outDir), 0750) 29 | Expect(err).NotTo(HaveOccurred()) 30 | }) 31 | Context("Testing SLDN Generation", func() { 32 | Context("GenerateAPI From File", func() { 33 | It("Generates SLDN from test file", func() { 34 | GenerateAPI(metaPath, outDir) 35 | Expect(fmt.Sprintf("%s/services/account.go", outDir)).Should(BeAnExistingFile()) 36 | Expect(fmt.Sprintf("%s/services/account_test.go", outDir)).Should(BeAnExistingFile()) 37 | Expect(fmt.Sprintf("%s/datatypes/virtual.go", outDir)).Should(BeAnExistingFile()) 38 | }) 39 | }) 40 | }) 41 | AfterEach(func() { 42 | Expect(os.RemoveAll(outDir)).To(Succeed()) 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /generator/specialcase_test.go: -------------------------------------------------------------------------------- 1 | package generator_test 2 | 3 | import ( 4 | "github.com/softlayer/softlayer-go/datatypes" 5 | "github.com/softlayer/softlayer-go/services" 6 | "reflect" 7 | "testing" 8 | ) 9 | 10 | // Tests for each service/method that follows special case logic during code 11 | // generation 12 | 13 | func TestVirtualDiskImageType(t *testing.T) { 14 | expected := "*datatypes.Virtual_Disk_Image_Type" 15 | actual := reflect.TypeOf(datatypes.Virtual_Guest_Block_Device_Template_Group{}.ImageType).String() 16 | 17 | if actual != expected { 18 | t.Errorf("Expect type of Virtual_Guest_Block_Device_Template_Group.ImageType to be %s, but was %s", expected, actual) 19 | } 20 | } 21 | 22 | func TestDomainResourceRecordPropertiesCopiedToBaseType(t *testing.T) { 23 | fields := []string{"IsGatewayAddress", "Port", "Priority", "Protocol", "Service", "Weight"} 24 | for _, field := range fields { 25 | if _, ok := reflect.TypeOf(datatypes.Dns_Domain_ResourceRecord{}).FieldByName(field); !ok { 26 | t.Errorf("Expect property %s not found for datatypes.Dns_Domain_ResourceRecord", field) 27 | } 28 | } 29 | } 30 | 31 | func TestVoidPatchedReturnTypes(t *testing.T) { 32 | tests := map[interface{}]string{ 33 | services.Network_Application_Delivery_Controller_LoadBalancer_Service{}: "DeleteObject", 34 | services.Network_Application_Delivery_Controller_LoadBalancer_VirtualServer{}: "DeleteObject", 35 | services.Network_Application_Delivery_Controller{}: "DeleteLiveLoadBalancerService", 36 | } 37 | 38 | for service, method := range tests { 39 | reflectedService := reflect.TypeOf(service) 40 | reflectedMethod, _ := reflectedService.MethodByName(method) 41 | if reflectedMethod.Type.NumOut() > 1 { 42 | t.Errorf("Expect %s() to have only one (error) return value, but multiple values found", reflectedService.String()+method) 43 | } 44 | } 45 | } 46 | 47 | func TestPlaceOrder(t *testing.T) { 48 | services := []interface{}{ 49 | services.Billing_Order_Quote{}, 50 | services.Product_Order{}, 51 | } 52 | 53 | methods := []string{"PlaceOrder", "VerifyOrder", "PlaceQuote"} 54 | for _, service := range services { 55 | serviceType := reflect.TypeOf(service) 56 | for _, methodName := range methods { 57 | method, _ := serviceType.MethodByName(methodName) 58 | argType := method.Type.In(1).String() 59 | if argType != "interface {}" { 60 | t.Errorf( 61 | "Expect %s.%s() to accept interface {} as parameter, but %s found instead", 62 | serviceType.String(), 63 | methodName, 64 | argType, 65 | ) 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /generator/types.go: -------------------------------------------------------------------------------- 1 | package generator 2 | 3 | type Type struct { 4 | Name string `json:"name"` 5 | Base string `json:"base"` 6 | TypeDoc string `json:"typeDoc"` 7 | Properties map[string]Property `json:"properties"` 8 | ServiceDoc string `json:"serviceDoc"` 9 | Methods map[string]Method `json:"methods"` 10 | NoService bool `json:"noservice"` 11 | Overview string `json:"docOverview"` 12 | Deprecated bool `json:"deprecated"` 13 | ServiceGroup string 14 | } 15 | 16 | type Property struct { 17 | Name string `json:"name"` 18 | Type string `json:"type"` 19 | TypeArray bool `json:"typeArray"` 20 | Form string `json:"form"` 21 | Doc string `json:"doc"` 22 | Overview string `json:"docOverview"` 23 | Deprecated bool `json:"deprecated"` 24 | } 25 | 26 | type Method struct { 27 | Name string `json:"name"` 28 | Type string `json:"type"` 29 | TypeArray bool `json:"typeArray"` 30 | Doc string `json:"doc"` 31 | Static bool `json:"static"` 32 | NoAuth bool `json:"noauth"` 33 | Limitable bool `json:"limitable"` 34 | Filterable bool `json:"filterable"` 35 | Maskable bool `json:"maskable"` 36 | Parameters []Parameter `json:"parameters"` 37 | Overview string `json:"docOverview"` 38 | Deprecated bool `json:"deprecated"` 39 | } 40 | 41 | type Parameter struct { 42 | Name string `json:"name"` 43 | Type string `json:"type"` 44 | TypeArray bool `json:"typeArray"` 45 | Doc string `json:"doc"` 46 | DefaultValue interface{} `json:"defaultValue"` 47 | ParentMethod string 48 | } 49 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/softlayer/softlayer-go 2 | 3 | go 1.21 4 | 5 | require ( 6 | github.com/jarcoal/httpmock v1.0.5 7 | github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 8 | github.com/onsi/ginkgo/v2 v2.15.0 9 | github.com/onsi/gomega v1.31.1 10 | github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e 11 | github.com/spf13/cobra v1.8.0 12 | golang.org/x/tools v0.17.0 13 | ) 14 | 15 | require ( 16 | github.com/go-logr/logr v1.3.0 // indirect 17 | github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect 18 | github.com/google/go-cmp v0.6.0 // indirect 19 | github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect 20 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 21 | github.com/kr/pretty v0.3.1 // indirect 22 | github.com/spf13/pflag v1.0.5 // indirect 23 | golang.org/x/mod v0.14.0 // indirect 24 | golang.org/x/net v0.23.0 // indirect 25 | golang.org/x/sys v0.18.0 // indirect 26 | golang.org/x/text v0.14.0 // indirect 27 | gopkg.in/yaml.v3 v3.0.1 // indirect 28 | ) 29 | -------------------------------------------------------------------------------- /helpers/hardware/hardware.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hardware 18 | 19 | import ( 20 | "fmt" 21 | "github.com/softlayer/softlayer-go/datatypes" 22 | "github.com/softlayer/softlayer-go/helpers/location" 23 | "github.com/softlayer/softlayer-go/services" 24 | "github.com/softlayer/softlayer-go/session" 25 | "github.com/softlayer/softlayer-go/sl" 26 | "regexp" 27 | "sync" 28 | ) 29 | 30 | // GeRouterByName returns a Hardware that matches the provided hostname, 31 | // or an error if no matching Hardware can be found. 32 | // SoftLayer does not provide a direct path to retrieve a list of router 33 | // objects. So, get Location_Datacenter object at first and get an array of 34 | // router objects from the Datacenter 35 | func GetRouterByName(sess *session.Session, hostname string, args ...interface{}) (datatypes.Hardware, error) { 36 | var mask string 37 | if len(args) > 0 { 38 | mask = args[0].(string) 39 | } 40 | 41 | r, _ := regexp.Compile("[A-Za-z]+[0-9]+$") 42 | dcName := r.FindString(hostname) 43 | if len(dcName) == 0 { 44 | return datatypes.Hardware{}, fmt.Errorf("Cannot get datacenter name from hostname %s", hostname) 45 | } 46 | 47 | datacenter, err := location.GetDatacenterByName(sess, dcName, "hardwareRouters[id,hostname]") 48 | if err != nil { 49 | return datatypes.Hardware{}, err 50 | } 51 | 52 | for _, router := range datacenter.HardwareRouters { 53 | if *router.Hostname == hostname { 54 | return services.GetHardwareService(sess). 55 | Id(*router.Id). 56 | Mask(mask). 57 | GetObject() 58 | } 59 | } 60 | 61 | return datatypes.Hardware{}, fmt.Errorf("No routers found with hostname of %s", hostname) 62 | } 63 | 64 | // Use go-routines to iterate through all hardware results. 65 | // options should be any Mask or Filter you need, and a Limit if the default is too large. 66 | // Any error in the subsequent API calls will be logged, but largely ignored 67 | func GetHardwareIter(session session.SLSession, options *sl.Options) (resp []datatypes.Hardware, err error) { 68 | 69 | options.SetOffset(0) 70 | limit := options.ValidateLimit() 71 | 72 | // Can't call service.GetVirtualGuests because it passes a copy of options, not the address to options sadly. 73 | err = session.DoRequest("SoftLayer_Account", "getHardware", nil, options, &resp) 74 | if err != nil { 75 | return 76 | } 77 | apicalls := options.GetRemainingAPICalls() 78 | var wg sync.WaitGroup 79 | for x := 1; x <= apicalls; x++ { 80 | wg.Add(1) 81 | go func(i int) { 82 | defer wg.Done() 83 | offset := i * limit 84 | this_resp := []datatypes.Hardware{} 85 | options.Offset = &offset 86 | err = session.DoRequest("SoftLayer_Account", "getHardware", nil, options, &this_resp) 87 | if err != nil { 88 | fmt.Printf("[ERROR] %v\n", err) 89 | } 90 | resp = append(resp, this_resp...) 91 | }(x) 92 | } 93 | wg.Wait() 94 | return resp, err 95 | } 96 | -------------------------------------------------------------------------------- /helpers/hardware/hardware_test.go: -------------------------------------------------------------------------------- 1 | package hardware_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | "github.com/softlayer/softlayer-go/helpers/hardware" 7 | "github.com/softlayer/softlayer-go/session/sessionfakes" 8 | "github.com/softlayer/softlayer-go/sl" 9 | "testing" 10 | ) 11 | 12 | func TestServices(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "Helper Hardware Tests") 15 | } 16 | 17 | var _ = Describe("Helper Hardware Tests", func() { 18 | var slsession *sessionfakes.FakeSLSession 19 | var options *sl.Options 20 | BeforeEach(func() { 21 | limit := 10 22 | slsession = &sessionfakes.FakeSLSession{} 23 | options = &sl.Options{ 24 | Mask: "mask[id,hostname]", 25 | Filter: "", 26 | Limit: &limit, 27 | } 28 | }) 29 | 30 | Context("GetHardwareIter Tests", func() { 31 | 32 | It("API call made properly", func() { 33 | _, err := hardware.GetHardwareIter(slsession, options) 34 | Expect(err).ToNot(HaveOccurred()) 35 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 36 | }) 37 | }) 38 | }) 39 | -------------------------------------------------------------------------------- /helpers/location/location.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package location 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/softlayer/softlayer-go/datatypes" 23 | "github.com/softlayer/softlayer-go/filter" 24 | "github.com/softlayer/softlayer-go/services" 25 | "github.com/softlayer/softlayer-go/session" 26 | ) 27 | 28 | // GetLocationByName returns a Location that matches the provided name, or an 29 | // error if no matching Location can be found. 30 | // 31 | // If you need to access a datacenter's unique properties, use 32 | // GetDatacenterByName instead 33 | func GetLocationByName(sess *session.Session, name string, args ...interface{}) (datatypes.Location, error) { 34 | var mask string 35 | if len(args) > 0 { 36 | mask = args[0].(string) 37 | } 38 | 39 | locs, err := services.GetLocationService(sess). 40 | Mask(mask). 41 | Filter(filter.New(filter.Path("name").Eq(name)).Build()). 42 | GetDatacenters() 43 | 44 | if err != nil { 45 | return datatypes.Location{}, err 46 | } 47 | 48 | // An empty filtered result set does not raise an error 49 | if len(locs) == 0 { 50 | return datatypes.Location{}, fmt.Errorf("No locations found with name of %s", name) 51 | } 52 | 53 | return locs[0], nil 54 | } 55 | 56 | // GetDatacenterByName returns a Location_Datacenter that matches the provided 57 | // name, or an error if no matching datacenter can be found. 58 | // 59 | // Note that unless you need to access datacenter-specific properties 60 | // (backendHardwareRouters, etc.), it is more efficient to use 61 | // GetLocationByName, since GetDatacenterByName requires an extra call to the 62 | // API 63 | func GetDatacenterByName(sess *session.Session, name string, args ...interface{}) (datatypes.Location_Datacenter, error) { 64 | var mask string 65 | if len(args) > 0 { 66 | mask = args[0].(string) 67 | } 68 | 69 | // SoftLayer does not provide a direct path to retrieve a list of "Location_Datacenter" 70 | // objects. Location_Datacenter.getDatacenters() actually returns a list of "Location" 71 | // objects, which do not have datacenter-specific properties populated. So we do this 72 | // in two passes 73 | 74 | // First get the Location which matches the name 75 | location, err := GetLocationByName(sess, name, "mask[id]") 76 | 77 | if err != nil { 78 | return datatypes.Location_Datacenter{}, err 79 | } 80 | 81 | // Now get the Datacenter record itself. 82 | return services.GetLocationDatacenterService(sess). 83 | Id(*location.Id). 84 | Mask(mask). 85 | GetObject() 86 | } 87 | -------------------------------------------------------------------------------- /helpers/network/network.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package network 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/softlayer/softlayer-go/datatypes" 23 | "github.com/softlayer/softlayer-go/filter" 24 | "github.com/softlayer/softlayer-go/services" 25 | "github.com/softlayer/softlayer-go/session" 26 | ) 27 | 28 | // GetNadcLbVipByName Get a virtual ip address by name attached to a load balancer 29 | // appliance like the Netscaler VPX. In the case of some load balancer appliances 30 | // looking up the virtual ip address by name is necessary since they don't get 31 | // assigned an id. 32 | func GetNadcLbVipByName(sess *session.Session, nadcId int, vipName string, mask ...string) (*datatypes.Network_LoadBalancer_VirtualIpAddress, error) { 33 | service := services.GetNetworkApplicationDeliveryControllerService(sess) 34 | 35 | service = service. 36 | Id(nadcId) 37 | 38 | if len(mask) > 0 { 39 | service = service.Mask(mask[0]) 40 | } 41 | 42 | vips, err := service.GetLoadBalancers() 43 | 44 | if err != nil { 45 | return nil, fmt.Errorf("Error getting NADC load balancers: %s", err) 46 | } 47 | 48 | for _, vip := range vips { 49 | if *vip.Name == vipName { 50 | return &vip, nil 51 | } 52 | } 53 | 54 | return nil, fmt.Errorf("Could not find any VIPs for NADC %d matching name %s", nadcId, vipName) 55 | } 56 | 57 | // GetNadcLbVipServiceByName Get a load balancer service by name attached to a load balancer 58 | // appliance like the Netscaler VPX. In the case of some load balancer appliances 59 | // looking up the virtual ip address by name is necessary since they don't get 60 | // assigned an id. 61 | func GetNadcLbVipServiceByName( 62 | sess *session.Session, nadcId int, vipName string, serviceName string, mask ...string, 63 | ) (*datatypes.Network_LoadBalancer_Service, error) { 64 | vipMask := "id,name,services[name,destinationIpAddress,destinationPort,weight,healthCheck,connectionLimit]" 65 | 66 | if len(mask) != 0 { 67 | vipMask = mask[0] 68 | } 69 | 70 | vip, err := GetNadcLbVipByName(sess, nadcId, vipName, vipMask) 71 | if err != nil { 72 | return nil, err 73 | } 74 | 75 | for _, service := range vip.Services { 76 | if *service.Name == serviceName { 77 | return &service, nil 78 | } 79 | } 80 | 81 | return nil, fmt.Errorf( 82 | "Could not find service %s in VIP %s for load balancer %d", 83 | serviceName, vipName, nadcId) 84 | } 85 | 86 | // GetOsTypeByName retrieves an object of type SoftLayer_Network_Storage_Iscsi_OS_Type. 87 | // To order block storage, OS type is required as a mandatory input. 88 | // GetOsTypeByName helps in getting the OS id and keyName 89 | // Examples: 90 | // id:6 name: Hyper-V keyName: HYPER_V 91 | // id:12 name: Linux keyName: LINUX 92 | // id:22 name: VMWare keyName: VMWARE 93 | // id:30 name: Xen keyName: XEN 94 | func GetOsTypeByName(sess *session.Session, name string, args ...interface{}) (datatypes.Network_Storage_Iscsi_OS_Type, error) { 95 | var mask string 96 | if len(args) > 0 { 97 | mask = args[0].(string) 98 | } 99 | 100 | osTypes, err := services.GetNetworkStorageIscsiOSTypeService(sess). 101 | Mask(mask). 102 | Filter(filter.New(filter.Path("name").Eq(name)).Build()). 103 | GetAllObjects() 104 | 105 | if err != nil { 106 | return datatypes.Network_Storage_Iscsi_OS_Type{}, err 107 | } 108 | 109 | // An empty filtered result set does not raise an error 110 | if len(osTypes) == 0 { 111 | return datatypes.Network_Storage_Iscsi_OS_Type{}, fmt.Errorf("No OS type found with name of %s", name) 112 | } 113 | 114 | return osTypes[0], nil 115 | } 116 | -------------------------------------------------------------------------------- /helpers/order/order.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package order 18 | 19 | import ( 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/services" 22 | "github.com/softlayer/softlayer-go/session" 23 | "github.com/softlayer/softlayer-go/sl" 24 | ) 25 | 26 | // CheckBillingOrderStatus returns true if the status of the billing order for 27 | // the provided product order receipt is in the list of provided statuses. 28 | // Returns false otherwise, along with the billing order item used to check the statuses, 29 | // and any error encountered. 30 | func CheckBillingOrderStatus(sess *session.Session, receipt *datatypes.Container_Product_Order_Receipt, statuses []string) (bool, *datatypes.Billing_Order_Item, error) { 31 | service := services.GetBillingOrderItemService(sess) 32 | 33 | item, err := service. 34 | Id(*receipt.PlacedOrder.Items[0].Id). 35 | Mask("mask[id,billingItem[id,provisionTransaction[id,transactionStatus[name]]]]"). 36 | GetObject() 37 | 38 | if err != nil { 39 | return false, nil, err 40 | } 41 | 42 | currentStatus, ok := sl.GrabOk(item, "BillingItem.ProvisionTransaction.TransactionStatus.Name") 43 | 44 | if ok { 45 | for _, status := range statuses { 46 | if currentStatus == status { 47 | return true, &item, nil 48 | } 49 | } 50 | } 51 | 52 | return false, &item, nil 53 | } 54 | 55 | // CheckBillingOrderComplete returns true if the status of the billing order for 56 | // the provided product order receipt is "COMPLETE". Returns false otherwise, 57 | // along with the billing order item used to check the statuses, and any error encountered. 58 | func CheckBillingOrderComplete(sess *session.Session, receipt *datatypes.Container_Product_Order_Receipt) (bool, *datatypes.Billing_Order_Item, error) { 59 | return CheckBillingOrderStatus(sess, receipt, []string{"COMPLETE"}) 60 | } 61 | -------------------------------------------------------------------------------- /helpers/virtual/virtual_test.go: -------------------------------------------------------------------------------- 1 | package virtual_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | // "github.com/softlayer/softlayer-go/datatypes" 7 | 8 | "github.com/softlayer/softlayer-go/helpers/virtual" 9 | "github.com/softlayer/softlayer-go/session/sessionfakes" 10 | "github.com/softlayer/softlayer-go/sl" 11 | "testing" 12 | ) 13 | 14 | func TestServices(t *testing.T) { 15 | RegisterFailHandler(Fail) 16 | RunSpecs(t, "Helper Virtual Tests") 17 | } 18 | 19 | var _ = Describe("Helper Virtual Tests", func() { 20 | var slsession *sessionfakes.FakeSLSession 21 | var options *sl.Options 22 | BeforeEach(func() { 23 | limit := 10 24 | slsession = &sessionfakes.FakeSLSession{} 25 | options = &sl.Options{ 26 | Mask: "mask[id,hostname]", 27 | Filter: "", 28 | Limit: &limit, 29 | } 30 | }) 31 | 32 | Context("GetVirtualGuestsIter Tests", func() { 33 | 34 | It("API call made properly", func() { 35 | _, err := virtual.GetVirtualGuestsIter(slsession, options) 36 | Expect(err).ToNot(HaveOccurred()) 37 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 38 | }) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /services/business.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // Contains business partner channel information 26 | type Business_Partner_Channel struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetBusinessPartnerChannelService returns an instance of the Business_Partner_Channel SoftLayer service 32 | func GetBusinessPartnerChannelService(sess session.SLSession) Business_Partner_Channel { 33 | return Business_Partner_Channel{Session: sess} 34 | } 35 | 36 | func (r Business_Partner_Channel) Id(id int) Business_Partner_Channel { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Business_Partner_Channel) Mask(mask string) Business_Partner_Channel { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Business_Partner_Channel) Filter(filter string) Business_Partner_Channel { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Business_Partner_Channel) Limit(limit int) Business_Partner_Channel { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Business_Partner_Channel) Offset(offset int) Business_Partner_Channel { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // no documentation yet 66 | func (r Business_Partner_Channel) GetObject() (resp datatypes.Business_Partner_Channel, err error) { 67 | err = r.Session.DoRequest("SoftLayer_Business_Partner_Channel", "getObject", nil, &r.Options, &resp) 68 | return 69 | } 70 | 71 | // Contains business partner segment information 72 | type Business_Partner_Segment struct { 73 | Session session.SLSession 74 | Options sl.Options 75 | } 76 | 77 | // GetBusinessPartnerSegmentService returns an instance of the Business_Partner_Segment SoftLayer service 78 | func GetBusinessPartnerSegmentService(sess session.SLSession) Business_Partner_Segment { 79 | return Business_Partner_Segment{Session: sess} 80 | } 81 | 82 | func (r Business_Partner_Segment) Id(id int) Business_Partner_Segment { 83 | r.Options.Id = &id 84 | return r 85 | } 86 | 87 | func (r Business_Partner_Segment) Mask(mask string) Business_Partner_Segment { 88 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 89 | mask = fmt.Sprintf("mask[%s]", mask) 90 | } 91 | 92 | r.Options.Mask = mask 93 | return r 94 | } 95 | 96 | func (r Business_Partner_Segment) Filter(filter string) Business_Partner_Segment { 97 | r.Options.Filter = filter 98 | return r 99 | } 100 | 101 | func (r Business_Partner_Segment) Limit(limit int) Business_Partner_Segment { 102 | r.Options.Limit = &limit 103 | return r 104 | } 105 | 106 | func (r Business_Partner_Segment) Offset(offset int) Business_Partner_Segment { 107 | r.Options.Offset = &offset 108 | return r 109 | } 110 | 111 | // no documentation yet 112 | func (r Business_Partner_Segment) GetObject() (resp datatypes.Business_Partner_Segment, err error) { 113 | err = r.Session.DoRequest("SoftLayer_Business_Partner_Segment", "getObject", nil, &r.Options, &resp) 114 | return 115 | } 116 | -------------------------------------------------------------------------------- /services/business_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Business Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Business_Partner_Channel service", func() { 18 | var sl_service services.Business_Partner_Channel 19 | BeforeEach(func() { 20 | sl_service = services.GetBusinessPartnerChannelService(slsession) 21 | }) 22 | Context("SoftLayer_Business_Partner_Channel Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Business_Partner_Channel Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Business_Partner_Channel::getObject", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetObject() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | }) 53 | 54 | Context("Testing SoftLayer_Business_Partner_Segment service", func() { 55 | var sl_service services.Business_Partner_Segment 56 | BeforeEach(func() { 57 | sl_service = services.GetBusinessPartnerSegmentService(slsession) 58 | }) 59 | Context("SoftLayer_Business_Partner_Segment Set Options", func() { 60 | It("Set Options properly", func() { 61 | t_id := 1234 62 | t_filter := "{'testFilter':{'test'}}" 63 | t_limit := 100 64 | t_offset := 5 65 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 66 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 67 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 68 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 69 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 70 | }) 71 | }) 72 | Context("SoftLayer_Business_Partner_Segment Set Mask", func() { 73 | It("Set Options properly", func() { 74 | t_mask1 := "mask[test,test2]" 75 | sl_service = sl_service.Mask(t_mask1) 76 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 77 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 78 | sl_service = sl_service.Mask("test,test2") 79 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 80 | }) 81 | }) 82 | Context("SoftLayer_Business_Partner_Segment::getObject", func() { 83 | It("API Call Test", func() { 84 | _, err := sl_service.GetObject() 85 | Expect(err).To(Succeed()) 86 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 87 | }) 88 | }) 89 | }) 90 | 91 | }) 92 | -------------------------------------------------------------------------------- /services/compliance.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // no documentation yet 26 | type Compliance_Report_Type struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetComplianceReportTypeService returns an instance of the Compliance_Report_Type SoftLayer service 32 | func GetComplianceReportTypeService(sess session.SLSession) Compliance_Report_Type { 33 | return Compliance_Report_Type{Session: sess} 34 | } 35 | 36 | func (r Compliance_Report_Type) Id(id int) Compliance_Report_Type { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Compliance_Report_Type) Mask(mask string) Compliance_Report_Type { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Compliance_Report_Type) Filter(filter string) Compliance_Report_Type { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Compliance_Report_Type) Limit(limit int) Compliance_Report_Type { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Compliance_Report_Type) Offset(offset int) Compliance_Report_Type { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // no documentation yet 66 | func (r Compliance_Report_Type) GetAllObjects() (resp []datatypes.Compliance_Report_Type, err error) { 67 | err = r.Session.DoRequest("SoftLayer_Compliance_Report_Type", "getAllObjects", nil, &r.Options, &resp) 68 | return 69 | } 70 | 71 | // no documentation yet 72 | func (r Compliance_Report_Type) GetObject() (resp datatypes.Compliance_Report_Type, err error) { 73 | err = r.Session.DoRequest("SoftLayer_Compliance_Report_Type", "getObject", nil, &r.Options, &resp) 74 | return 75 | } 76 | -------------------------------------------------------------------------------- /services/compliance_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Compliance Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Compliance_Report_Type service", func() { 18 | var sl_service services.Compliance_Report_Type 19 | BeforeEach(func() { 20 | sl_service = services.GetComplianceReportTypeService(slsession) 21 | }) 22 | Context("SoftLayer_Compliance_Report_Type Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Compliance_Report_Type Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Compliance_Report_Type::getAllObjects", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetAllObjects() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Compliance_Report_Type::getObject", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetObject() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | }) 60 | 61 | }) 62 | -------------------------------------------------------------------------------- /services/email.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // no documentation yet 26 | type Email_Subscription struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetEmailSubscriptionService returns an instance of the Email_Subscription SoftLayer service 32 | func GetEmailSubscriptionService(sess session.SLSession) Email_Subscription { 33 | return Email_Subscription{Session: sess} 34 | } 35 | 36 | func (r Email_Subscription) Id(id int) Email_Subscription { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Email_Subscription) Mask(mask string) Email_Subscription { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Email_Subscription) Filter(filter string) Email_Subscription { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Email_Subscription) Limit(limit int) Email_Subscription { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Email_Subscription) Offset(offset int) Email_Subscription { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // no documentation yet 66 | func (r Email_Subscription) Disable() (resp bool, err error) { 67 | err = r.Session.DoRequest("SoftLayer_Email_Subscription", "disable", nil, &r.Options, &resp) 68 | return 69 | } 70 | 71 | // no documentation yet 72 | func (r Email_Subscription) Enable() (resp bool, err error) { 73 | err = r.Session.DoRequest("SoftLayer_Email_Subscription", "enable", nil, &r.Options, &resp) 74 | return 75 | } 76 | 77 | // no documentation yet 78 | func (r Email_Subscription) GetAllObjects() (resp []datatypes.Email_Subscription, err error) { 79 | err = r.Session.DoRequest("SoftLayer_Email_Subscription", "getAllObjects", nil, &r.Options, &resp) 80 | return 81 | } 82 | 83 | // Retrieve 84 | func (r Email_Subscription) GetEnabled() (resp bool, err error) { 85 | err = r.Session.DoRequest("SoftLayer_Email_Subscription", "getEnabled", nil, &r.Options, &resp) 86 | return 87 | } 88 | 89 | // no documentation yet 90 | func (r Email_Subscription) GetObject() (resp datatypes.Email_Subscription, err error) { 91 | err = r.Session.DoRequest("SoftLayer_Email_Subscription", "getObject", nil, &r.Options, &resp) 92 | return 93 | } 94 | 95 | // no documentation yet 96 | type Email_Subscription_Group struct { 97 | Session session.SLSession 98 | Options sl.Options 99 | } 100 | 101 | // GetEmailSubscriptionGroupService returns an instance of the Email_Subscription_Group SoftLayer service 102 | func GetEmailSubscriptionGroupService(sess session.SLSession) Email_Subscription_Group { 103 | return Email_Subscription_Group{Session: sess} 104 | } 105 | 106 | func (r Email_Subscription_Group) Id(id int) Email_Subscription_Group { 107 | r.Options.Id = &id 108 | return r 109 | } 110 | 111 | func (r Email_Subscription_Group) Mask(mask string) Email_Subscription_Group { 112 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 113 | mask = fmt.Sprintf("mask[%s]", mask) 114 | } 115 | 116 | r.Options.Mask = mask 117 | return r 118 | } 119 | 120 | func (r Email_Subscription_Group) Filter(filter string) Email_Subscription_Group { 121 | r.Options.Filter = filter 122 | return r 123 | } 124 | 125 | func (r Email_Subscription_Group) Limit(limit int) Email_Subscription_Group { 126 | r.Options.Limit = &limit 127 | return r 128 | } 129 | 130 | func (r Email_Subscription_Group) Offset(offset int) Email_Subscription_Group { 131 | r.Options.Offset = &offset 132 | return r 133 | } 134 | 135 | // no documentation yet 136 | func (r Email_Subscription_Group) GetAllObjects() (resp []datatypes.Email_Subscription_Group, err error) { 137 | err = r.Session.DoRequest("SoftLayer_Email_Subscription_Group", "getAllObjects", nil, &r.Options, &resp) 138 | return 139 | } 140 | 141 | // no documentation yet 142 | func (r Email_Subscription_Group) GetObject() (resp datatypes.Email_Subscription_Group, err error) { 143 | err = r.Session.DoRequest("SoftLayer_Email_Subscription_Group", "getObject", nil, &r.Options, &resp) 144 | return 145 | } 146 | 147 | // Retrieve All email subscriptions associated with this group. 148 | func (r Email_Subscription_Group) GetSubscriptions() (resp []datatypes.Email_Subscription, err error) { 149 | err = r.Session.DoRequest("SoftLayer_Email_Subscription_Group", "getSubscriptions", nil, &r.Options, &resp) 150 | return 151 | } 152 | -------------------------------------------------------------------------------- /services/email_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Email Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Email_Subscription service", func() { 18 | var sl_service services.Email_Subscription 19 | BeforeEach(func() { 20 | sl_service = services.GetEmailSubscriptionService(slsession) 21 | }) 22 | Context("SoftLayer_Email_Subscription Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Email_Subscription Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Email_Subscription::disable", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.Disable() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Email_Subscription::enable", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.Enable() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Email_Subscription::getAllObjects", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetAllObjects() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Email_Subscription::getEnabled", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetEnabled() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Email_Subscription::getObject", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetObject() 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | }) 81 | 82 | Context("Testing SoftLayer_Email_Subscription_Group service", func() { 83 | var sl_service services.Email_Subscription_Group 84 | BeforeEach(func() { 85 | sl_service = services.GetEmailSubscriptionGroupService(slsession) 86 | }) 87 | Context("SoftLayer_Email_Subscription_Group Set Options", func() { 88 | It("Set Options properly", func() { 89 | t_id := 1234 90 | t_filter := "{'testFilter':{'test'}}" 91 | t_limit := 100 92 | t_offset := 5 93 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 94 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 95 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 96 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 97 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 98 | }) 99 | }) 100 | Context("SoftLayer_Email_Subscription_Group Set Mask", func() { 101 | It("Set Options properly", func() { 102 | t_mask1 := "mask[test,test2]" 103 | sl_service = sl_service.Mask(t_mask1) 104 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 105 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 106 | sl_service = sl_service.Mask("test,test2") 107 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 108 | }) 109 | }) 110 | Context("SoftLayer_Email_Subscription_Group::getAllObjects", func() { 111 | It("API Call Test", func() { 112 | _, err := sl_service.GetAllObjects() 113 | Expect(err).To(Succeed()) 114 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 115 | }) 116 | }) 117 | Context("SoftLayer_Email_Subscription_Group::getObject", func() { 118 | It("API Call Test", func() { 119 | _, err := sl_service.GetObject() 120 | Expect(err).To(Succeed()) 121 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 122 | }) 123 | }) 124 | Context("SoftLayer_Email_Subscription_Group::getSubscriptions", func() { 125 | It("API Call Test", func() { 126 | _, err := sl_service.GetSubscriptions() 127 | Expect(err).To(Succeed()) 128 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 129 | }) 130 | }) 131 | }) 132 | 133 | }) 134 | -------------------------------------------------------------------------------- /services/event.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // The SoftLayer_Event_Log data type contains an event detail occurred upon various SoftLayer resources. 26 | type Event_Log struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetEventLogService returns an instance of the Event_Log SoftLayer service 32 | func GetEventLogService(sess session.SLSession) Event_Log { 33 | return Event_Log{Session: sess} 34 | } 35 | 36 | func (r Event_Log) Id(id int) Event_Log { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Event_Log) Mask(mask string) Event_Log { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Event_Log) Filter(filter string) Event_Log { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Event_Log) Limit(limit int) Event_Log { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Event_Log) Offset(offset int) Event_Log { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // This all indexed event names. 66 | func (r Event_Log) GetAllEventNames(objectName *string) (resp []string, err error) { 67 | params := []interface{}{ 68 | objectName, 69 | } 70 | err = r.Session.DoRequest("SoftLayer_Event_Log", "getAllEventNames", params, &r.Options, &resp) 71 | return 72 | } 73 | 74 | // This all indexed event object names. 75 | func (r Event_Log) GetAllEventObjectNames() (resp []string, err error) { 76 | err = r.Session.DoRequest("SoftLayer_Event_Log", "getAllEventObjectNames", nil, &r.Options, &resp) 77 | return 78 | } 79 | 80 | // no documentation yet 81 | func (r Event_Log) GetAllObjects() (resp []datatypes.Event_Log, err error) { 82 | err = r.Session.DoRequest("SoftLayer_Event_Log", "getAllObjects", nil, &r.Options, &resp) 83 | return 84 | } 85 | 86 | // no documentation yet 87 | func (r Event_Log) GetAllUserTypes() (resp []string, err error) { 88 | err = r.Session.DoRequest("SoftLayer_Event_Log", "getAllUserTypes", nil, &r.Options, &resp) 89 | return 90 | } 91 | 92 | // Retrieve 93 | func (r Event_Log) GetUser() (resp datatypes.User_Customer, err error) { 94 | err = r.Session.DoRequest("SoftLayer_Event_Log", "getUser", nil, &r.Options, &resp) 95 | return 96 | } 97 | -------------------------------------------------------------------------------- /services/event_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Event Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Event_Log service", func() { 18 | var sl_service services.Event_Log 19 | BeforeEach(func() { 20 | sl_service = services.GetEventLogService(slsession) 21 | }) 22 | Context("SoftLayer_Event_Log Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Event_Log Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Event_Log::getAllEventNames", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetAllEventNames(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Event_Log::getAllEventObjectNames", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetAllEventObjectNames() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Event_Log::getAllObjects", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetAllObjects() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Event_Log::getAllUserTypes", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetAllUserTypes() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Event_Log::getUser", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetUser() 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | }) 81 | 82 | }) 83 | -------------------------------------------------------------------------------- /services/exception.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/session" 21 | "github.com/softlayer/softlayer-go/sl" 22 | ) 23 | 24 | // Throw this exception if there are validation errors. The types are specified in SoftLayer_Brand_Creation_Input including: KEY_NAME, PREFIX, NAME, LONG_NAME, SUPPORT_POLICY, POLICY_ACKNOWLEDGEMENT_FLAG, etc. 25 | type Exception_Brand_Creation struct { 26 | Session session.SLSession 27 | Options sl.Options 28 | } 29 | 30 | // GetExceptionBrandCreationService returns an instance of the Exception_Brand_Creation SoftLayer service 31 | func GetExceptionBrandCreationService(sess session.SLSession) Exception_Brand_Creation { 32 | return Exception_Brand_Creation{Session: sess} 33 | } 34 | 35 | func (r Exception_Brand_Creation) Id(id int) Exception_Brand_Creation { 36 | r.Options.Id = &id 37 | return r 38 | } 39 | 40 | func (r Exception_Brand_Creation) Mask(mask string) Exception_Brand_Creation { 41 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 42 | mask = fmt.Sprintf("mask[%s]", mask) 43 | } 44 | 45 | r.Options.Mask = mask 46 | return r 47 | } 48 | 49 | func (r Exception_Brand_Creation) Filter(filter string) Exception_Brand_Creation { 50 | r.Options.Filter = filter 51 | return r 52 | } 53 | 54 | func (r Exception_Brand_Creation) Limit(limit int) Exception_Brand_Creation { 55 | r.Options.Limit = &limit 56 | return r 57 | } 58 | 59 | func (r Exception_Brand_Creation) Offset(offset int) Exception_Brand_Creation { 60 | r.Options.Offset = &offset 61 | return r 62 | } 63 | -------------------------------------------------------------------------------- /services/flexiblecredit.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // no documentation yet 26 | type FlexibleCredit_Program struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetFlexibleCreditProgramService returns an instance of the FlexibleCredit_Program SoftLayer service 32 | func GetFlexibleCreditProgramService(sess session.SLSession) FlexibleCredit_Program { 33 | return FlexibleCredit_Program{Session: sess} 34 | } 35 | 36 | func (r FlexibleCredit_Program) Id(id int) FlexibleCredit_Program { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r FlexibleCredit_Program) Mask(mask string) FlexibleCredit_Program { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r FlexibleCredit_Program) Filter(filter string) FlexibleCredit_Program { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r FlexibleCredit_Program) Limit(limit int) FlexibleCredit_Program { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r FlexibleCredit_Program) Offset(offset int) FlexibleCredit_Program { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // no documentation yet 66 | func (r FlexibleCredit_Program) GetAffiliatesAvailableForSelfEnrollmentByVerificationType(verificationTypeKeyName *string) (resp []datatypes.FlexibleCredit_Affiliate, err error) { 67 | params := []interface{}{ 68 | verificationTypeKeyName, 69 | } 70 | err = r.Session.DoRequest("SoftLayer_FlexibleCredit_Program", "getAffiliatesAvailableForSelfEnrollmentByVerificationType", params, &r.Options, &resp) 71 | return 72 | } 73 | 74 | // no documentation yet 75 | func (r FlexibleCredit_Program) GetCompanyTypes() (resp []datatypes.FlexibleCredit_Company_Type, err error) { 76 | err = r.Session.DoRequest("SoftLayer_FlexibleCredit_Program", "getCompanyTypes", nil, &r.Options, &resp) 77 | return 78 | } 79 | 80 | // no documentation yet 81 | func (r FlexibleCredit_Program) GetObject() (resp datatypes.FlexibleCredit_Program, err error) { 82 | err = r.Session.DoRequest("SoftLayer_FlexibleCredit_Program", "getObject", nil, &r.Options, &resp) 83 | return 84 | } 85 | 86 | // no documentation yet 87 | func (r FlexibleCredit_Program) SelfEnrollNewAccount(accountTemplate *datatypes.Account) (resp datatypes.Account, err error) { 88 | params := []interface{}{ 89 | accountTemplate, 90 | } 91 | err = r.Session.DoRequest("SoftLayer_FlexibleCredit_Program", "selfEnrollNewAccount", params, &r.Options, &resp) 92 | return 93 | } 94 | -------------------------------------------------------------------------------- /services/flexiblecredit_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("FlexibleCredit Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_FlexibleCredit_Program service", func() { 18 | var sl_service services.FlexibleCredit_Program 19 | BeforeEach(func() { 20 | sl_service = services.GetFlexibleCreditProgramService(slsession) 21 | }) 22 | Context("SoftLayer_FlexibleCredit_Program Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_FlexibleCredit_Program Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_FlexibleCredit_Program::getAffiliatesAvailableForSelfEnrollmentByVerificationType", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetAffiliatesAvailableForSelfEnrollmentByVerificationType(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_FlexibleCredit_Program::getCompanyTypes", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetCompanyTypes() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_FlexibleCredit_Program::getObject", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetObject() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_FlexibleCredit_Program::selfEnrollNewAccount", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.SelfEnrollNewAccount(nil) 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | }) 74 | 75 | }) 76 | -------------------------------------------------------------------------------- /services/marketplace_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Marketplace Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Marketplace_Partner service", func() { 18 | var sl_service services.Marketplace_Partner 19 | BeforeEach(func() { 20 | sl_service = services.GetMarketplacePartnerService(slsession) 21 | }) 22 | Context("SoftLayer_Marketplace_Partner Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Marketplace_Partner Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Marketplace_Partner::getAllObjects", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetAllObjects() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Marketplace_Partner::getAllPublishedPartners", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetAllPublishedPartners(nil) 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Marketplace_Partner::getAttachments", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetAttachments() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Marketplace_Partner::getFeaturedPartners", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetFeaturedPartners(nil) 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Marketplace_Partner::getFile", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetFile(nil) 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | Context("SoftLayer_Marketplace_Partner::getLogoMedium", func() { 81 | It("API Call Test", func() { 82 | _, err := sl_service.GetLogoMedium() 83 | Expect(err).To(Succeed()) 84 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 85 | }) 86 | }) 87 | Context("SoftLayer_Marketplace_Partner::getLogoMediumTemp", func() { 88 | It("API Call Test", func() { 89 | _, err := sl_service.GetLogoMediumTemp() 90 | Expect(err).To(Succeed()) 91 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 92 | }) 93 | }) 94 | Context("SoftLayer_Marketplace_Partner::getLogoSmall", func() { 95 | It("API Call Test", func() { 96 | _, err := sl_service.GetLogoSmall() 97 | Expect(err).To(Succeed()) 98 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 99 | }) 100 | }) 101 | Context("SoftLayer_Marketplace_Partner::getLogoSmallTemp", func() { 102 | It("API Call Test", func() { 103 | _, err := sl_service.GetLogoSmallTemp() 104 | Expect(err).To(Succeed()) 105 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 106 | }) 107 | }) 108 | Context("SoftLayer_Marketplace_Partner::getObject", func() { 109 | It("API Call Test", func() { 110 | _, err := sl_service.GetObject() 111 | Expect(err).To(Succeed()) 112 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 113 | }) 114 | }) 115 | Context("SoftLayer_Marketplace_Partner::getPartnerByUrlIdentifier", func() { 116 | It("API Call Test", func() { 117 | _, err := sl_service.GetPartnerByUrlIdentifier(nil) 118 | Expect(err).To(Succeed()) 119 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 120 | }) 121 | }) 122 | }) 123 | 124 | }) 125 | -------------------------------------------------------------------------------- /services/monitoring.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // DEPRECATED. The SoftLayer_Monitoring_Robot data type contains general information relating to a monitoring robot. 26 | type Monitoring_Robot struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetMonitoringRobotService returns an instance of the Monitoring_Robot SoftLayer service 32 | func GetMonitoringRobotService(sess session.SLSession) Monitoring_Robot { 33 | return Monitoring_Robot{Session: sess} 34 | } 35 | 36 | func (r Monitoring_Robot) Id(id int) Monitoring_Robot { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Monitoring_Robot) Mask(mask string) Monitoring_Robot { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Monitoring_Robot) Filter(filter string) Monitoring_Robot { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Monitoring_Robot) Limit(limit int) Monitoring_Robot { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Monitoring_Robot) Offset(offset int) Monitoring_Robot { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // DEPRECATED. Checks if a monitoring robot can communicate with SoftLayer monitoring management system via the private network. 66 | // 67 | // TCP port 48000 - 48002 must be open on your server or your virtual server in order for this test to succeed. 68 | // Deprecated: This function has been marked as deprecated. 69 | func (r Monitoring_Robot) CheckConnection() (resp bool, err error) { 70 | err = r.Session.DoRequest("SoftLayer_Monitoring_Robot", "checkConnection", nil, &r.Options, &resp) 71 | return 72 | } 73 | 74 | // no documentation yet 75 | func (r Monitoring_Robot) GetObject() (resp datatypes.Monitoring_Robot, err error) { 76 | err = r.Session.DoRequest("SoftLayer_Monitoring_Robot", "getObject", nil, &r.Options, &resp) 77 | return 78 | } 79 | -------------------------------------------------------------------------------- /services/monitoring_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Monitoring Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Monitoring_Robot service", func() { 18 | var sl_service services.Monitoring_Robot 19 | BeforeEach(func() { 20 | sl_service = services.GetMonitoringRobotService(slsession) 21 | }) 22 | Context("SoftLayer_Monitoring_Robot Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Monitoring_Robot Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Monitoring_Robot::checkConnection", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.CheckConnection() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Monitoring_Robot::getObject", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetObject() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | }) 60 | 61 | }) 62 | -------------------------------------------------------------------------------- /services/sales.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // The presale event data types indicate the information regarding an individual presale event. The ”'locationId”' will indicate the datacenter associated with the presale event. The ”'itemId”' will indicate the product item associated with a particular presale event - however these are more rare. The ”'startDate”' and ”'endDate”' will provide information regarding when the presale event is available for use. At the end of the presale event, the server or services purchased will be available once approved and provisioned. 26 | type Sales_Presale_Event struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetSalesPresaleEventService returns an instance of the Sales_Presale_Event SoftLayer service 32 | func GetSalesPresaleEventService(sess session.SLSession) Sales_Presale_Event { 33 | return Sales_Presale_Event{Session: sess} 34 | } 35 | 36 | func (r Sales_Presale_Event) Id(id int) Sales_Presale_Event { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Sales_Presale_Event) Mask(mask string) Sales_Presale_Event { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Sales_Presale_Event) Filter(filter string) Sales_Presale_Event { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Sales_Presale_Event) Limit(limit int) Sales_Presale_Event { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Sales_Presale_Event) Offset(offset int) Sales_Presale_Event { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // Retrieve A flag to indicate that the presale event is currently active. A presale event is active if the current time is between the start and end dates. 66 | func (r Sales_Presale_Event) GetActiveFlag() (resp bool, err error) { 67 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getActiveFlag", nil, &r.Options, &resp) 68 | return 69 | } 70 | 71 | // no documentation yet 72 | func (r Sales_Presale_Event) GetAllObjects() (resp []datatypes.Sales_Presale_Event, err error) { 73 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getAllObjects", nil, &r.Options, &resp) 74 | return 75 | } 76 | 77 | // Retrieve A flag to indicate that the presale event is expired. A presale event is expired if the current time is after the end date. 78 | func (r Sales_Presale_Event) GetExpiredFlag() (resp bool, err error) { 79 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getExpiredFlag", nil, &r.Options, &resp) 80 | return 81 | } 82 | 83 | // Retrieve The [[SoftLayer_Product_Item]] associated with the presale event. 84 | func (r Sales_Presale_Event) GetItem() (resp datatypes.Product_Item, err error) { 85 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getItem", nil, &r.Options, &resp) 86 | return 87 | } 88 | 89 | // Retrieve The [[SoftLayer_Location]] associated with the presale event. 90 | func (r Sales_Presale_Event) GetLocation() (resp datatypes.Location, err error) { 91 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getLocation", nil, &r.Options, &resp) 92 | return 93 | } 94 | 95 | // ”'getObject”' retrieves the [[SoftLayer_Sales_Presale_Event]] object whose id number corresponds to the id number of the init parameter passed to the SoftLayer_Sales_Presale_Event service. Customers may only retrieve presale events that are currently active. 96 | func (r Sales_Presale_Event) GetObject() (resp datatypes.Sales_Presale_Event, err error) { 97 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getObject", nil, &r.Options, &resp) 98 | return 99 | } 100 | 101 | // Retrieve The orders ([[SoftLayer_Billing_Order]]) associated with this presale event that were created for the customer's account. 102 | func (r Sales_Presale_Event) GetOrders() (resp []datatypes.Billing_Order, err error) { 103 | err = r.Session.DoRequest("SoftLayer_Sales_Presale_Event", "getOrders", nil, &r.Options, &resp) 104 | return 105 | } 106 | -------------------------------------------------------------------------------- /services/sales_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Sales Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Sales_Presale_Event service", func() { 18 | var sl_service services.Sales_Presale_Event 19 | BeforeEach(func() { 20 | sl_service = services.GetSalesPresaleEventService(slsession) 21 | }) 22 | Context("SoftLayer_Sales_Presale_Event Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Sales_Presale_Event Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Sales_Presale_Event::getActiveFlag", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetActiveFlag() 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Sales_Presale_Event::getAllObjects", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetAllObjects() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Sales_Presale_Event::getExpiredFlag", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetExpiredFlag() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Sales_Presale_Event::getItem", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetItem() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Sales_Presale_Event::getLocation", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetLocation() 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | Context("SoftLayer_Sales_Presale_Event::getObject", func() { 81 | It("API Call Test", func() { 82 | _, err := sl_service.GetObject() 83 | Expect(err).To(Succeed()) 84 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 85 | }) 86 | }) 87 | Context("SoftLayer_Sales_Presale_Event::getOrders", func() { 88 | It("API Call Test", func() { 89 | _, err := sl_service.GetOrders() 90 | Expect(err).To(Succeed()) 91 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 92 | }) 93 | }) 94 | }) 95 | 96 | }) 97 | -------------------------------------------------------------------------------- /services/search_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Search Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Search service", func() { 18 | var sl_service services.Search 19 | BeforeEach(func() { 20 | sl_service = services.GetSearchService(slsession) 21 | }) 22 | Context("SoftLayer_Search Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Search Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Search::advancedSearch", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.AdvancedSearch(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Search::getObjectTypes", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetObjectTypes() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Search::search", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.Search(nil) 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | }) 67 | 68 | }) 69 | -------------------------------------------------------------------------------- /services/services_test.go: -------------------------------------------------------------------------------- 1 | package services_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | "github.com/softlayer/softlayer-go/datatypes" 7 | "testing" 8 | ) 9 | 10 | func TestServices(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Services Tests") 13 | } 14 | 15 | // This is required for a few of the Place order API methods that take in an interface 16 | func GetOrderContainer() *datatypes.Container_Product_Order { 17 | ComplexType := "Test_Complex_Type" 18 | OrderContainer := &datatypes.Container_Product_Order{ComplexType: &ComplexType} 19 | return OrderContainer 20 | } 21 | -------------------------------------------------------------------------------- /services/survey.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/datatypes" 21 | "github.com/softlayer/softlayer-go/session" 22 | "github.com/softlayer/softlayer-go/sl" 23 | ) 24 | 25 | // The SoftLayer_Survey data type contains general information relating to a single SoftLayer survey. 26 | type Survey struct { 27 | Session session.SLSession 28 | Options sl.Options 29 | } 30 | 31 | // GetSurveyService returns an instance of the Survey SoftLayer service 32 | func GetSurveyService(sess session.SLSession) Survey { 33 | return Survey{Session: sess} 34 | } 35 | 36 | func (r Survey) Id(id int) Survey { 37 | r.Options.Id = &id 38 | return r 39 | } 40 | 41 | func (r Survey) Mask(mask string) Survey { 42 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 43 | mask = fmt.Sprintf("mask[%s]", mask) 44 | } 45 | 46 | r.Options.Mask = mask 47 | return r 48 | } 49 | 50 | func (r Survey) Filter(filter string) Survey { 51 | r.Options.Filter = filter 52 | return r 53 | } 54 | 55 | func (r Survey) Limit(limit int) Survey { 56 | r.Options.Limit = &limit 57 | return r 58 | } 59 | 60 | func (r Survey) Offset(offset int) Survey { 61 | r.Options.Offset = &offset 62 | return r 63 | } 64 | 65 | // Provides survey details for the given type 66 | func (r Survey) GetActiveSurveyByType(typ *string) (resp datatypes.Survey, err error) { 67 | params := []interface{}{ 68 | typ, 69 | } 70 | err = r.Session.DoRequest("SoftLayer_Survey", "getActiveSurveyByType", params, &r.Options, &resp) 71 | return 72 | } 73 | 74 | // getObject retrieves the SoftLayer_Survey object whose ID number corresponds to the ID number of the init parameter passed to the SoftLayer_Survey service. You can only retrieve the survey that your portal user has taken. 75 | func (r Survey) GetObject() (resp datatypes.Survey, err error) { 76 | err = r.Session.DoRequest("SoftLayer_Survey", "getObject", nil, &r.Options, &resp) 77 | return 78 | } 79 | 80 | // Retrieve The questions for a survey. 81 | func (r Survey) GetQuestions() (resp []datatypes.Survey_Question, err error) { 82 | err = r.Session.DoRequest("SoftLayer_Survey", "getQuestions", nil, &r.Options, &resp) 83 | return 84 | } 85 | 86 | // Retrieve The status of the survey 87 | func (r Survey) GetStatus() (resp datatypes.Survey_Status, err error) { 88 | err = r.Session.DoRequest("SoftLayer_Survey", "getStatus", nil, &r.Options, &resp) 89 | return 90 | } 91 | 92 | // Retrieve The type of survey 93 | func (r Survey) GetType() (resp datatypes.Survey_Type, err error) { 94 | err = r.Session.DoRequest("SoftLayer_Survey", "getType", nil, &r.Options, &resp) 95 | return 96 | } 97 | 98 | // Response to a SoftLayer survey's questions. 99 | func (r Survey) TakeSurvey(responses []datatypes.Survey_Response) (resp bool, err error) { 100 | params := []interface{}{ 101 | responses, 102 | } 103 | err = r.Session.DoRequest("SoftLayer_Survey", "takeSurvey", params, &r.Options, &resp) 104 | return 105 | } 106 | -------------------------------------------------------------------------------- /services/survey_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Survey Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Survey service", func() { 18 | var sl_service services.Survey 19 | BeforeEach(func() { 20 | sl_service = services.GetSurveyService(slsession) 21 | }) 22 | Context("SoftLayer_Survey Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Survey Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Survey::getActiveSurveyByType", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.GetActiveSurveyByType(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Survey::getObject", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.GetObject() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Survey::getQuestions", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetQuestions() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Survey::getStatus", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetStatus() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Survey::getType", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetType() 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | Context("SoftLayer_Survey::takeSurvey", func() { 81 | It("API Call Test", func() { 82 | _, err := sl_service.TakeSurvey(nil) 83 | Expect(err).To(Succeed()) 84 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 85 | }) 86 | }) 87 | }) 88 | 89 | }) 90 | -------------------------------------------------------------------------------- /services/tag_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Tag Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Tag service", func() { 18 | var sl_service services.Tag 19 | BeforeEach(func() { 20 | sl_service = services.GetTagService(slsession) 21 | }) 22 | Context("SoftLayer_Tag Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Tag Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Tag::autoComplete", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.AutoComplete(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Tag::deleteTag", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.DeleteTag(nil) 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Tag::getAccount", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetAccount() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Tag::getAllTagTypes", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetAllTagTypes() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | Context("SoftLayer_Tag::getAttachedTagsForCurrentUser", func() { 74 | It("API Call Test", func() { 75 | _, err := sl_service.GetAttachedTagsForCurrentUser() 76 | Expect(err).To(Succeed()) 77 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 78 | }) 79 | }) 80 | Context("SoftLayer_Tag::getObject", func() { 81 | It("API Call Test", func() { 82 | _, err := sl_service.GetObject() 83 | Expect(err).To(Succeed()) 84 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 85 | }) 86 | }) 87 | Context("SoftLayer_Tag::getReferences", func() { 88 | It("API Call Test", func() { 89 | _, err := sl_service.GetReferences() 90 | Expect(err).To(Succeed()) 91 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 92 | }) 93 | }) 94 | Context("SoftLayer_Tag::getTagByTagName", func() { 95 | It("API Call Test", func() { 96 | _, err := sl_service.GetTagByTagName(nil) 97 | Expect(err).To(Succeed()) 98 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 99 | }) 100 | }) 101 | Context("SoftLayer_Tag::getUnattachedTagsForCurrentUser", func() { 102 | It("API Call Test", func() { 103 | _, err := sl_service.GetUnattachedTagsForCurrentUser() 104 | Expect(err).To(Succeed()) 105 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 106 | }) 107 | }) 108 | Context("SoftLayer_Tag::setTags", func() { 109 | It("API Call Test", func() { 110 | _, err := sl_service.SetTags(nil, nil, nil) 111 | Expect(err).To(Succeed()) 112 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 113 | }) 114 | }) 115 | }) 116 | 117 | }) 118 | -------------------------------------------------------------------------------- /services/utility.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package services 15 | 16 | import ( 17 | "fmt" 18 | "strings" 19 | 20 | "github.com/softlayer/softlayer-go/session" 21 | "github.com/softlayer/softlayer-go/sl" 22 | ) 23 | 24 | // no documentation yet 25 | type Utility_Network struct { 26 | Session session.SLSession 27 | Options sl.Options 28 | } 29 | 30 | // GetUtilityNetworkService returns an instance of the Utility_Network SoftLayer service 31 | func GetUtilityNetworkService(sess session.SLSession) Utility_Network { 32 | return Utility_Network{Session: sess} 33 | } 34 | 35 | func (r Utility_Network) Id(id int) Utility_Network { 36 | r.Options.Id = &id 37 | return r 38 | } 39 | 40 | func (r Utility_Network) Mask(mask string) Utility_Network { 41 | if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) { 42 | mask = fmt.Sprintf("mask[%s]", mask) 43 | } 44 | 45 | r.Options.Mask = mask 46 | return r 47 | } 48 | 49 | func (r Utility_Network) Filter(filter string) Utility_Network { 50 | r.Options.Filter = filter 51 | return r 52 | } 53 | 54 | func (r Utility_Network) Limit(limit int) Utility_Network { 55 | r.Options.Limit = &limit 56 | return r 57 | } 58 | 59 | func (r Utility_Network) Offset(offset int) Utility_Network { 60 | r.Options.Offset = &offset 61 | return r 62 | } 63 | 64 | // A method used to return the nameserver information for a given address 65 | func (r Utility_Network) NsLookup(address *string, typ *string) (resp string, err error) { 66 | params := []interface{}{ 67 | address, 68 | typ, 69 | } 70 | err = r.Session.DoRequest("SoftLayer_Utility_Network", "nsLookup", params, &r.Options, &resp) 71 | return 72 | } 73 | 74 | // Perform a WHOIS lookup from SoftLayer's application servers on the given IP address or hostname and return the raw results of that command. The returned result is similar to the result received from running the command `whois` from a UNIX command shell. A WHOIS lookup queries a host's registrar to retrieve domain registrant information including registration date, expiry date, and the administrative, technical, billing, and abuse contacts responsible for a domain. WHOIS lookups are useful for determining a physical contact responsible for a particular domain. WHOIS lookups are also useful for determining domain availability. Running a WHOIS lookup on an IP address queries ARIN for that IP block's ownership, and is helpful for determining a physical entity responsible for a certain IP address. 75 | func (r Utility_Network) Whois(address *string) (resp string, err error) { 76 | params := []interface{}{ 77 | address, 78 | } 79 | err = r.Session.DoRequest("SoftLayer_Utility_Network", "whois", params, &r.Options, &resp) 80 | return 81 | } 82 | -------------------------------------------------------------------------------- /services/utility_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Utility Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Utility_Network service", func() { 18 | var sl_service services.Utility_Network 19 | BeforeEach(func() { 20 | sl_service = services.GetUtilityNetworkService(slsession) 21 | }) 22 | Context("SoftLayer_Utility_Network Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Utility_Network Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Utility_Network::nsLookup", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.NsLookup(nil, nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Utility_Network::whois", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.Whois(nil) 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | }) 60 | 61 | }) 62 | -------------------------------------------------------------------------------- /services/verify_test.go: -------------------------------------------------------------------------------- 1 | // AUTO GENERATED by tools/loadmeta.go 2 | package services_test 3 | 4 | import ( 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | "github.com/softlayer/softlayer-go/services" 8 | "github.com/softlayer/softlayer-go/session/sessionfakes" 9 | ) 10 | 11 | var _ = Describe("Verify Tests", func() { 12 | var slsession *sessionfakes.FakeSLSession 13 | BeforeEach(func() { 14 | slsession = &sessionfakes.FakeSLSession{} 15 | }) 16 | 17 | Context("Testing SoftLayer_Verify_Api_HttpObj service", func() { 18 | var sl_service services.Verify_Api_HttpObj 19 | BeforeEach(func() { 20 | sl_service = services.GetVerifyApiHttpObjService(slsession) 21 | }) 22 | Context("SoftLayer_Verify_Api_HttpObj Set Options", func() { 23 | It("Set Options properly", func() { 24 | t_id := 1234 25 | t_filter := "{'testFilter':{'test'}}" 26 | t_limit := 100 27 | t_offset := 5 28 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 29 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 30 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 31 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 32 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 33 | }) 34 | }) 35 | Context("SoftLayer_Verify_Api_HttpObj Set Mask", func() { 36 | It("Set Options properly", func() { 37 | t_mask1 := "mask[test,test2]" 38 | sl_service = sl_service.Mask(t_mask1) 39 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 40 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 41 | sl_service = sl_service.Mask("test,test2") 42 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 43 | }) 44 | }) 45 | Context("SoftLayer_Verify_Api_HttpObj::createObject", func() { 46 | It("API Call Test", func() { 47 | _, err := sl_service.CreateObject(nil) 48 | Expect(err).To(Succeed()) 49 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 50 | }) 51 | }) 52 | Context("SoftLayer_Verify_Api_HttpObj::deleteObject", func() { 53 | It("API Call Test", func() { 54 | _, err := sl_service.DeleteObject() 55 | Expect(err).To(Succeed()) 56 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 57 | }) 58 | }) 59 | Context("SoftLayer_Verify_Api_HttpObj::getAllObjects", func() { 60 | It("API Call Test", func() { 61 | _, err := sl_service.GetAllObjects() 62 | Expect(err).To(Succeed()) 63 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 64 | }) 65 | }) 66 | Context("SoftLayer_Verify_Api_HttpObj::getObject", func() { 67 | It("API Call Test", func() { 68 | _, err := sl_service.GetObject() 69 | Expect(err).To(Succeed()) 70 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 71 | }) 72 | }) 73 | }) 74 | 75 | Context("Testing SoftLayer_Verify_Api_HttpsObj service", func() { 76 | var sl_service services.Verify_Api_HttpsObj 77 | BeforeEach(func() { 78 | sl_service = services.GetVerifyApiHttpsObjService(slsession) 79 | }) 80 | Context("SoftLayer_Verify_Api_HttpsObj Set Options", func() { 81 | It("Set Options properly", func() { 82 | t_id := 1234 83 | t_filter := "{'testFilter':{'test'}}" 84 | t_limit := 100 85 | t_offset := 5 86 | sl_service = sl_service.Id(t_id).Filter(t_filter).Offset(t_offset).Limit(t_limit) 87 | Expect(sl_service.Options.Id).To(HaveValue(Equal(t_id))) 88 | Expect(sl_service.Options.Filter).To(HaveValue(Equal(t_filter))) 89 | Expect(sl_service.Options.Limit).To(HaveValue(Equal(t_limit))) 90 | Expect(sl_service.Options.Offset).To(HaveValue(Equal(t_offset))) 91 | }) 92 | }) 93 | Context("SoftLayer_Verify_Api_HttpsObj Set Mask", func() { 94 | It("Set Options properly", func() { 95 | t_mask1 := "mask[test,test2]" 96 | sl_service = sl_service.Mask(t_mask1) 97 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 98 | // Mask("test,test2") should set the mask to be "mask[test,test2]" aka t_mask1 99 | sl_service = sl_service.Mask("test,test2") 100 | Expect(sl_service.Options.Mask).To(HaveValue(Equal(t_mask1))) 101 | }) 102 | }) 103 | Context("SoftLayer_Verify_Api_HttpsObj::createObject", func() { 104 | It("API Call Test", func() { 105 | _, err := sl_service.CreateObject(nil) 106 | Expect(err).To(Succeed()) 107 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 108 | }) 109 | }) 110 | Context("SoftLayer_Verify_Api_HttpsObj::deleteObject", func() { 111 | It("API Call Test", func() { 112 | _, err := sl_service.DeleteObject() 113 | Expect(err).To(Succeed()) 114 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 115 | }) 116 | }) 117 | Context("SoftLayer_Verify_Api_HttpsObj::getAllObjects", func() { 118 | It("API Call Test", func() { 119 | _, err := sl_service.GetAllObjects() 120 | Expect(err).To(Succeed()) 121 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 122 | }) 123 | }) 124 | Context("SoftLayer_Verify_Api_HttpsObj::getObject", func() { 125 | It("API Call Test", func() { 126 | _, err := sl_service.GetObject() 127 | Expect(err).To(Succeed()) 128 | Expect(slsession.DoRequestCallCount()).To(Equal(1)) 129 | }) 130 | }) 131 | }) 132 | 133 | }) 134 | -------------------------------------------------------------------------------- /session/iamupdater.go: -------------------------------------------------------------------------------- 1 | package session 2 | 3 | //counterfeiter:generate . IAMUpdater 4 | type IAMUpdater interface { 5 | Update(token string, refresh string) 6 | } 7 | 8 | type LogIamUpdater struct { 9 | debug bool 10 | } 11 | 12 | func NewLogIamUpdater(debug bool) *LogIamUpdater { 13 | return &LogIamUpdater{ 14 | debug: debug, 15 | } 16 | } 17 | 18 | func (iamupdater *LogIamUpdater) Update(token string, refresh string) { 19 | if iamupdater.debug { 20 | Logger.Printf("[DEBUG] New Token: %s\n", token) 21 | Logger.Printf("[DEBUG] New Refresh Token: %s\n", refresh) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /session/sessionfakes/fake_iamupdater.go: -------------------------------------------------------------------------------- 1 | // Code generated by counterfeiter. DO NOT EDIT. 2 | package sessionfakes 3 | 4 | import ( 5 | "sync" 6 | 7 | "github.com/softlayer/softlayer-go/session" 8 | ) 9 | 10 | type FakeIAMUpdater struct { 11 | UpdateStub func(string, string) 12 | updateMutex sync.RWMutex 13 | updateArgsForCall []struct { 14 | arg1 string 15 | arg2 string 16 | } 17 | invocations map[string][][]interface{} 18 | invocationsMutex sync.RWMutex 19 | } 20 | 21 | func (fake *FakeIAMUpdater) Update(arg1 string, arg2 string) { 22 | fake.updateMutex.Lock() 23 | fake.updateArgsForCall = append(fake.updateArgsForCall, struct { 24 | arg1 string 25 | arg2 string 26 | }{arg1, arg2}) 27 | stub := fake.UpdateStub 28 | fake.recordInvocation("Update", []interface{}{arg1, arg2}) 29 | fake.updateMutex.Unlock() 30 | if stub != nil { 31 | fake.UpdateStub(arg1, arg2) 32 | } 33 | } 34 | 35 | func (fake *FakeIAMUpdater) UpdateCallCount() int { 36 | fake.updateMutex.RLock() 37 | defer fake.updateMutex.RUnlock() 38 | return len(fake.updateArgsForCall) 39 | } 40 | 41 | func (fake *FakeIAMUpdater) UpdateCalls(stub func(string, string)) { 42 | fake.updateMutex.Lock() 43 | defer fake.updateMutex.Unlock() 44 | fake.UpdateStub = stub 45 | } 46 | 47 | func (fake *FakeIAMUpdater) UpdateArgsForCall(i int) (string, string) { 48 | fake.updateMutex.RLock() 49 | defer fake.updateMutex.RUnlock() 50 | argsForCall := fake.updateArgsForCall[i] 51 | return argsForCall.arg1, argsForCall.arg2 52 | } 53 | 54 | func (fake *FakeIAMUpdater) Invocations() map[string][][]interface{} { 55 | fake.invocationsMutex.RLock() 56 | defer fake.invocationsMutex.RUnlock() 57 | fake.updateMutex.RLock() 58 | defer fake.updateMutex.RUnlock() 59 | copiedInvocations := map[string][][]interface{}{} 60 | for key, value := range fake.invocations { 61 | copiedInvocations[key] = value 62 | } 63 | return copiedInvocations 64 | } 65 | 66 | func (fake *FakeIAMUpdater) recordInvocation(key string, args []interface{}) { 67 | fake.invocationsMutex.Lock() 68 | defer fake.invocationsMutex.Unlock() 69 | if fake.invocations == nil { 70 | fake.invocations = map[string][][]interface{}{} 71 | } 72 | if fake.invocations[key] == nil { 73 | fake.invocations[key] = [][]interface{}{} 74 | } 75 | fake.invocations[key] = append(fake.invocations[key], args) 76 | } 77 | 78 | var _ session.IAMUpdater = new(FakeIAMUpdater) 79 | -------------------------------------------------------------------------------- /session/sessionfakes/fake_transport_handler.go: -------------------------------------------------------------------------------- 1 | // Code generated by counterfeiter. DO NOT EDIT. 2 | package sessionfakes 3 | 4 | import ( 5 | "sync" 6 | 7 | "github.com/softlayer/softlayer-go/session" 8 | "github.com/softlayer/softlayer-go/sl" 9 | ) 10 | 11 | type FakeTransportHandler struct { 12 | DoRequestStub func(*session.Session, string, string, []interface{}, *sl.Options, interface{}) error 13 | doRequestMutex sync.RWMutex 14 | doRequestArgsForCall []struct { 15 | arg1 *session.Session 16 | arg2 string 17 | arg3 string 18 | arg4 []interface{} 19 | arg5 *sl.Options 20 | arg6 interface{} 21 | } 22 | doRequestReturns struct { 23 | result1 error 24 | } 25 | doRequestReturnsOnCall map[int]struct { 26 | result1 error 27 | } 28 | invocations map[string][][]interface{} 29 | invocationsMutex sync.RWMutex 30 | } 31 | 32 | func (fake *FakeTransportHandler) DoRequest(arg1 *session.Session, arg2 string, arg3 string, arg4 []interface{}, arg5 *sl.Options, arg6 interface{}) error { 33 | var arg4Copy []interface{} 34 | if arg4 != nil { 35 | arg4Copy = make([]interface{}, len(arg4)) 36 | copy(arg4Copy, arg4) 37 | } 38 | fake.doRequestMutex.Lock() 39 | ret, specificReturn := fake.doRequestReturnsOnCall[len(fake.doRequestArgsForCall)] 40 | fake.doRequestArgsForCall = append(fake.doRequestArgsForCall, struct { 41 | arg1 *session.Session 42 | arg2 string 43 | arg3 string 44 | arg4 []interface{} 45 | arg5 *sl.Options 46 | arg6 interface{} 47 | }{arg1, arg2, arg3, arg4Copy, arg5, arg6}) 48 | stub := fake.DoRequestStub 49 | fakeReturns := fake.doRequestReturns 50 | fake.recordInvocation("DoRequest", []interface{}{arg1, arg2, arg3, arg4Copy, arg5, arg6}) 51 | fake.doRequestMutex.Unlock() 52 | if stub != nil { 53 | return stub(arg1, arg2, arg3, arg4, arg5, arg6) 54 | } 55 | if specificReturn { 56 | return ret.result1 57 | } 58 | return fakeReturns.result1 59 | } 60 | 61 | func (fake *FakeTransportHandler) DoRequestCallCount() int { 62 | fake.doRequestMutex.RLock() 63 | defer fake.doRequestMutex.RUnlock() 64 | return len(fake.doRequestArgsForCall) 65 | } 66 | 67 | func (fake *FakeTransportHandler) DoRequestCalls(stub func(*session.Session, string, string, []interface{}, *sl.Options, interface{}) error) { 68 | fake.doRequestMutex.Lock() 69 | defer fake.doRequestMutex.Unlock() 70 | fake.DoRequestStub = stub 71 | } 72 | 73 | func (fake *FakeTransportHandler) DoRequestArgsForCall(i int) (*session.Session, string, string, []interface{}, *sl.Options, interface{}) { 74 | fake.doRequestMutex.RLock() 75 | defer fake.doRequestMutex.RUnlock() 76 | argsForCall := fake.doRequestArgsForCall[i] 77 | return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 78 | } 79 | 80 | func (fake *FakeTransportHandler) DoRequestReturns(result1 error) { 81 | fake.doRequestMutex.Lock() 82 | defer fake.doRequestMutex.Unlock() 83 | fake.DoRequestStub = nil 84 | fake.doRequestReturns = struct { 85 | result1 error 86 | }{result1} 87 | } 88 | 89 | func (fake *FakeTransportHandler) DoRequestReturnsOnCall(i int, result1 error) { 90 | fake.doRequestMutex.Lock() 91 | defer fake.doRequestMutex.Unlock() 92 | fake.DoRequestStub = nil 93 | if fake.doRequestReturnsOnCall == nil { 94 | fake.doRequestReturnsOnCall = make(map[int]struct { 95 | result1 error 96 | }) 97 | } 98 | fake.doRequestReturnsOnCall[i] = struct { 99 | result1 error 100 | }{result1} 101 | } 102 | 103 | func (fake *FakeTransportHandler) Invocations() map[string][][]interface{} { 104 | fake.invocationsMutex.RLock() 105 | defer fake.invocationsMutex.RUnlock() 106 | fake.doRequestMutex.RLock() 107 | defer fake.doRequestMutex.RUnlock() 108 | copiedInvocations := map[string][][]interface{}{} 109 | for key, value := range fake.invocations { 110 | copiedInvocations[key] = value 111 | } 112 | return copiedInvocations 113 | } 114 | 115 | func (fake *FakeTransportHandler) recordInvocation(key string, args []interface{}) { 116 | fake.invocationsMutex.Lock() 117 | defer fake.invocationsMutex.Unlock() 118 | if fake.invocations == nil { 119 | fake.invocations = map[string][][]interface{}{} 120 | } 121 | if fake.invocations[key] == nil { 122 | fake.invocations[key] = [][]interface{}{} 123 | } 124 | fake.invocations[key] = append(fake.invocations[key], args) 125 | } 126 | 127 | var _ session.TransportHandler = new(FakeTransportHandler) 128 | -------------------------------------------------------------------------------- /sl/errors.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sl 18 | 19 | import "fmt" 20 | 21 | // Error contains detailed information about an API error, which can be useful 22 | // for debugging, or when finer error handling is required than just the mere 23 | // presence or absence of an error. 24 | // 25 | // Error implements the error interface 26 | type Error struct { 27 | StatusCode int 28 | Exception string `json:"code"` 29 | Message string `json:"error"` 30 | Wrapped error 31 | } 32 | 33 | func (r Error) Error() string { 34 | if r.Wrapped != nil { 35 | return r.Wrapped.Error() 36 | } 37 | 38 | var msg string 39 | if r.Exception != "" { 40 | msg = r.Exception + ": " 41 | } 42 | if r.Message != "" { 43 | msg = msg + r.Message + " " 44 | } 45 | if r.StatusCode != 0 { 46 | msg = fmt.Sprintf("%s(HTTP %d)", msg, r.StatusCode) 47 | } 48 | return msg 49 | } 50 | -------------------------------------------------------------------------------- /sl/errors_test.go: -------------------------------------------------------------------------------- 1 | package sl_test 2 | 3 | import ( 4 | "errors" 5 | . "github.com/onsi/ginkgo/v2" 6 | . "github.com/onsi/gomega" 7 | 8 | "github.com/softlayer/softlayer-go/sl" 9 | ) 10 | 11 | var _ = Describe("Error Tests", func() { 12 | var sl_err sl.Error 13 | var base_err error 14 | Context("Error Tests", func() { 15 | BeforeEach(func() { 16 | base_err = errors.New("TTTTT") 17 | sl_err = sl.Error{ 18 | StatusCode: 0, 19 | Exception: "", 20 | Message: "", 21 | Wrapped: base_err, 22 | } 23 | }) 24 | It("Basic Error Tests", func() { 25 | Expect(sl_err.Error()).To(Equal("TTTTT")) 26 | sl_err.Wrapped = nil 27 | Expect(sl_err.Error()).To(Equal("")) 28 | sl_err.Exception = "AAA" 29 | Expect(sl_err.Error()).To(Equal("AAA: ")) 30 | sl_err.Message = "BBB" 31 | Expect(sl_err.Error()).To(Equal("AAA: BBB ")) 32 | sl_err.StatusCode = 99 33 | Expect(sl_err.Error()).To(Equal("AAA: BBB (HTTP 99)")) 34 | }) 35 | 36 | }) 37 | }) 38 | -------------------------------------------------------------------------------- /sl/helpers_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sl 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/softlayer/softlayer-go/datatypes" 23 | "reflect" 24 | ) 25 | 26 | func TestGet(t *testing.T) { 27 | // primitive test values 28 | testString := "Test" 29 | testInt := 123 30 | testFloat := 3.14159 31 | testBool := true 32 | 33 | // Pass by value 34 | if Get(testString) != "Test" { 35 | t.Errorf("Expected %s, got %s", testString, Get(testString)) 36 | } 37 | 38 | if Get(testInt) != 123 { 39 | t.Errorf("Expected %d, got %d", testInt, Get(testInt)) 40 | } 41 | 42 | if Get(testFloat) != 3.14159 { 43 | t.Errorf("Expected %f, got %f", testFloat, Get(testFloat)) 44 | } 45 | 46 | if Get(testBool) != true { 47 | t.Errorf("Expected %t, got %t", testBool, Get(testBool)) 48 | } 49 | 50 | // Pass by reference 51 | if Get(&testString) != "Test" { 52 | t.Errorf("Expected %s, got %s", testString, Get(&testString)) 53 | } 54 | 55 | if Get(&testInt) != 123 { 56 | t.Errorf("Expected %d, got %d", testInt, Get(&testInt)) 57 | } 58 | 59 | if Get(&testFloat) != 3.14159 { 60 | t.Errorf("Expected %f, got %f", testFloat, Get(&testFloat)) 61 | } 62 | 63 | if Get(&testBool) != true { 64 | t.Errorf("Expected %t, got %t", testBool, Get(&testBool)) 65 | } 66 | 67 | // zero value primitive 68 | var testZero int 69 | 70 | if Get(testZero) != 0 { 71 | t.Errorf("Expected %d, got %d", testZero, Get(testZero)) 72 | } 73 | 74 | if Get(&testZero) != 0 { 75 | t.Errorf("Expected %d, got %d", testZero, Get(&testZero)) 76 | } 77 | 78 | // nil pointer to primitive 79 | var testNil *int 80 | 81 | if Get(testNil) != 0 { 82 | t.Errorf("Expected %d, got %d", testNil, Get(testNil)) 83 | } 84 | } 85 | 86 | func TestGetStruct(t *testing.T) { 87 | // Complex datatype test with 88 | // 1. non-nil primitive 89 | // 2. nil primitive (anything not set) 90 | // 3. non-nil ptr-to-struct type (Account) 91 | // 4. nil ptr-to-struct type (any unspecified ptr-to-struct field, e.g., Location) 92 | // 5. non-nil slice type (ActiveTickets) 93 | // 6. zero-val slice type (unspecified, e.g., ActiveTransactions) 94 | 95 | account := datatypes.Account{ 96 | Id: Int(456), 97 | } 98 | 99 | tickets := []datatypes.Ticket{ 100 | datatypes.Ticket{ 101 | Id: Int(789), 102 | }, 103 | } 104 | 105 | location := datatypes.Location{} 106 | 107 | var transactions []datatypes.Provisioning_Version1_Transaction 108 | 109 | d := datatypes.Virtual_Guest{ 110 | Id: Int(123), 111 | Account: &account, 112 | ActiveTickets: tickets, 113 | } 114 | 115 | if Get(d.Id) != 123 { 116 | t.Errorf("Expected %d, got %d", *d.Id, Get(d.Id)) 117 | } 118 | 119 | if !reflect.DeepEqual(Get(d.Account), account) { 120 | t.Errorf("Expected %v, got %v", account, Get(d.Account)) 121 | } 122 | 123 | if !reflect.DeepEqual(Get(d.Location), location) { 124 | t.Errorf("Expected %v, got %v", location, Get(d.Location)) 125 | } 126 | 127 | if !reflect.DeepEqual(Get(d.ActiveTickets), tickets) { 128 | t.Errorf("Expected %v, got %v", tickets, Get(d.ActiveTickets)) 129 | } 130 | 131 | if !reflect.DeepEqual(Get(d.ActiveTransactions), transactions) { 132 | t.Errorf("Expected %#v, got %#v", transactions, Get(d.ActiveTransactions)) 133 | } 134 | } 135 | 136 | func TestGetDefaults(t *testing.T) { 137 | var testptr *int 138 | 139 | if Get(testptr, 123) != 123 { 140 | t.Errorf("Expected 123, got %d", Get(testptr, 123)) 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /sl/options.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sl 18 | 19 | import ( 20 | "math" 21 | ) 22 | 23 | var DefaultLimit = 50 24 | 25 | // Options contains the individual query parameters that can be applied to a request. 26 | type Options struct { 27 | Id *int 28 | Mask string 29 | Filter string 30 | Limit *int 31 | Offset *int 32 | TotalItems int 33 | } 34 | 35 | // returns Math.Ciel((TotalItems - Limit) / Limit) 36 | func (opt *Options) GetRemainingAPICalls() int { 37 | Total := float64(opt.TotalItems) 38 | Limit := float64(*opt.Limit) 39 | return int(math.Ceil((Total - Limit) / Limit)) 40 | } 41 | 42 | // Makes sure the limit is set to something, not 0 or 1. Will set to default if no other limit is set. 43 | func (opt *Options) ValidateLimit() int { 44 | if opt.Limit == nil || *opt.Limit < 2 { 45 | opt.Limit = &DefaultLimit 46 | } 47 | return *opt.Limit 48 | } 49 | 50 | func (opt *Options) SetTotalItems(total int) { 51 | opt.TotalItems = total 52 | } 53 | 54 | func (opt *Options) SetOffset(offset int) { 55 | opt.Offset = &offset 56 | } 57 | 58 | func (opt *Options) SetLimit(limit int) { 59 | opt.Limit = &limit 60 | } 61 | -------------------------------------------------------------------------------- /sl/options_test.go: -------------------------------------------------------------------------------- 1 | package sl_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | 7 | "github.com/softlayer/softlayer-go/sl" 8 | ) 9 | 10 | var _ = Describe("Options Tests", func() { 11 | var sl_limit int 12 | var sl_id int 13 | var sl_mask string 14 | var sl_filter string 15 | var sl_offset int 16 | var sl_totalItems int 17 | Context("Option Setter Testing", func() { 18 | BeforeEach(func() { 19 | sl_limit = 10 20 | sl_id = 99999 21 | sl_mask = "mask[id, hostname]" 22 | sl_filter = `{"test":{"operation":"ok"}}` 23 | sl_offset = 0 24 | sl_totalItems = 0 25 | }) 26 | It("Test GetRemainingAPICalls", func() { 27 | options := sl.Options{ 28 | TotalItems: 1000, 29 | Limit: &sl_limit, 30 | } 31 | result := options.GetRemainingAPICalls() 32 | Expect(result).To(Equal(99)) 33 | }) 34 | It("Test ValidateLimit", func() { 35 | options := sl.Options{} 36 | limit := options.ValidateLimit() 37 | Expect(limit).To(Equal(sl.DefaultLimit)) 38 | Expect(*options.Limit).To(Equal(sl.DefaultLimit)) 39 | options.SetLimit(123) 40 | Expect(*options.Limit).To(Equal(123)) 41 | }) 42 | It("Setter Tests", func() { 43 | options := sl.Options{} 44 | options.SetTotalItems(44) 45 | Expect(options.TotalItems).To(Equal(44)) 46 | options.SetOffset(33) 47 | Expect(*options.Offset).To(Equal(33)) 48 | options.SetLimit(22) 49 | Expect(*options.Limit).To(Equal(22)) 50 | }) 51 | It("Basic Setting Tests", func() { 52 | options := sl.Options{ 53 | Id: &sl_id, 54 | Mask: sl_mask, 55 | Filter: sl_filter, 56 | Limit: &sl_limit, 57 | Offset: &sl_offset, 58 | TotalItems: sl_totalItems, 59 | } 60 | Expect(options.Limit).To(Equal(&sl_limit)) 61 | }) 62 | 63 | }) 64 | }) 65 | -------------------------------------------------------------------------------- /sl/sl_test.go: -------------------------------------------------------------------------------- 1 | package sl_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | 7 | "testing" 8 | ) 9 | 10 | func TestServices(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "SL Package Tests") 13 | } 14 | -------------------------------------------------------------------------------- /sl/version.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2024 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 5 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 8 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | * See the License for the specific language governing permissions and limitations under the License. 10 | */ 11 | 12 | // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY 13 | 14 | package sl 15 | 16 | import "fmt" 17 | 18 | type VersionInfo struct { 19 | Major int 20 | Minor int 21 | Patch int 22 | Pre string 23 | } 24 | 25 | var Version = VersionInfo{ 26 | Major: 1, 27 | Minor: 1, 28 | Patch: 3, 29 | Pre: "", 30 | } 31 | 32 | func (v VersionInfo) String() string { 33 | result := fmt.Sprintf("v%d.%d.%d", v.Major, v.Minor, v.Patch) 34 | 35 | if v.Pre != "" { 36 | result += fmt.Sprintf("-%s", v.Pre) 37 | } 38 | 39 | return result 40 | } 41 | -------------------------------------------------------------------------------- /sl/version_test.go: -------------------------------------------------------------------------------- 1 | package sl_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo/v2" 5 | . "github.com/onsi/gomega" 6 | 7 | "github.com/softlayer/softlayer-go/sl" 8 | ) 9 | 10 | var _ = Describe("Version Tests", func() { 11 | Context("Get Version Tests", func() { 12 | It("Setting Version", func() { 13 | version := sl.VersionInfo{ 14 | Major: 1, Minor: 2, Patch: 3, Pre: "", 15 | } 16 | Expect(version.String()).To(Equal("v1.2.3")) 17 | }) 18 | It("Pre Version", func() { 19 | version := sl.VersionInfo{ 20 | Major: 1, Minor: 2, Patch: 3, Pre: "a", 21 | } 22 | Expect(version.String()).To(Equal("v1.2.3-a")) 23 | }) 24 | It("Base Version", func() { 25 | version := sl.Version 26 | Expect(version.String()).Should(HavePrefix("v")) 27 | }) 28 | }) 29 | }) 30 | -------------------------------------------------------------------------------- /tools/main.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/softlayer/softlayer-go/generator" 21 | ) 22 | 23 | func main() { 24 | generator.Execute() 25 | } 26 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | 3 | package tools 4 | 5 | import ( 6 | _ "github.com/maxbrunsfeld/counterfeiter/v6" 7 | ) 8 | 9 | // This file imports packages that are used when running go generate, or used 10 | // during the development process but not otherwise depended on by built code. 11 | -------------------------------------------------------------------------------- /tools/version.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | "go/format" 23 | "html/template" 24 | "os" 25 | 26 | "flag" 27 | "github.com/softlayer/softlayer-go/sl" 28 | ) 29 | 30 | const license = `/** 31 | * Copyright 2016-2024 IBM Corp. 32 | * 33 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 34 | * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 35 | * 36 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 37 | * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | * See the License for the specific language governing permissions and limitations under the License. 39 | */ 40 | ` 41 | const codegenWarning = `// AUTOMATICALLY GENERATED CODE - DO NOT MODIFY` 42 | 43 | var versionfile = fmt.Sprintf(`%s 44 | 45 | %s 46 | 47 | package sl 48 | 49 | import "fmt" 50 | 51 | type VersionInfo struct { 52 | Major int 53 | Minor int 54 | Patch int 55 | Pre string 56 | } 57 | 58 | var Version = VersionInfo { 59 | Major: {{.Major}}, 60 | Minor: {{.Minor}}, 61 | Patch: {{.Patch}}, 62 | Pre: "{{.Pre}}", 63 | } 64 | 65 | func (v VersionInfo) String() string { 66 | result := fmt.Sprintf("v%%d.%%d.%%d", v.Major, v.Minor, v.Patch) 67 | 68 | if v.Pre != "" { 69 | result += fmt.Sprintf("-%%s", v.Pre) 70 | } 71 | 72 | return result 73 | } 74 | 75 | `, license, codegenWarning) 76 | 77 | const ( 78 | bumpUsage = "specify one of major|minor|patch to bump that specifier" 79 | prerelUsage = "optional prerelease stamp (e.g. alpha, beta, rc.1" 80 | ) 81 | 82 | func version() { 83 | var bump, prerelease string 84 | 85 | flagset := flag.NewFlagSet(os.Args[1], flag.ExitOnError) 86 | 87 | flagset.StringVar(&bump, "bump", "", bumpUsage) 88 | flagset.StringVar(&bump, "b", "", bumpUsage+" (shorthand)") 89 | 90 | flagset.StringVar(&prerelease, "prerelease", "", prerelUsage) 91 | flagset.StringVar(&prerelease, "p", "", prerelUsage+" (shorthand)") 92 | 93 | flagset.Parse(os.Args[2:]) 94 | 95 | v := sl.Version 96 | 97 | switch bump { 98 | case "major": 99 | v.Major++ 100 | v.Minor = 0 101 | v.Patch = 0 102 | v.Pre = prerelease 103 | case "minor": 104 | v.Minor++ 105 | v.Patch = 0 106 | v.Pre = prerelease 107 | case "patch": 108 | v.Patch++ 109 | v.Pre = prerelease 110 | case "": 111 | default: 112 | fmt.Printf("Invalid value for bump: %s", bump) 113 | os.Exit(1) 114 | } 115 | 116 | writeVersionFile(v) 117 | 118 | fmt.Println(v) 119 | } 120 | 121 | func writeVersionFile(v sl.VersionInfo) { 122 | // Generate source 123 | var buf bytes.Buffer 124 | t := template.New("version") 125 | template.Must(t.Parse(versionfile)).Execute(&buf, v) 126 | 127 | //fmt.Println(string(buf.Bytes())) 128 | 129 | // format go file 130 | pretty, err := format.Source(buf.Bytes()) 131 | if err != nil { 132 | fmt.Println(err) 133 | os.Exit(1) 134 | } 135 | 136 | // write go file 137 | f, err := os.Create("sl/version.go") 138 | if err != nil { 139 | fmt.Println(err) 140 | os.Exit(1) 141 | } 142 | defer f.Close() 143 | fmt.Fprintf(f, "%s", pretty) 144 | } 145 | --------------------------------------------------------------------------------