Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.0 (February 24, 2026)

FEATURES:

* **New Resource:** `bridge_bridges_stop` PR: [#5](https://github.com/jfrog/terraform-provider-bridge/pull/5)

## 1.0.0 (January 22, 2026)

FEATURES:
Expand Down
146 changes: 146 additions & 0 deletions pkg/bridge/resource_bridges_stop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package bridge

import (
"context"
"net/http"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/jfrog/terraform-provider-shared/util"
utilfw "github.com/jfrog/terraform-provider-shared/util/fw"
)

const (
StopEndpoint = "bridge-client/api/v1/bridges/{{bridge_ID}}/stop"
StopEndpoint = "bridge-client/api/v1/bridges/{{bridge_ID}}/stop"
)

func NewBridgesStopResource() resource.Resource {
return &BridgesStopResource{
TypeName: "bridge_stop",
}
}

type BridgesStopResource struct {
ProviderData util.ProviderMetadata
TypeName string
}

type BridgesStopResourceModel struct {
BridgeID types.String `tfsdk:"bridge_ID"`
BridgeClientBaseURL types.String `tfsdk:"bridge_client_BaseURL"`
}

type StopRequestAPIModel struct {
BridgeID string `json:"bridge_ID"`
BridgeClientBaseURL string `json:"bridge_client_BaseURL"`
}

type StopAPIModel struct {
BridgeID string `json:"bridge_ID"`
BridgeClientBaseURL string `json:"bridge_client_BaseURL"`
}

func (r *BridgesStopResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = r.TypeName
}

func (r *BridgesStopResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"bridge_ID": schema.StringAttribute{
Required: true,
Description: "The bridge_ID of the resource.",
},
"bridge_client_BaseURL": schema.StringAttribute{
Required: true,
Description: "Path parameter",
},
},
MarkdownDescription: "Manages stop in JFrog Bridge.",
}
}

func (r *BridgesStopResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
r.ProviderData = req.ProviderData.(util.ProviderMetadata)
}


func (r *BridgesStopResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
go util.SendUsageResourceCreate(ctx, r.ProviderData.Client.R(), r.ProviderData.ProductId, r.TypeName)

var plan BridgesStopResourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
}

requestBody := BridgesStopRequestAPIModel{
BridgeID: plan.BridgeID.ValueString(),
BridgeClientBaseURL: plan.BridgeClientBaseURL.ValueString(),
}

var result BridgesStopAPIModel

response, err := r.ProviderData.Client.R().
SetBody(requestBody).
SetResult(&result).
Post(StopEndpoint)
if err != nil {
utilfw.UnableToCreateResourceError(resp, err.Error())
return
}

if response.IsError() {
utilfw.UnableToCreateResourceError(resp, response.String())
return
}

resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)
}


func (r *BridgesStopResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
go util.SendUsageResourceRead(ctx, r.ProviderData.Client.R(), r.ProviderData.ProductId, r.TypeName)

var state BridgesStopResourceModel
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
}

var result BridgesStopAPIModel

response, err := r.ProviderData.Client.R().
SetPathParams(map[string]string{
"bridge_ID": state.BridgeID.ValueString(),
}).
SetResult(&result).
Get(StopEndpoint)
if err != nil {
utilfw.UnableToRefreshResourceError(resp, err.Error())
return
}

if response.StatusCode() == http.StatusNotFound {
resp.State.RemoveResource(ctx)
return
}

if response.IsError() {
utilfw.UnableToRefreshResourceError(resp, response.String())
return
}

resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
}




32 changes: 32 additions & 0 deletions pkg/bridge/resource_bridges_stop_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package bridge

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccBridgesStop_basic(t *testing.T) {
// TODO: Implement acceptance test
resource.Test(t, resource.TestCase{
PreCheck: func() { /* testAccPreCheck(t) */ },
ProtoV6ProviderFactories: nil, // TODO: set provider factories
Steps: []resource.TestStep{
{
Config: testAccBridgesStopConfig_basic(),
Check: resource.ComposeTestCheckFunc(
// TODO: Add checks
),
},
},
})
}

func testAccBridgesStopConfig_basic() string {
return `
resource "bridge_stop" "test" {
bridge_ID = "test-value"
bridge_client_BaseURL = "test-value"
}
`
}
Loading