Skip to content

Commit

Permalink
new resource: servicecatalog_order (#59)
Browse files Browse the repository at this point in the history
* new resource: servicecatalog_order

* cleanup

---------

Co-authored-by: Andrei Predoiu <[email protected]>
  • Loading branch information
marcosdiez and Andrei-Predoiu authored Oct 16, 2023
1 parent f149590 commit 92fa401
Show file tree
Hide file tree
Showing 9 changed files with 1,004 additions and 14 deletions.
96 changes: 96 additions & 0 deletions docs/resources/servicecatalog_order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "servicenow-data_servicecatalog_order Resource - terraform-provider-servicenow-data"
subcategory: ""
description: |-
A Service Now ServiceCatalog order. It consumes the "ordernow" API ( https://developer.servicenow.com/dev.do#!/reference/api/utah/rest/cServiceCatalogAPI#servicecat-POST-items-order_now )
Please note that Service Now catalog orders are immutable.
That means if you try to destroy an order, it will be removed from terraform but nothing will happen in Service Now.
Also, if you try to update an order, it will be removed from terraform and a new one will be created. In other words, you will end up with two orders in service now.
---

# servicenow-data_servicecatalog_order (Resource)

A Service Now ServiceCatalog order. It consumes the "order_now" API ( https://developer.servicenow.com/dev.do#!/reference/api/utah/rest/c_ServiceCatalogAPI#servicecat-POST-items-order_now )

Please note that Service Now catalog orders are immutable.
That means if you try to destroy an order, it will be removed from terraform but nothing will happen in Service Now.
Also, if you try to update an order, it will be removed from terraform and a new one will be created. In other words, you will end up with two orders in service now.

## Example Usage

```terraform
resource "servicenow-data_servicecatalog_order" "order" {
sc_cat_item_id = "e2a2e5bc1b757850d5a68773604bcb32"
variables = {
"var1" : "value1",
"var2" : "value2",
"var3" : "value3",
}
}
# sample output
# "result": {
# "$$uiNotification": [],
# "number": "REQ0227772",
# "parent_id": null,
# "parent_table": "task",
# "request_id": "24e3e99e97f53110af6574971153afaa",
# "request_number": "REQ0227772",
# "sys_id": "24e3e99e97f53110af6574971153afaa",
# "table": "sc_request"
# }
data "servicenow-data_table_row" "request" {
table_id = "sc_request"
row_data = {
"number" : servicenow-data_servicecatalog_order.order.request_number
}
}
data "servicenow-data_table_row" "request_item" {
table_id = "sc_req_item"
row_data = {
"request" : data.servicenow-data_table_row.request.sys_id
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `sc_cat_item_id` (String) The id of the catalog item to order
- `variables` (Map of String) Name-value pairs of all mandatory cart item variables. Mandatory variables are defined on the associated form.

### Optional

- `get_portal_messages` (String)
- `sysparm_also_request_for` (String) Comma-separated string of user sys_ids of other users for which to order the specified item. User sys_ids are located in the User [sys_user] table.
- `sysparm_no_validation` (String)
- `sysparm_quantity` (Number) Quantity of the item. Cannot be a negative number.
- `sysparm_requested_for` (String) Sys_id of the user for whom to order the specified item. Located in the User [sys_user] table.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `id` (String) The ID of this resource.
- `number` (String) Number of the generated request
- `parent_id` (String) If available, the sys_id of the parent record from which the request is created
- `parent_table` (String) If available, the name of the parent table from which the request is created.
- `request_id` (String) Sys_id of the order request.
- `request_number` (String) Request number.
- `sys_id` (String) Sys_id of the order.
- `table` (String) Table name of the request.

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `default` (String)
- `delete` (String)
- `read` (String)
- `update` (String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
resource "servicenow-data_servicecatalog_order" "order" {
sc_cat_item_id = "e2a2e5bc1b757850d5a68773604bcb32"
variables = {
"var1" : "value1",
"var2" : "value2",
"var3" : "value3",
}
}

# sample output
# "result": {
# "$$uiNotification": [],
# "number": "REQ0227772",
# "parent_id": null,
# "parent_table": "task",
# "request_id": "24e3e99e97f53110af6574971153afaa",
# "request_number": "REQ0227772",
# "sys_id": "24e3e99e97f53110af6574971153afaa",
# "table": "sc_request"
# }

data "servicenow-data_table_row" "request" {
table_id = "sc_request"
row_data = {
"number" : servicenow-data_servicecatalog_order.order.request_number
}
}

data "servicenow-data_table_row" "request_item" {
table_id = "sc_req_item"
row_data = {
"request" : data.servicenow-data_table_row.request.sys_id
}
}
42 changes: 42 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,39 @@ go 1.19
require github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.19.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.13.0 // indirect
cloud.google.com/go/storage v1.28.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.37.0 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-getter v1.5.3 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.5.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.0 // indirect
Expand All @@ -28,27 +47,50 @@ require (
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.17.2 // indirect
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/posener/complete v1.2.1 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.0 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
Loading

0 comments on commit 92fa401

Please sign in to comment.