// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
 * Copyright 2022 chyroc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lark

import (
	"context"
)

// CreateSheetProtectedDimension 该接口用于根据 spreadsheetToken 和维度信息增加多个保护范围；单次操作不超过5000行或列。
//
// 仅支持设置保护行或保护列, 暂不支持设置保护单元格
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/ugDNzUjL4QzM14CO0MTN
// new doc: https://open.feishu.cn/document/server-docs/docs/sheets-v3/protect-range/add-locked-cells
func (r *DriveService) CreateSheetProtectedDimension(ctx context.Context, request *CreateSheetProtectedDimensionReq, options ...MethodOptionFunc) (*CreateSheetProtectedDimensionResp, *Response, error) {
	if r.cli.mock.mockDriveCreateSheetProtectedDimension != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#CreateSheetProtectedDimension mock enable")
		return r.cli.mock.mockDriveCreateSheetProtectedDimension(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "CreateSheetProtectedDimension",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/protected_dimension",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(createSheetProtectedDimensionResp)

	response, err := r.cli.RawRequest(ctx, req, resp)
	return resp.Data, response, err
}

// MockDriveCreateSheetProtectedDimension mock DriveCreateSheetProtectedDimension method
func (r *Mock) MockDriveCreateSheetProtectedDimension(f func(ctx context.Context, request *CreateSheetProtectedDimensionReq, options ...MethodOptionFunc) (*CreateSheetProtectedDimensionResp, *Response, error)) {
	r.mockDriveCreateSheetProtectedDimension = f
}

// UnMockDriveCreateSheetProtectedDimension un-mock DriveCreateSheetProtectedDimension method
func (r *Mock) UnMockDriveCreateSheetProtectedDimension() {
	r.mockDriveCreateSheetProtectedDimension = nil
}

// CreateSheetProtectedDimensionReq ...
type CreateSheetProtectedDimensionReq struct {
	SpreadSheetToken      string                                                   `path:"spreadsheetToken" json:"-"`       // spreadsheet 的 token, 获取方式见 [在线表格开发指南](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)
	UserIDType            *IDType                                                  `query:"user_id_type" json:"-"`          // 请求的用户id类型, 可选open_id, union_id
	AddProtectedDimension []*CreateSheetProtectedDimensionReqAddProtectedDimension `json:"addProtectedDimension,omitempty"` // 需要增加保护范围的维度信息, 可多个范围
}

// CreateSheetProtectedDimensionReqAddProtectedDimension ...
type CreateSheetProtectedDimensionReqAddProtectedDimension struct {
	Dimension *CreateSheetProtectedDimensionReqAddProtectedDimensionDimension `json:"dimension,omitempty"` // 需要保护行列的维度信息
	Editors   []int64                                                         `json:"editors,omitempty"`   // 允许编辑保护范围的用户的 userID
	Users     []string                                                        `json:"users,omitempty"`     // 允许编辑保护范围的用户的id, id类型取决于user_id_type
	LockInfo  *string                                                         `json:"lockInfo,omitempty"`  // 保护范围的信息
}

// CreateSheetProtectedDimensionReqAddProtectedDimensionDimension ...
type CreateSheetProtectedDimensionReqAddProtectedDimensionDimension struct {
	SheetID        string  `json:"sheetId,omitempty"`        // sheetId
	MajorDimension *string `json:"majorDimension,omitempty"` // 默认 ROWS, 可选 ROWS、COLUMNS
	StartIndex     int64   `json:"startIndex"`               // 开始的位置
	EndIndex       int64   `json:"endIndex,omitempty"`       // 结束的位置
}

// CreateSheetProtectedDimensionResp ...
type CreateSheetProtectedDimensionResp struct {
	AddProtectedDimension []*CreateSheetProtectedDimensionRespAddProtectedDimension `json:"addProtectedDimension,omitempty"` // 需要增加保护范围的维度信息, 可多个范围
}

// CreateSheetProtectedDimensionRespAddProtectedDimension ...
type CreateSheetProtectedDimensionRespAddProtectedDimension struct {
	Dimension *CreateSheetProtectedDimensionRespAddProtectedDimensionDimension `json:"dimension,omitempty"` // 需要保护行列的维度信息
	Editors   []int64                                                          `json:"editors,omitempty"`   // 允许编辑保护范围的用户的 userID
	Users     []string                                                         `json:"users,omitempty"`     // 允许编辑保护范围的用户的id, id类型取决于user_id_type
	LockInfo  string                                                           `json:"lockInfo,omitempty"`  // 保护范围的信息
	ProtectID string                                                           `json:"protectId,omitempty"` // 保护区域的唯一 uid, 可用做后续解除保护
}

// CreateSheetProtectedDimensionRespAddProtectedDimensionDimension ...
type CreateSheetProtectedDimensionRespAddProtectedDimensionDimension struct {
	SheetID        string `json:"sheetId,omitempty"`        // sheetId
	MajorDimension string `json:"majorDimension,omitempty"` // 默认 ROWS, 可选 ROWS、COLUMNS
	StartIndex     int64  `json:"startIndex"`               // 开始的位置
	EndIndex       int64  `json:"endIndex,omitempty"`       // 结束的位置
}

// createSheetProtectedDimensionResp ...
type createSheetProtectedDimensionResp struct {
	Code int64                              `json:"code,omitempty"`
	Msg  string                             `json:"msg,omitempty"`
	Data *CreateSheetProtectedDimensionResp `json:"data,omitempty"`
}
