Skip to content

Commit ef9c668

Browse files
rashik-bhasinsagarp337
authored andcommitted
Added - Support for osp_gateway service supporting invoices and subscriptions
1 parent b3e3936 commit ef9c668

File tree

69 files changed

+9206
-0
lines changed

Some content is hidden

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

69 files changed

+9206
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {
5+
}
6+
7+
variable "user_ocid" {
8+
}
9+
10+
variable "fingerprint" {
11+
}
12+
13+
variable "private_key_path" {
14+
}
15+
16+
variable "compartment_ocid" {
17+
}
18+
19+
variable "region" {
20+
}
21+
22+
provider "oci" {
23+
region = "${var.region}"
24+
tenancy_ocid = "${var.tenancy_ocid}"
25+
user_ocid = "${var.user_ocid}"
26+
fingerprint = "${var.fingerprint}"
27+
private_key_path = "${var.private_key_path}"
28+
}
29+
30+
// invoices
31+
data "oci_osp_gateway_invoices" "test_invoices" {
32+
compartment_id = "${var.tenancy_ocid}"
33+
osp_home_region = "${var.region}"
34+
}
35+
36+
data "oci_osp_gateway_invoice" "test_invoice" {
37+
compartment_id = "${var.tenancy_ocid}"
38+
osp_home_region = "${var.region}"
39+
internal_invoice_id = "${lookup(data.oci_osp_gateway_invoices.test_invoices.invoice_collection.0.items[3], "internal_invoice_id")}"
40+
}
41+
42+
data "oci_osp_gateway_invoices_invoice_lines" "test_invoice_lines" {
43+
compartment_id = "${var.tenancy_ocid}"
44+
osp_home_region = "${var.region}"
45+
internal_invoice_id = "${data.oci_osp_gateway_invoice.test_invoice.internal_invoice_id}"
46+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {
5+
}
6+
7+
variable "user_ocid" {
8+
}
9+
10+
variable "fingerprint" {
11+
}
12+
13+
variable "private_key_path" {
14+
}
15+
16+
variable "compartment_ocid" {
17+
}
18+
19+
variable "region" {
20+
}
21+
22+
provider "oci" {
23+
region = "${var.region}"
24+
tenancy_ocid = "${var.tenancy_ocid}"
25+
user_ocid = "${var.user_ocid}"
26+
fingerprint = "${var.fingerprint}"
27+
private_key_path = "${var.private_key_path}"
28+
}
29+
30+
data "oci_osp_gateway_subscriptions" "test_subscriptions" {
31+
compartment_id = "${var.tenancy_ocid}"
32+
osp_home_region = "${var.region}"
33+
}
34+
35+
data "oci_osp_gateway_subscription" "test_subscription" {
36+
compartment_id = "${var.tenancy_ocid}"
37+
osp_home_region = "${var.region}"
38+
subscription_id = "${lookup(data.oci_osp_gateway_subscriptions.test_subscriptions.subscription_collection.0.items[0], "id")}"
39+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package client
5+
6+
import (
7+
oci_osp_gateway "github.com/oracle/oci-go-sdk/v56/ospgateway"
8+
9+
oci_common "github.com/oracle/oci-go-sdk/v56/common"
10+
)
11+
12+
func init() {
13+
RegisterOracleClient("oci_osp_gateway.InvoiceServiceClient", &OracleClient{InitClientFn: initOspgatewayInvoiceServiceClient})
14+
RegisterOracleClient("oci_osp_gateway.SubscriptionServiceClient", &OracleClient{InitClientFn: initOspgatewaySubscriptionServiceClient})
15+
}
16+
17+
func initOspgatewayInvoiceServiceClient(configProvider oci_common.ConfigurationProvider, configureClient ConfigureClient, serviceClientOverrides ServiceClientOverrides) (interface{}, error) {
18+
client, err := oci_osp_gateway.NewInvoiceServiceClientWithConfigurationProvider(configProvider)
19+
if err != nil {
20+
return nil, err
21+
}
22+
err = configureClient(&client.BaseClient)
23+
if err != nil {
24+
return nil, err
25+
}
26+
27+
if serviceClientOverrides.HostUrlOverride != "" {
28+
client.Host = serviceClientOverrides.HostUrlOverride
29+
}
30+
return &client, nil
31+
}
32+
33+
func (m *OracleClients) InvoiceServiceClient() *oci_osp_gateway.InvoiceServiceClient {
34+
return m.GetClient("oci_osp_gateway.InvoiceServiceClient").(*oci_osp_gateway.InvoiceServiceClient)
35+
}
36+
37+
func initOspgatewaySubscriptionServiceClient(configProvider oci_common.ConfigurationProvider, configureClient ConfigureClient, serviceClientOverrides ServiceClientOverrides) (interface{}, error) {
38+
client, err := oci_osp_gateway.NewSubscriptionServiceClientWithConfigurationProvider(configProvider)
39+
if err != nil {
40+
return nil, err
41+
}
42+
err = configureClient(&client.BaseClient)
43+
if err != nil {
44+
return nil, err
45+
}
46+
47+
if serviceClientOverrides.HostUrlOverride != "" {
48+
client.Host = serviceClientOverrides.HostUrlOverride
49+
}
50+
return &client, nil
51+
}
52+
53+
func (m *OracleClients) SubscriptionServiceClient() *oci_osp_gateway.SubscriptionServiceClient {
54+
return m.GetClient("oci_osp_gateway.SubscriptionServiceClient").(*oci_osp_gateway.SubscriptionServiceClient)
55+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/terraform-providers/terraform-provider-oci/internal/acctest"
11+
"github.com/terraform-providers/terraform-provider-oci/internal/utils"
12+
13+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
14+
15+
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
16+
)
17+
18+
var (
19+
invoiceSingularDataSourceRepresentation = map[string]interface{}{
20+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
21+
"internal_invoice_id": acctest.Representation{RepType: acctest.Required, Create: `${lookup(data.oci_osp_gateway_invoices.test_invoices.invoice_collection.0.items[3], "internal_invoice_id")}`},
22+
"osp_home_region": acctest.Representation{RepType: acctest.Required, Create: `${var.home_region}`},
23+
}
24+
25+
invoiceDataSourceRepresentation = map[string]interface{}{
26+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
27+
"osp_home_region": acctest.Representation{RepType: acctest.Required, Create: `${var.home_region}`},
28+
}
29+
30+
InvoiceResourceConfig = ""
31+
)
32+
33+
// issue-routing-tag: osp_gateway/default
34+
func TestOspGatewayInvoiceResource_basic(t *testing.T) {
35+
t.Skip("Invoice tests are not supported due to test resource unavailability.")
36+
37+
httpreplay.SetScenario("TestOspGatewayInvoiceResource_basic")
38+
defer httpreplay.SaveScenario()
39+
40+
config := acctest.ProviderTestConfig()
41+
42+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
43+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
44+
45+
homeRegion := utils.GetEnvSettingWithBlankDefault("region")
46+
regionVariableStr := fmt.Sprintf("variable \"home_region\" { default = \"%s\" }\n", homeRegion)
47+
48+
datasourceName := "data.oci_osp_gateway_invoices.test_invoices"
49+
singularDatasourceName := "data.oci_osp_gateway_invoice.test_invoice"
50+
51+
acctest.SaveConfigContent("", "", "", t)
52+
53+
acctest.ResourceTest(t, nil, []resource.TestStep{
54+
// verify datasource
55+
{
56+
Config: config +
57+
acctest.GenerateDataSourceFromRepresentationMap("oci_osp_gateway_invoices", "test_invoices", acctest.Required, acctest.Create, invoiceDataSourceRepresentation) +
58+
compartmentIdVariableStr + regionVariableStr + InvoiceResourceConfig,
59+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
60+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
61+
resource.TestCheckResourceAttr(datasourceName, "osp_home_region", homeRegion),
62+
63+
resource.TestCheckResourceAttrSet(datasourceName, "invoice_collection.#"),
64+
),
65+
},
66+
// verify singular datasource
67+
{
68+
Config: config +
69+
acctest.GenerateDataSourceFromRepresentationMap("oci_osp_gateway_invoices", "test_invoices", acctest.Required, acctest.Create, invoiceDataSourceRepresentation) +
70+
acctest.GenerateDataSourceFromRepresentationMap("oci_osp_gateway_invoice", "test_invoice", acctest.Required, acctest.Create, invoiceSingularDataSourceRepresentation) +
71+
compartmentIdVariableStr + regionVariableStr + InvoiceResourceConfig,
72+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
73+
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
74+
resource.TestCheckResourceAttrSet(singularDatasourceName, "internal_invoice_id"),
75+
resource.TestCheckResourceAttr(singularDatasourceName, "osp_home_region", homeRegion),
76+
77+
resource.TestCheckResourceAttr(singularDatasourceName, "bill_to_address.#", "1"),
78+
resource.TestCheckResourceAttr(singularDatasourceName, "currency.#", "1"),
79+
resource.TestCheckResourceAttrSet(singularDatasourceName, "internal_invoice_id"),
80+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_amount"),
81+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_amount_adjusted"),
82+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_amount_applied"),
83+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_amount_credited"),
84+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_amount_due"),
85+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_number"),
86+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_ref_number"),
87+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_status"),
88+
resource.TestCheckResourceAttrSet(singularDatasourceName, "invoice_type"),
89+
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_credit_card_payable"),
90+
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_display_download_pdf"),
91+
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_payable"),
92+
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_pdf_email_available"),
93+
resource.TestCheckResourceAttr(singularDatasourceName, "last_payment_detail.#", "1"),
94+
resource.TestCheckResourceAttrSet(singularDatasourceName, "payment_terms"),
95+
resource.TestCheckResourceAttrSet(singularDatasourceName, "preferred_email"),
96+
resource.TestCheckResourceAttr(singularDatasourceName, "subscription_ids.#", "1"),
97+
resource.TestCheckResourceAttrSet(singularDatasourceName, "tax"),
98+
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_invoice"),
99+
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_invoice_due"),
100+
),
101+
},
102+
})
103+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/terraform-providers/terraform-provider-oci/internal/acctest"
11+
"github.com/terraform-providers/terraform-provider-oci/internal/utils"
12+
13+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
14+
15+
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
16+
)
17+
18+
var (
19+
invoicesInvoiceLineDataSourceRepresentation = map[string]interface{}{
20+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
21+
"internal_invoice_id": acctest.Representation{RepType: acctest.Required, Create: `${lookup(data.oci_osp_gateway_invoices.test_invoices.invoice_collection.0.items[3], "internal_invoice_id")}`},
22+
"osp_home_region": acctest.Representation{RepType: acctest.Required, Create: `${var.home_region}`},
23+
}
24+
25+
InvoicesInvoiceLineResourceConfig = ""
26+
)
27+
28+
// issue-routing-tag: osp_gateway/default
29+
func TestOspGatewayInvoicesInvoiceLineResource_basic(t *testing.T) {
30+
t.Skip("Invoice tests are not supported due to test resource unavailability.")
31+
32+
httpreplay.SetScenario("TestOspGatewayInvoicesInvoiceLineResource_basic")
33+
defer httpreplay.SaveScenario()
34+
35+
config := acctest.ProviderTestConfig()
36+
37+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
38+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
39+
40+
homeRegion := utils.GetEnvSettingWithBlankDefault("region")
41+
regionVariableStr := fmt.Sprintf("variable \"home_region\" { default = \"%s\" }\n", homeRegion)
42+
43+
datasourceName := "data.oci_osp_gateway_invoices_invoice_lines.test_invoices_invoice_lines"
44+
45+
acctest.SaveConfigContent("", "", "", t)
46+
47+
acctest.ResourceTest(t, nil, []resource.TestStep{
48+
// verify datasource
49+
{
50+
Config: config +
51+
acctest.GenerateDataSourceFromRepresentationMap("oci_osp_gateway_invoices", "test_invoices", acctest.Required, acctest.Create, invoiceDataSourceRepresentation) +
52+
acctest.GenerateDataSourceFromRepresentationMap("oci_osp_gateway_invoices_invoice_lines", "test_invoices_invoice_lines", acctest.Required, acctest.Create, invoicesInvoiceLineDataSourceRepresentation) +
53+
compartmentIdVariableStr + regionVariableStr + InvoicesInvoiceLineResourceConfig,
54+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
55+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
56+
resource.TestCheckResourceAttrSet(datasourceName, "internal_invoice_id"),
57+
resource.TestCheckResourceAttr(datasourceName, "osp_home_region", homeRegion),
58+
59+
resource.TestCheckResourceAttrSet(datasourceName, "invoice_line_collection.#"),
60+
resource.TestCheckResourceAttr(datasourceName, "invoice_line_collection.0.items.#", "1"),
61+
),
62+
},
63+
})
64+
}

0 commit comments

Comments
 (0)